mirror of
https://github.com/scratchfoundation/paper.js.git
synced 2025-01-01 02:38:43 -05:00
Implement unit tests for Matrix#getRotation() and #getScaling().
Of which one test is failing.
This commit is contained in:
parent
6ae500e6df
commit
fa097e02f2
2 changed files with 92 additions and 0 deletions
91
test/tests/Matrix.js
Normal file
91
test/tests/Matrix.js
Normal file
|
@ -0,0 +1,91 @@
|
|||
/*
|
||||
* Paper.js - The Swiss Army Knife of Vector Graphics Scripting.
|
||||
* http://paperjs.org/
|
||||
*
|
||||
* Copyright (c) 2011 - 2013, Juerg Lehni & Jonathan Puckey
|
||||
* http://lehni.org/ & http://jonathanpuckey.com/
|
||||
*
|
||||
* Distributed under the MIT license. See LICENSE file for details.
|
||||
*
|
||||
* All rights reserved.
|
||||
*/
|
||||
|
||||
module('Matrix');
|
||||
test('getRotation()', function() {
|
||||
equals(function() {
|
||||
return new Matrix().rotate(45).getRotation();
|
||||
}, 45);
|
||||
|
||||
equals(function() {
|
||||
return new Matrix().rotate(90).getRotation();
|
||||
}, 90);
|
||||
|
||||
equals(function() {
|
||||
return new Matrix().rotate(180).getRotation();
|
||||
}, 180);
|
||||
|
||||
equals(function() {
|
||||
return new Matrix().rotate(270).getRotation();
|
||||
}, -90, null, Numerical.TOLERANCE);
|
||||
|
||||
equals(function() {
|
||||
return new Matrix().rotate(-45).getRotation();
|
||||
}, -45);
|
||||
|
||||
equals(function() {
|
||||
return new Matrix().rotate(-90).getRotation();
|
||||
}, -90);
|
||||
|
||||
equals(function() {
|
||||
return new Matrix().rotate(-180).getRotation();
|
||||
}, -180);
|
||||
|
||||
equals(function() {
|
||||
return new Matrix().rotate(-270).getRotation();
|
||||
}, 90, null, Numerical.TOLERANCE);
|
||||
});
|
||||
|
||||
test('getScaling()', function() {
|
||||
equals(function() {
|
||||
return new Matrix().scale(1, 1).getScaling();
|
||||
}, new Point(1, 1));
|
||||
|
||||
equals(function() {
|
||||
return new Matrix().scale(1, -1).getScaling();
|
||||
}, new Point(1, -1));
|
||||
|
||||
equals(function() {
|
||||
return new Matrix().scale(-1, 1).getScaling();
|
||||
}, new Point(-1, 1));
|
||||
|
||||
equals(function() {
|
||||
return new Matrix().scale(2, -4).getScaling();
|
||||
}, new Point(2, -4));
|
||||
|
||||
equals(function() {
|
||||
return new Matrix().scale(-4, 2).getScaling();
|
||||
}, new Point(-4, 2));
|
||||
|
||||
equals(function() {
|
||||
return new Matrix().scale(-4, -4).getScaling();
|
||||
}, new Point(-4, -4));
|
||||
});
|
||||
|
||||
test('getRotation() & getScaling()', function() {
|
||||
equals(function() {
|
||||
return new Matrix().scale(2, 4).rotate(45).getScaling();
|
||||
}, new Point(2, 4));
|
||||
|
||||
equals(function() {
|
||||
return new Matrix().scale(2, 4).rotate(45).getRotation();
|
||||
}, 45);
|
||||
|
||||
equals(function() {
|
||||
return new Matrix().scale(2, -4).rotate(45).getScaling();
|
||||
}, new Point(2, -4));
|
||||
|
||||
equals(function() {
|
||||
return new Matrix().scale(2, -4).rotate(45).getRotation();
|
||||
}, 45);
|
||||
|
||||
});
|
|
@ -13,6 +13,7 @@
|
|||
/*#*/ include('Point.js');
|
||||
/*#*/ include('Size.js');
|
||||
/*#*/ include('Rectangle.js');
|
||||
/*#*/ include('Matrix.js');
|
||||
|
||||
/*#*/ include('Color.js');
|
||||
|
||||
|
|
Loading…
Reference in a new issue