mirror of
https://github.com/scratchfoundation/paper.js.git
synced 2025-01-06 04:42:15 -05:00
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:
parent
bb546decae
commit
8d99aa5f95
2 changed files with 12 additions and 13 deletions
|
@ -2151,8 +2151,18 @@ var Item = this.Item = Base.extend(Callback, {
|
||||||
// possible on Raster, PointText, PlacedSymbol, since the matrix is
|
// possible on Raster, PointText, PlacedSymbol, since the matrix is
|
||||||
// storing the actual location / transformation state.
|
// storing the actual location / transformation state.
|
||||||
if ((this.applyMatrix || arguments[1])
|
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();
|
this._matrix.reset();
|
||||||
|
}
|
||||||
// We always need to call _changed since we're caching bounds on all
|
// We always need to call _changed since we're caching bounds on all
|
||||||
// items, including Group.
|
// items, including Group.
|
||||||
this._changed(/*#=*/ Change.GEOMETRY);
|
this._changed(/*#=*/ Change.GEOMETRY);
|
||||||
|
|
|
@ -304,19 +304,8 @@ var Path = this.Path = PathItem.extend(/** @lends Path# */{
|
||||||
|
|
||||||
_applyMatrix: function(matrix) {
|
_applyMatrix: function(matrix) {
|
||||||
var coords = new Array(6);
|
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);
|
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;
|
return true;
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue