finished pixel detection algo which can be applied to any Shape. This enables a lot of new functionality, such as image pixel detection, shape border detection, and custom shape detection that isn't drawn with a standard path

This commit is contained in:
Eric Rowell
2012-04-01 01:08:33 -07:00
parent 08e2b74da9
commit 95fabe9160
6 changed files with 140 additions and 17 deletions

View File

@@ -519,6 +519,75 @@ Test.prototype.tests = {
};
imageObj.src = '../darth-vader.jpg';
},
/*
* WARNING: this functional test will only pass if it's hosted on
* a webserver due to cross domain security issues
*/
'EVENTS - image pixel detection': function(containerId) {
var imageObj = new Image();
imageObj.onload = function() {
var stage = new Kinetic.Stage({
container: containerId,
width: 578,
height: 200
});
var layer = new Kinetic.Layer();
var darth = new Kinetic.Image({
x: 200,
y: 40,
image: imageObj,
detectionType: 'pixel',
draggable: true
});
darth.on('mouseover', function() {
log('mouseover');
});
darth.on('mouseout', function() {
log('mouseout');
});
layer.add(darth);
stage.add(layer);
};
imageObj.src = '../lion.png';
},
'EVENTS - star pixel detection': function(containerId) {
var imageObj = new Image();
imageObj.onload = function() {
var stage = new Kinetic.Stage({
container: containerId,
width: 578,
height: 200
});
var layer = new Kinetic.Layer();
var star = new Kinetic.Star({
x: 200,
y: 100,
points: 10,
innerRadius: 40,
outerRadius: 70,
fill: 'green',
stroke: 'blue',
strokeWidth: 20,
detectionType: 'pixel',
draggable: true
});
star.on('mouseover', function() {
log('mouseover');
});
star.on('mouseout', function() {
log('mouseout');
});
layer.add(star);
stage.add(layer);
};
imageObj.src = '../lion.png';
},
'EVENTS - drag events click': function(containerId) {
var stage = new Kinetic.Stage({
container: containerId,

BIN
tests/lion.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 19 KiB