|
| 1 | +/* |
| 2 | + * Paper.js - The Swiss Army Knife of Vector Graphics Scripting. |
| 3 | + * http://paperjs.org/ |
| 4 | + * |
| 5 | + * Copyright (c) 2011 - 2013, Juerg Lehni & Jonathan Puckey |
| 6 | + * http://lehni.org/ & http://jonathanpuckey.com/ |
| 7 | + * |
| 8 | + * Distributed under the MIT license. See LICENSE file for details. |
| 9 | + * |
| 10 | + * All rights reserved. |
| 11 | + */ |
| 12 | + |
| 13 | +module('Matrix'); |
| 14 | +test('getRotation()', function() { |
| 15 | + equals(function() { |
| 16 | + return new Matrix().rotate(45).getRotation(); |
| 17 | + }, 45); |
| 18 | + |
| 19 | + equals(function() { |
| 20 | + return new Matrix().rotate(90).getRotation(); |
| 21 | + }, 90); |
| 22 | + |
| 23 | + equals(function() { |
| 24 | + return new Matrix().rotate(180).getRotation(); |
| 25 | + }, 180); |
| 26 | + |
| 27 | + equals(function() { |
| 28 | + return new Matrix().rotate(270).getRotation(); |
| 29 | + }, -90, null, Numerical.TOLERANCE); |
| 30 | + |
| 31 | + equals(function() { |
| 32 | + return new Matrix().rotate(-45).getRotation(); |
| 33 | + }, -45); |
| 34 | + |
| 35 | + equals(function() { |
| 36 | + return new Matrix().rotate(-90).getRotation(); |
| 37 | + }, -90); |
| 38 | + |
| 39 | + equals(function() { |
| 40 | + return new Matrix().rotate(-180).getRotation(); |
| 41 | + }, -180); |
| 42 | + |
| 43 | + equals(function() { |
| 44 | + return new Matrix().rotate(-270).getRotation(); |
| 45 | + }, 90, null, Numerical.TOLERANCE); |
| 46 | +}); |
| 47 | + |
| 48 | +test('getScaling()', function() { |
| 49 | + equals(function() { |
| 50 | + return new Matrix().scale(1, 1).getScaling(); |
| 51 | + }, new Point(1, 1)); |
| 52 | + |
| 53 | + equals(function() { |
| 54 | + return new Matrix().scale(1, -1).getScaling(); |
| 55 | + }, new Point(1, -1)); |
| 56 | + |
| 57 | + equals(function() { |
| 58 | + return new Matrix().scale(-1, 1).getScaling(); |
| 59 | + }, new Point(-1, 1)); |
| 60 | + |
| 61 | + equals(function() { |
| 62 | + return new Matrix().scale(2, -4).getScaling(); |
| 63 | + }, new Point(2, -4)); |
| 64 | + |
| 65 | + equals(function() { |
| 66 | + return new Matrix().scale(-4, 2).getScaling(); |
| 67 | + }, new Point(-4, 2)); |
| 68 | + |
| 69 | + equals(function() { |
| 70 | + return new Matrix().scale(-4, -4).getScaling(); |
| 71 | + }, new Point(-4, -4)); |
| 72 | +}); |
| 73 | + |
| 74 | +test('getRotation() & getScaling()', function() { |
| 75 | + equals(function() { |
| 76 | + return new Matrix().scale(2, 4).rotate(45).getScaling(); |
| 77 | + }, new Point(2, 4)); |
| 78 | + |
| 79 | + equals(function() { |
| 80 | + return new Matrix().scale(2, 4).rotate(45).getRotation(); |
| 81 | + }, 45); |
| 82 | + |
| 83 | + equals(function() { |
| 84 | + return new Matrix().scale(2, -4).rotate(45).getScaling(); |
| 85 | + }, new Point(2, -4)); |
| 86 | + |
| 87 | + equals(function() { |
| 88 | + return new Matrix().scale(2, -4).rotate(45).getRotation(); |
| 89 | + }, 45); |
| 90 | + |
| 91 | +}); |
0 commit comments