mirror of
https://github.com/scratchfoundation/paper.js.git
synced 2025-01-19 14:10:14 -05:00
Rename Item#applyMatrix() to shorter #apply().
This commit is contained in:
parent
61dca0b4d0
commit
97b66582f8
3 changed files with 13 additions and 12 deletions
|
@ -1830,7 +1830,7 @@ function(name) {
|
||||||
if (this._transform)
|
if (this._transform)
|
||||||
this._transform(matrix);
|
this._transform(matrix);
|
||||||
if (apply)
|
if (apply)
|
||||||
this.applyMatrix();
|
this.apply();
|
||||||
// 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);
|
||||||
|
@ -1856,14 +1856,15 @@ function(name) {
|
||||||
return this;
|
return this;
|
||||||
},
|
},
|
||||||
|
|
||||||
applyMatrix: function() {
|
// DOCS: Document #apply()
|
||||||
// Call the internal #_applyMatrix(), and set the internal _matrix to
|
apply: function() {
|
||||||
// the identity transformation if it was possible to apply it.
|
// Call the internal #_apply(), and set the internal _matrix to the
|
||||||
|
// identity transformation if it was possible to apply it.
|
||||||
// Application is not possible on Raster, PointText, PlacedSymbol, since
|
// Application is not possible on Raster, PointText, PlacedSymbol, since
|
||||||
// the matrix is storing the actual location / transformation state.
|
// the matrix is storing the actual location / transformation state.
|
||||||
// Pass on this._matrix to _applyMatrix calls, for reasons of faster
|
// Pass on this._matrix to _apply calls, for reasons of faster access
|
||||||
// access and code minification.
|
// and code minification.
|
||||||
if (this._applyMatrix(this._matrix)) {
|
if (this._apply(this._matrix)) {
|
||||||
// Set _matrix to the identity
|
// Set _matrix to the identity
|
||||||
this._matrix.setIdentity();
|
this._matrix.setIdentity();
|
||||||
// TODO: This needs a _changed notification, but the GEOMETRY
|
// TODO: This needs a _changed notification, but the GEOMETRY
|
||||||
|
@ -1871,13 +1872,13 @@ function(name) {
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
_applyMatrix: function(matrix) {
|
_apply: function(matrix) {
|
||||||
// Pass on the transformation to the children, and apply it there too:
|
// Pass on the transformation to the children, and apply it there too:
|
||||||
if (this._children) {
|
if (this._children) {
|
||||||
for (var i = 0, l = this._children.length; i < l; i++) {
|
for (var i = 0, l = this._children.length; i < l; i++) {
|
||||||
var child = this._children[i];
|
var child = this._children[i];
|
||||||
child.transform(matrix);
|
child.transform(matrix);
|
||||||
child.applyMatrix();
|
child.apply();
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
|
@ -206,7 +206,7 @@ var Path = this.Path = PathItem.extend(/** @lends Path# */{
|
||||||
// path, with the added benefit that b can be < a, and closed looping is
|
// path, with the added benefit that b can be < a, and closed looping is
|
||||||
// taken into account.
|
// taken into account.
|
||||||
|
|
||||||
_applyMatrix: function(matrix) {
|
_apply: 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);
|
||||||
|
|
|
@ -54,7 +54,7 @@ test('path.bounds', function() {
|
||||||
|
|
||||||
// Set new bounds and check segment list as result of resizing / positioning
|
// Set new bounds and check segment list as result of resizing / positioning
|
||||||
path.bounds = { x: 100, y: 100, width: 200, height: 200 };
|
path.bounds = { x: 100, y: 100, width: 200, height: 200 };
|
||||||
path.applyMatrix();
|
path.apply();
|
||||||
equals(path.segments.toString(),
|
equals(path.segments.toString(),
|
||||||
'{ point: { x: 107.93077, y: 179.56917 }, handleIn: { x: -24.41127, y: 51.30707 }, handleOut: { x: 39.52904, y: -83.08194 } },{ point: { x: 271.10084, y: 160.66656 }, handleIn: { x: -53.96176, y: -99.91377 }, handleOut: { x: 53.96176, y: 99.91377 } },{ point: { x: 215.85428, y: 296.96086 }, handleIn: { x: 85.81084, y: -17.18521 }, handleOut: { x: -101.49949, y: 20.32729 } }',
|
'{ point: { x: 107.93077, y: 179.56917 }, handleIn: { x: -24.41127, y: 51.30707 }, handleOut: { x: 39.52904, y: -83.08194 } },{ point: { x: 271.10084, y: 160.66656 }, handleIn: { x: -53.96176, y: -99.91377 }, handleOut: { x: 53.96176, y: 99.91377 } },{ point: { x: 215.85428, y: 296.96086 }, handleIn: { x: 85.81084, y: -17.18521 }, handleOut: { x: -101.49949, y: 20.32729 } }',
|
||||||
'resized path.segments');
|
'resized path.segments');
|
||||||
|
@ -65,7 +65,7 @@ test('path.bounds', function() {
|
||||||
{ x: 92.38109, y: 106.78957, width: 191.4803, height: 203.66878 },
|
{ x: 92.38109, y: 106.78957, width: 191.4803, height: 203.66878 },
|
||||||
'rotated path.bounds');
|
'rotated path.bounds');
|
||||||
|
|
||||||
path.applyMatrix();
|
path.apply();
|
||||||
equals(path.segments.toString(),
|
equals(path.segments.toString(),
|
||||||
'{ point: { x: 142.60356, y: 125.16811 }, handleIn: { x: -51.67967, y: 23.61224 }, handleOut: { x: 83.68504, y: -38.23568 } },{ point: { x: 279.74945, y: 215.57158 }, handleIn: { x: 22.88623, y: -111.22434 }, handleOut: { x: -22.88623, y: 111.22434 } },{ point: { x: 149.81984, y: 284.46726 }, handleIn: { x: 76.78135, y: 41.99351 }, handleOut: { x: -90.81925, y: -49.67101 } }',
|
'{ point: { x: 142.60356, y: 125.16811 }, handleIn: { x: -51.67967, y: 23.61224 }, handleOut: { x: 83.68504, y: -38.23568 } },{ point: { x: 279.74945, y: 215.57158 }, handleIn: { x: 22.88623, y: -111.22434 }, handleOut: { x: -22.88623, y: 111.22434 } },{ point: { x: 149.81984, y: 284.46726 }, handleIn: { x: 76.78135, y: 41.99351 }, handleOut: { x: -90.81925, y: -49.67101 } }',
|
||||||
'roated path.segments');
|
'roated path.segments');
|
||||||
|
|
Loading…
Reference in a new issue