mirror of
https://github.com/konvajs/konva.git
synced 2026-01-02 20:42:42 +08:00
added support for image hit detection with new color mapping algo
This commit is contained in:
@@ -11,7 +11,7 @@ Kinetic.Plugins = {};
|
||||
Kinetic.Global = {
|
||||
BUBBLE_WHITELIST: ['mousedown', 'mousemove', 'mouseup', 'mouseover', 'mouseout', 'click', 'dblclick', 'touchstart', 'touchmove', 'touchend', 'tap', 'dbltap', 'dragstart', 'dragmove', 'dragend'],
|
||||
BUFFER_WHITELIST: ['fill', 'stroke', 'textFill', 'textStroke'],
|
||||
BUFFER_BLACKLIST: ['shadow'],
|
||||
BUFFER_BLACKLIST: ['shadow', 'image'],
|
||||
stages: [],
|
||||
idCounter: 0,
|
||||
tempNodes: {},
|
||||
|
||||
@@ -355,7 +355,12 @@ Kinetic.Shape = Kinetic.Node.extend({
|
||||
var wl = Kinetic.Global.BUFFER_WHITELIST;
|
||||
var bl = Kinetic.Global.BUFFER_BLACKLIST;
|
||||
var attrs = {};
|
||||
|
||||
if(canvas.name === 'buffer') {
|
||||
if('image' in this.attrs) {
|
||||
this.attrs.fill = '#' + this.colorKey;
|
||||
}
|
||||
|
||||
for(var n = 0; n < wl.length; n++) {
|
||||
var key = wl[n];
|
||||
attrs[key] = this.attrs[key];
|
||||
@@ -368,13 +373,14 @@ Kinetic.Shape = Kinetic.Node.extend({
|
||||
attrs[key] = this.attrs[key];
|
||||
this.attrs[key] = '';
|
||||
}
|
||||
|
||||
context.globalAlpha = 1;
|
||||
}
|
||||
|
||||
this.attrs.drawFunc.call(this, canvas.getContext());
|
||||
|
||||
if(canvas.name === 'buffer') {
|
||||
var bothLists = wl.concat(bl);
|
||||
var bothLists = wl.concat(bl);
|
||||
for(var n = 0; n < bothLists.length; n++) {
|
||||
var key = bothLists[n];
|
||||
this.attrs[key] = attrs[key];
|
||||
|
||||
@@ -19,16 +19,17 @@ Kinetic.Image = Kinetic.Shape.extend({
|
||||
this._super(config);
|
||||
},
|
||||
drawFunc: function(context) {
|
||||
var width = this.getWidth();
|
||||
var height = this.getHeight();
|
||||
|
||||
context.beginPath();
|
||||
context.rect(0, 0, width, height);
|
||||
context.closePath();
|
||||
this.fill(context);
|
||||
this.stroke(context);
|
||||
|
||||
if(this.attrs.image) {
|
||||
var width = this.getWidth();
|
||||
var height = this.getHeight();
|
||||
|
||||
context.beginPath();
|
||||
context.rect(0, 0, width, height);
|
||||
context.closePath();
|
||||
this.fill(context);
|
||||
this.stroke(context);
|
||||
|
||||
context.beginPath();
|
||||
// if cropping
|
||||
if(this.attrs.crop && this.attrs.crop.width && this.attrs.crop.height) {
|
||||
var cropX = this.attrs.crop.x ? this.attrs.crop.x : 0;
|
||||
|
||||
Reference in New Issue
Block a user