PDA

View Full Version : [OPEN] [4.0.2a]Bugs in Ext.draw.Sprite.setAttributes()



Evantan
25 Jul 2011, 9:17 AM
Cannot do translate when set all args with 0(x==0 && y==0).
Cannot do rotate when set all args with 0(x==0 && y==0 && degrees==0).
Cannot do scale when set all args with 0(x==0 && y==0 && cx==0 && cy==0).

Maybe this because in Ext.draw.Sprite's setAttributes() method:


translate = attrs.translate;
translation = spriteAttrs.translation;
if (translate) {
if ((translate.x && translate.x !== translation.x) ||
(translate.y && translate.y !== translation.y)) {
Ext.apply(translation, translate);
me.dirtyTransform = true;
}
delete attrs.translate;
}

rotate = attrs.rotate;
rotation = spriteAttrs.rotation;
if (rotate) {
if ((rotate.x && rotate.x !== rotation.x) ||
(rotate.y && rotate.y !== rotation.y) ||
(rotate.degrees && rotate.degrees !== rotation.degrees)) {
Ext.apply(rotation, rotate);
me.dirtyTransform = true;
}
delete attrs.rotate;
}

scale = attrs.scale;
scaling = spriteAttrs.scaling;
if (scale) {
if ((scale.x && scale.x !== scaling.x) ||
(scale.y && scale.y !== scaling.y) ||
(scale.cx && scale.cx !== scaling.cx) ||
(scale.cy && scale.cy !== scaling.cy)) {
Ext.apply(scaling, scale);
me.dirtyTransform = true;
}
delete attrs.scale;
}


Should these code replace by: .. != undefined ?
Sorry for poor english.

mike.estes
25 Jul 2011, 10:29 AM
could you fill out the bug report template (http://www.sencha.com/forum/showthread.php?138165-How-to-report-a-bug), specifically providing a test case here would help us process this faster.

Evantan
25 Jul 2011, 11:22 AM
REQUIRED INFORMATION


Ext version tested:

Ext 4.0.2a


Browser versions tested against:

IE9
FF4


Description:

Cannot do translate when set all args with 0(x==0 && y==0).
Cannot do rotate when set all args with 0(x==0 && y==0 && degrees==0).
Cannot do scale when set all args with 0(x==0 && y==0 && cx==0 && cy==0).


Steps to reproduce the problem:

Create a sprite, do some translate/rotate /scale, and then do another translate/rotate /scale with all args set to zero.


The result that was expected:

Both translate/rotate /scale can take effect.


The result that occurs instead:

Only the first translate/rotate /scale take effect.


Test Case:



var drawComponent = Ext.create('Ext.draw.Component', {
width: 400,
height: 400,
renderTo: document.body,
viewBox: false
}), surface = drawComponent.surface;
var c = surface.add({
type: 'rect',
fill: '#ccc',
x: 0,
y: 0,
width: 100,
height: 200,
translate: {
x: 100,
y: 100
},
rotate: {
x: 100,
y: 100,
degrees: 30
},
scale: {
cx: 10,
cy: 10,
x: 0.2,
y: 0.2
}
});
c.show(true);
c.setAttributes({
translate: {
x: 0,
y: 0
},
rotate: {
x: 0,
y: 0,
degrees: 0
},
scale: {
cx: 0,
cy: 0,
x: 0,
y: 0
}
}, true);




HELPFUL INFORMATION


Debugging already done:

Yes



Maybe this because in Ext.draw.Sprite's setAttributes() method: (Colored code)


translate = attrs.translate;
translation = spriteAttrs.translation;
if (translate) {
if ((translate.x && translate.x !== translation.x) ||
(translate.y && translate.y !== translation.y)) {
Ext.apply(translation, translate);
me.dirtyTransform = true;
}
delete attrs.translate;
}

rotate = attrs.rotate;
rotation = spriteAttrs.rotation;
if (rotate) {
if ((rotate.x && rotate.x !== rotation.x) ||
(rotate.y && rotate.y !== rotation.y) ||
(rotate.degrees && rotate.degrees !== rotation.degrees)) {
Ext.apply(rotation, rotate);
me.dirtyTransform = true;
}
delete attrs.rotate;
}

scale = attrs.scale;
scaling = spriteAttrs.scaling;
if (scale) {
if ((scale.x && scale.x !== scaling.x) ||
(scale.y && scale.y !== scaling.y) ||
(scale.cx && scale.cx !== scaling.cx) ||
(scale.cy && scale.cy !== scaling.cy)) {
Ext.apply(scaling, scale);
me.dirtyTransform = true;
}
delete attrs.scale;
}




[/CODE]


Possible fix:

Replace colored code with ....!= undefined, or remove them all,I can't see any necessity

Evantan
25 Jul 2011, 11:24 AM
BTW: my another post (http://www.sencha.com/forum/showthread.php?141178-4.0.2a-Bug-in-Ext.draw.Surface-Scale-s-cx-cy-cannot-take-effect-when-do-scaling) about bug in Ext.draw.Surface

mike.estes
25 Jul 2011, 12:47 PM
thanks for updating your post, the test case helped me confirm the bug quickly. We have it filed as EXTJSIV-3572