mirror of
https://github.com/scratchfoundation/paper.js.git
synced 2025-01-03 19:45:44 -05:00
Improve Item#_getStrokeMatrix()
This commit is contained in:
parent
948a8af9a8
commit
fefb4302e8
2 changed files with 9 additions and 8 deletions
|
@ -209,7 +209,7 @@ new function() { // Injection scope for various item event handlers
|
||||||
* @param {ChangeFlag} flags describes what exactly has changed
|
* @param {ChangeFlag} flags describes what exactly has changed
|
||||||
*/
|
*/
|
||||||
_changed: function(flags) {
|
_changed: function(flags) {
|
||||||
var symbol = this._parentSymbol,
|
var symbol = this._symbol,
|
||||||
cacheParent = this._parent || symbol,
|
cacheParent = this._parent || symbol,
|
||||||
project = this._project;
|
project = this._project;
|
||||||
if (flags & /*#=*/ChangeFlag.GEOMETRY) {
|
if (flags & /*#=*/ChangeFlag.GEOMETRY) {
|
||||||
|
@ -911,7 +911,7 @@ new function() { // Injection scope for various item event handlers
|
||||||
].join('');
|
].join('');
|
||||||
// NOTE: This needs to happen before returning cached values, since even
|
// NOTE: This needs to happen before returning cached values, since even
|
||||||
// then, _boundsCache needs to be kept up-to-date.
|
// then, _boundsCache needs to be kept up-to-date.
|
||||||
Item._updateBoundsCache(this._parent || this._parentSymbol, cacheItem);
|
Item._updateBoundsCache(this._parent || this._symbol, cacheItem);
|
||||||
if (cacheKey && this._bounds && cacheKey in this._bounds)
|
if (cacheKey && this._bounds && cacheKey in this._bounds)
|
||||||
return this._bounds[cacheKey].rect.clone();
|
return this._bounds[cacheKey].rect.clone();
|
||||||
var bounds = this._getBounds(matrix || _matrix, options);
|
var bounds = this._getBounds(matrix || _matrix, options);
|
||||||
|
@ -936,9 +936,10 @@ new function() { // Injection scope for various item event handlers
|
||||||
* is always shiftless, meaning its translation vector is reset to zero.
|
* is always shiftless, meaning its translation vector is reset to zero.
|
||||||
*/
|
*/
|
||||||
_getStrokeMatrix: function(matrix, options) {
|
_getStrokeMatrix: function(matrix, options) {
|
||||||
var mx = this.getStrokeScaling() ? matrix : (options && options.internal
|
var parent = this.getStrokeScaling() ? null
|
||||||
? this : this._parent || this._parentSymbol._item)
|
: options && options.internal ? this
|
||||||
.getViewMatrix().invert();
|
: this._parent || this._symbol && this._symbol._item,
|
||||||
|
mx = parent ? parent.getViewMatrix().invert() : matrix;
|
||||||
return mx && mx._shiftless();
|
return mx && mx._shiftless();
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
|
@ -104,11 +104,11 @@ var SymbolDefinition = Base.extend(/** @lends SymbolDefinition# */{
|
||||||
|
|
||||||
setItem: function(item, _dontCenter) {
|
setItem: function(item, _dontCenter) {
|
||||||
// Make sure we're not stealing another symbol's definition
|
// Make sure we're not stealing another symbol's definition
|
||||||
if (item._parentSymbol)
|
if (item._symbol)
|
||||||
item = item.clone();
|
item = item.clone();
|
||||||
// Remove previous definition's reference to this symbol
|
// Remove previous definition's reference to this symbol
|
||||||
if (this._item)
|
if (this._item)
|
||||||
this._item._parentSymbol = null;
|
this._item._symbol = null;
|
||||||
this._item = item;
|
this._item = item;
|
||||||
// Remove item from DOM, as it's embedded in Symbol now.
|
// Remove item from DOM, as it's embedded in Symbol now.
|
||||||
item.remove();
|
item.remove();
|
||||||
|
@ -116,7 +116,7 @@ var SymbolDefinition = Base.extend(/** @lends SymbolDefinition# */{
|
||||||
// Move position to 0, 0, so it's centered when placed.
|
// Move position to 0, 0, so it's centered when placed.
|
||||||
if (!_dontCenter)
|
if (!_dontCenter)
|
||||||
item.setPosition(new Point());
|
item.setPosition(new Point());
|
||||||
item._parentSymbol = this;
|
item._symbol = this;
|
||||||
this._changed(/*#=*/Change.GEOMETRY);
|
this._changed(/*#=*/Change.GEOMETRY);
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue