Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Group globalToLocal/localToGlobal tests together

  • Loading branch information...
commit fa8ed637940ae5a312271e6e03753af744aeaf0b 1 parent bbe24b4
@davidaurelio davidaurelio authored
Showing with 52 additions and 47 deletions.
  1. +52 −47 test/display_object-spec.js
View
99 test/display_object-spec.js
@@ -411,67 +411,72 @@ define([
});
});
- describe('globalToLocal', function() {
- it('should apply the transform of an display object to a point', function() {
- var point = new Point(-102, 23.75);
- var matrix = new Matrix(1.0625, 0.3125, -1.25, -1.09375, 26.5, -34);
- var displayObject = new DisplayObject().attr('matrix', matrix);
-
- expect(displayObject.globalToLocal(point))
- .toEqual(matrix.transformPoint(point));
+ describe('Coordinate space conversion', function() {
});
- it('should apply the computed transform of the display object and each parent', function() {
- var point = new Point(-102, 23.75);
- var matrix = new Matrix(1.375, -0.75, 1.328125, -0.15625, 41.75, -34.25);
- var displayObject = new DisplayObject().attr('matrix', matrix);
+ describe('globalToLocal', function() {
- var parent = new Group();
- parent.addChild(displayObject);
- var parentMatrix = new Matrix(1.9375, -1.609375, -1.609375, -0.078125, -15.5, -7);
- parent.attr('matrix', parentMatrix);
+ it('should apply the transform of an display object to a point', function() {
+ var point = new Point(-102, 23.75);
+ var matrix = new Matrix(1.0625, 0.3125, -1.25, -1.09375, 26.5, -34);
+ var displayObject = new DisplayObject().attr('matrix', matrix);
- var root = new Group();
- root.addChild(parent);
- var rootMatrix = new Matrix(-0.0625, 1.6875, -1.5, -1.421875, -14.5, 36.75);
- root.attr('matrix', rootMatrix);
+ expect(displayObject.globalToLocal(point))
+ .toEqual(matrix.transformPoint(point));
+ });
- var absoluteMatrix = matrix.concat(parentMatrix).concat(rootMatrix);
+ it('should apply the computed transform of the display object and each parent', function() {
+ var point = new Point(-102, 23.75);
+ var matrix = new Matrix(1.375, -0.75, 1.328125, -0.15625, 41.75, -34.25);
+ var displayObject = new DisplayObject().attr('matrix', matrix);
- expect(displayObject.globalToLocal(point))
- .toEqual(absoluteMatrix.transformPoint(point));
- });
- });
+ var parent = new Group();
+ parent.addChild(displayObject);
+ var parentMatrix = new Matrix(1.9375, -1.609375, -1.609375, -0.078125, -15.5, -7);
+ parent.attr('matrix', parentMatrix);
- describe('localToGlobal', function() {
- it('should apply the inversed transform of an display object to a point', function() {
- var point = new Point(-102, 23.75);
- var matrix = new Matrix(1.0625, 0.3125, -1.25, -1.09375, 26.5, -34);
- var displayObject = new DisplayObject().attr('matrix', matrix);
+ var root = new Group();
+ root.addChild(parent);
+ var rootMatrix = new Matrix(-0.0625, 1.6875, -1.5, -1.421875, -14.5, 36.75);
+ root.attr('matrix', rootMatrix);
- expect(displayObject.localToGlobal(point))
- .toEqual(matrix.invert().transformPoint(point));
+ var absoluteMatrix = matrix.concat(parentMatrix).concat(rootMatrix);
+
+ expect(displayObject.globalToLocal(point))
+ .toEqual(absoluteMatrix.transformPoint(point));
+ });
});
- it('should apply the inverse computed transform of the display object and each parent', function() {
- var point = new Point(-102, 23.75);
- var matrix = new Matrix(1.375, -0.75, 1.328125, -0.15625, 41.75, -34.25);
- var displayObject = new DisplayObject().attr('matrix', matrix);
+ describe('localToGlobal', function() {
+ it('should apply the inversed transform of an display object to a point', function() {
+ var point = new Point(-102, 23.75);
+ var matrix = new Matrix(1.0625, 0.3125, -1.25, -1.09375, 26.5, -34);
+ var displayObject = new DisplayObject().attr('matrix', matrix);
- var parent = new Group();
- parent.addChild(displayObject);
- var parentMatrix = new Matrix(1.9375, -1.609375, -1.609375, -0.078125, -15.5, -7);
- parent.attr('matrix', parentMatrix);
+ expect(displayObject.localToGlobal(point))
+ .toEqual(matrix.invert().transformPoint(point));
+ });
+
+ it('should apply the inverse computed transform of the display object and each parent', function() {
+ var point = new Point(-102, 23.75);
+ var matrix = new Matrix(1.375, -0.75, 1.328125, -0.15625, 41.75, -34.25);
+ var displayObject = new DisplayObject().attr('matrix', matrix);
- var root = new Group();
- root.addChild(parent);
- var rootMatrix = new Matrix(-0.0625, 1.6875, -1.5, -1.421875, -14.5, 36.75);
- root.attr('matrix', rootMatrix);
+ var parent = new Group();
+ parent.addChild(displayObject);
+ var parentMatrix = new Matrix(1.9375, -1.609375, -1.609375, -0.078125, -15.5, -7);
+ parent.attr('matrix', parentMatrix);
- var absoluteMatrix = matrix.concat(parentMatrix).concat(rootMatrix);
+ var root = new Group();
+ root.addChild(parent);
+ var rootMatrix = new Matrix(-0.0625, 1.6875, -1.5, -1.421875, -14.5, 36.75);
+ root.attr('matrix', rootMatrix);
- expect(displayObject.localToGlobal(point))
- .toEqual(absoluteMatrix.invert().transformPoint(point));
+ var absoluteMatrix = matrix.concat(parentMatrix).concat(rootMatrix);
+
+ expect(displayObject.localToGlobal(point))
+ .toEqual(absoluteMatrix.invert().transformPoint(point));
+ });
});
});
});
Please sign in to comment.
Something went wrong with that request. Please try again.