Handle color transformation in Item#transform() rather than Path#_applyMatrix().

Fixes an issue with BoucingBalls.html, now that CompoundPath#applyMatrix is true.
This commit is contained in:
Jürg Lehni 2013-04-19 13:13:54 -07:00
parent bb546decae
commit 8d99aa5f95
2 changed files with 12 additions and 13 deletions

View file

@ -2151,8 +2151,18 @@ var Item = this.Item = Base.extend(Callback, {
// possible on Raster, PointText, PlacedSymbol, since the matrix is
// storing the actual location / transformation state.
if ((this.applyMatrix || arguments[1])
&& this._applyMatrix(this._matrix))
&& this._applyMatrix(this._matrix)) {
// When the matrix could be applied, we also need to transform
// color styles with matrices (only gradients so far):
var style = this._style,
fillColor = style._fillColor,
strokeColor = style._strokeColor;
if (fillColor)
fillColor.transform(this._matrix);
if (strokeColor)
strokeColor.transform(this._matrix);
this._matrix.reset();
}
// We always need to call _changed since we're caching bounds on all
// items, including Group.
this._changed(/*#=*/ Change.GEOMETRY);

View file

@ -304,19 +304,8 @@ var Path = this.Path = PathItem.extend(/** @lends Path# */{
_applyMatrix: function(matrix) {
var coords = new Array(6);
for (var i = 0, l = this._segments.length; i < l; i++) {
for (var i = 0, l = this._segments.length; i < l; i++)
this._segments[i]._transformCoordinates(matrix, coords, true);
}
// See #draw() for an explanation of why we can access _style properties
// directly here:
var style = this._style,
fillColor = style._fillColor,
strokeColor = style._strokeColor;
// Try calling transform on colors in case they are gradients.
if (fillColor && fillColor._type === 'gradient')
fillColor.transform(matrix);
if (strokeColor && strokeColor._type === 'gradient')
strokeColor.transform(matrix);
return true;
},