Browse Source

Added isPointInPath() tests

v1.x
Tj Holowaychuk 14 years ago
parent
commit
bba08890c3
  1. 4
      src/context2d.cc
  2. 19
      test/canvas.test.js

4
src/context2d.cc

@ -345,6 +345,10 @@ Context2d::SetLineCap(Local<String> prop, Local<Value> val, const AccessorInfo &
} }
} }
/*
* Check if the given point is within the current path.
*/
Handle<Value> Handle<Value>
Context2d::IsPointInPath(const Arguments &args) { Context2d::IsPointInPath(const Arguments &args) {
HandleScope scope; HandleScope scope;

19
test/canvas.test.js

@ -480,5 +480,24 @@ module.exports = {
, path , path
, '6199442d05718481ac5ccd034239f6f1' , '6199442d05718481ac5ccd034239f6f1'
, 'Context2d#clip() failed'); , 'Context2d#clip() failed');
},
'test Context2d#isPointInPath()': function(assert){
var canvas = new Canvas(200, 200)
, ctx = canvas.getContext('2d');
ctx.rect(5,5,100,100);
ctx.rect(50,100,10,10);
assert.ok(ctx.isPointInPath(10,10));
assert.ok(ctx.isPointInPath(10,50));
assert.ok(ctx.isPointInPath(100,100));
assert.ok(ctx.isPointInPath(105,105));
assert.ok(!ctx.isPointInPath(106,105));
assert.ok(!ctx.isPointInPath(150,150));
assert.ok(ctx.isPointInPath(50,110));
assert.ok(ctx.isPointInPath(60,110));
assert.ok(!ctx.isPointInPath(70,110));
assert.ok(!ctx.isPointInPath(50,120));
} }
} }
Loading…
Cancel
Save