PDA

View Full Version : [4.0.2a]Bug in Ext.draw.Surface: Scale's cx/cy cannot take effect when do scaling



Evantan
21 Jul 2011, 3:22 AM
REQUIRED INFORMATION


Ext version tested:

Ext 4.0.2a


Browser versions tested against:

IE9
FF4
Chrome


Description:

Scale's cx/cy cannot take effect when do scaling.


Steps to reproduce the problem:

Defines a circle which centre is x:100 y:100, radius: 100
scale it:
scale: {
x: 0.5,
y: 0.5,
cx: 0,
cy: 0
}


The result that was expected:

the centre of the circle should change to x:50 y:50, because the scaling take the (0, 0) coordinate of surface as centers, not the centre of circle itself (100, 100).


The result that occurs instead:

the centre of the circle remain x:100 y:100


Test Case:



var drawComponent = Ext.create('Ext.draw.Component', {
width: 400,
height: 400,
renderTo: document.body,
viewBox: false,
items: [{
type: 'circle',
fill: '#ccc',
radius: 100,
x: 100,
y: 100
}]
}), surface = drawComponent.surface;
var c = surface.add({
type: 'circle',
fill: '#cc0',
radius: 100,
x: 100,
y: 100
});
c.show(true);
c.setAttributes({
scale: {
x: 0.5,
y: 0.5,
cx: 0,
cy: 0
}
}, true);




HELPFUL INFORMATION


Debugging already done:

yes

Found the bug in Ext.draw.Surface:


scale: function(sprite) {
var bbox,
x = sprite.attr.scaling.x || 1,
y = sprite.attr.scaling.y || 1,
centerX = sprite.attr.scaling.centerX,
centerY = sprite.attr.scaling.centerY;

... ...
});

It's wrong, it should be cx and cy.
Possible fix:

not provided


Another doc bug in Ext.draw.Surface: It's add() method say "Returns void",which should returns sprite just added.

BTW: what time the next version will issue? Waiting so long since 4.0.2a.It will be 4.0.4 or 4.1?

krystian
25 Oct 2012, 1:01 AM
This bug is still present in 4.1.1a
Proposed fix in this report fixes this issue (simply changing centerX->cx and centerY->cy).

See also: http://docs.sencha.com/ext-js/4-1/#!/api/Ext.draw.Sprite-method-setAttributes