mirror of
https://github.com/konvajs/konva.git
synced 2025-09-18 09:50:05 +08:00
Merge pull request #184 from soulBit/master
Sprites not respecting width and height
This commit is contained in:
@@ -32,6 +32,8 @@
|
|||||||
var anim = this.attrs.animation;
|
var anim = this.attrs.animation;
|
||||||
var index = this.attrs.index;
|
var index = this.attrs.index;
|
||||||
var f = this.attrs.animations[anim][index];
|
var f = this.attrs.animations[anim][index];
|
||||||
|
var width = this.attrs.width || f.width;
|
||||||
|
var height = this.attrs.height || f.height;
|
||||||
|
|
||||||
if(this.attrs.image) {
|
if(this.attrs.image) {
|
||||||
|
|
||||||
@@ -39,16 +41,18 @@
|
|||||||
context.rect(0, 0, f.width, f.height);
|
context.rect(0, 0, f.width, f.height);
|
||||||
context.closePath();
|
context.closePath();
|
||||||
|
|
||||||
this.drawImage(context, this.attrs.image, f.x, f.y, f.width, f.height, 0, 0, f.width, f.height);
|
this.drawImage(context, this.attrs.image, f.x, f.y, f.width, f.height, 0, 0, width, height);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
drawHitFunc: function(context) {
|
drawHitFunc: function(context) {
|
||||||
var anim = this.attrs.animation;
|
var anim = this.attrs.animation;
|
||||||
var index = this.attrs.index;
|
var index = this.attrs.index;
|
||||||
var f = this.attrs.animations[anim][index];
|
var f = this.attrs.animations[anim][index];
|
||||||
|
var width = this.attrs.width || f.width;
|
||||||
|
var height = this.attrs.height || f.height;
|
||||||
|
|
||||||
context.beginPath();
|
context.beginPath();
|
||||||
context.rect(0, 0, f.width, f.height);
|
context.rect(0, 0, width, height);
|
||||||
context.closePath();
|
context.closePath();
|
||||||
this.fillStroke(context);
|
this.fillStroke(context);
|
||||||
},
|
},
|
||||||
|
Reference in New Issue
Block a user