Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 <!DOCTYPE html> | |
| 2 <html> | |
| 3 <head> | |
| 4 <title>Geometry Interfaces: DOMMatrix translate</title> | |
| 5 <script src="../../resources/js-test.js"></script> | |
|
krit
2014/08/08 06:24:15
As mentioned in another CL, it would be great if w
zino
2014/08/16 03:23:32
Done.
| |
| 6 </head> | |
| 7 <body> | |
| 8 <script> | |
| 9 | |
| 10 function compareMatrix(matrixObject, matrixValue) | |
| 11 { | |
| 12 return matrixObject.m11 == matrixValue[0] && | |
| 13 matrixObject.m21 == matrixValue[1] && | |
| 14 matrixObject.m31 == matrixValue[2] && | |
| 15 matrixObject.m41 == matrixValue[3] && | |
| 16 matrixObject.m12 == matrixValue[4] && | |
| 17 matrixObject.m22 == matrixValue[5] && | |
| 18 matrixObject.m32 == matrixValue[6] && | |
| 19 matrixObject.m42 == matrixValue[7] && | |
| 20 matrixObject.m13 == matrixValue[8] && | |
| 21 matrixObject.m23 == matrixValue[9] && | |
| 22 matrixObject.m33 == matrixValue[10] && | |
| 23 matrixObject.m43 == matrixValue[11] && | |
| 24 matrixObject.m14 == matrixValue[12] && | |
| 25 matrixObject.m24 == matrixValue[13] && | |
| 26 matrixObject.m34 == matrixValue[14] && | |
| 27 matrixObject.m44 == matrixValue[15]; | |
| 28 } | |
| 29 | |
| 30 debug("# DOMMatrix.translate(tx, ty)"); | |
| 31 var matrix = new DOMMatrix(); | |
| 32 shouldBeTrue("matrix.is2D"); | |
| 33 shouldBeTrue("matrix.isIdentity"); | |
| 34 shouldBeTrue("compareMatrix(matrix, [ 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1 ])"); | |
| 35 var result = matrix.translate(2, 3); | |
| 36 shouldBeTrue("result.is2D"); | |
| 37 shouldBeFalse("result.isIdentity"); | |
| 38 shouldBeTrue("compareMatrix(result, [ 1, 0, 0, 2, 0, 1, 0, 3, 0, 0, 1, 0, 0, 0, 0, 1 ])"); | |
| 39 shouldBeTrue("matrix.is2D"); | |
| 40 shouldBeTrue("matrix.isIdentity"); | |
| 41 shouldBeTrue("compareMatrix(matrix, [ 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1 ])"); | |
| 42 debug(""); | |
| 43 | |
| 44 debug("# DOMMatrix.translate(tx, ty) with non-identity"); | |
| 45 matrix = new DOMMatrix(result); | |
| 46 shouldBeTrue("matrix.is2D"); | |
| 47 shouldBeFalse("matrix.isIdentity"); | |
| 48 shouldBeTrue("compareMatrix(matrix, [ 1, 0, 0, 2, 0, 1, 0, 3, 0, 0, 1, 0, 0, 0, 0, 1 ])"); | |
| 49 result = matrix.translate(4, 2); | |
| 50 shouldBeTrue("result.is2D"); | |
| 51 shouldBeFalse("result.isIdentity"); | |
| 52 shouldBeTrue("compareMatrix(result, [ 1, 0, 0, 6, 0, 1, 0, 5, 0, 0, 1, 0, 0, 0, 0, 1 ])"); | |
| 53 shouldBeTrue("matrix.is2D"); | |
| 54 shouldBeFalse("matrix.isIdentity"); | |
| 55 shouldBeTrue("compareMatrix(matrix, [ 1, 0, 0, 2, 0, 1, 0, 3, 0, 0, 1, 0, 0, 0, 0, 1 ])"); | |
| 56 debug(""); | |
| 57 | |
| 58 debug("# DOMMatrix.translateSelf(tx, ty)"); | |
| 59 matrix = new DOMMatrix(); | |
| 60 shouldBeTrue("matrix.is2D"); | |
| 61 shouldBeTrue("matrix.isIdentity"); | |
| 62 shouldBeTrue("compareMatrix(matrix, [ 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1 ])"); | |
| 63 result = matrix.translateSelf(4, 2); | |
| 64 shouldBeTrue("result.is2D"); | |
| 65 shouldBeFalse("result.isIdentity"); | |
| 66 shouldBeTrue("compareMatrix(result, [ 1, 0, 0, 4, 0, 1, 0, 2, 0, 0, 1, 0, 0, 0, 0, 1 ])"); | |
| 67 shouldBeTrue("matrix.is2D"); | |
| 68 shouldBeFalse("matrix.isIdentity"); | |
| 69 shouldBeTrue("compareMatrix(matrix, [ 1, 0, 0, 4, 0, 1, 0, 2, 0, 0, 1, 0, 0, 0, 0, 1 ])"); | |
| 70 debug(""); | |
| 71 | |
| 72 debug("# DOMMatrix.translate(tx, ty, tz)"); | |
| 73 matrix = new DOMMatrix(); | |
| 74 shouldBeTrue("matrix.is2D"); | |
| 75 shouldBeTrue("matrix.isIdentity"); | |
| 76 shouldBeTrue("compareMatrix(matrix, [ 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1 ])"); | |
| 77 result = matrix.translate(2, 3, 4); | |
| 78 shouldBeFalse("result.is2D"); | |
| 79 shouldBeFalse("result.isIdentity"); | |
| 80 shouldBeTrue("compareMatrix(result, [ 1, 0, 0, 2, 0, 1, 0, 3, 0, 0, 1, 4, 0, 0, 0, 1 ])"); | |
| 81 shouldBeTrue("matrix.is2D"); | |
| 82 shouldBeTrue("matrix.isIdentity"); | |
| 83 shouldBeTrue("compareMatrix(matrix, [ 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1 ])"); | |
| 84 debug(""); | |
| 85 | |
| 86 debug("# DOMMatrix.translate(tx, ty, tz) with non-identity"); | |
| 87 var matrix2d = new DOMMatrix(); | |
| 88 matrix2d.translateSelf(2, 3); | |
| 89 matrix = new DOMMatrix(matrix2d); | |
| 90 shouldBeTrue("matrix.is2D"); | |
| 91 shouldBeFalse("matrix.isIdentity"); | |
| 92 shouldBeTrue("compareMatrix(matrix, [ 1, 0, 0, 2, 0, 1, 0, 3, 0, 0, 1, 0, 0, 0, 0, 1 ])"); | |
| 93 result = matrix.translate(4, 2, 3); | |
| 94 shouldBeFalse("result.is2D"); | |
| 95 shouldBeFalse("result.isIdentity"); | |
| 96 shouldBeTrue("compareMatrix(result, [ 1, 0, 0, 6, 0, 1, 0, 5, 0, 0, 1, 3, 0 , 0, 0, 1 ])"); | |
| 97 shouldBeTrue("matrix.is2D"); | |
| 98 shouldBeFalse("matrix.isIdentity"); | |
| 99 shouldBeTrue("compareMatrix(matrix, [ 1, 0, 0, 2, 0, 1, 0, 3, 0, 0, 1, 0, 0, 0, 0, 1 ])"); | |
| 100 debug(""); | |
| 101 | |
| 102 debug("# DOMMatrix.translateSelf(tx, ty, tz)"); | |
| 103 matrix = new DOMMatrix(); | |
| 104 shouldBeTrue("matrix.is2D"); | |
| 105 shouldBeTrue("matrix.isIdentity"); | |
| 106 shouldBeTrue("compareMatrix(matrix, [ 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1 ])"); | |
| 107 result = matrix.translateSelf(4, 2, 3); | |
| 108 shouldBeFalse("result.is2D"); | |
| 109 shouldBeFalse("result.isIdentity"); | |
| 110 shouldBeTrue("compareMatrix(result, [ 1, 0, 0, 4, 0, 1, 0, 2, 0, 0, 1, 3, 0, 0, 0, 1 ])"); | |
| 111 shouldBeFalse("matrix.is2D"); | |
| 112 shouldBeFalse("matrix.isIdentity"); | |
| 113 shouldBeTrue("compareMatrix(matrix, [ 1, 0, 0, 4, 0, 1, 0, 2, 0, 0, 1, 3, 0, 0, 0, 1 ])"); | |
| 114 debug(""); | |
| 115 | |
| 116 debug("# DOMMatrix.translateSelf(tx, ty, tz) Homogeneous Coordinates"); | |
| 117 matrix = new DOMMatrix(); | |
| 118 shouldBeTrue("matrix.is2D"); | |
| 119 shouldBeTrue("matrix.isIdentity"); | |
| 120 matrix.m14 = 2; | |
| 121 matrix.m24 = 3; | |
| 122 matrix.m34 = 4; | |
| 123 matrix.m44 = 7; | |
| 124 shouldBeFalse("matrix.is2D"); | |
| 125 shouldBeFalse("matrix.isIdentity"); | |
| 126 shouldBeTrue("compareMatrix(matrix, [ 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 2, 3, 4, 7 ])"); | |
| 127 matrix.translateSelf(7, -8, 2); | |
| 128 shouldBeFalse("matrix.is2D"); | |
| 129 shouldBeFalse("matrix.isIdentity"); | |
| 130 shouldBeTrue("compareMatrix(matrix, [ 1, 0, 0, 7, 0, 1, 0, -8, 0, 0, 1, 2, 2, 3, 4, 5 ])"); | |
| 131 debug(""); | |
| 132 | |
| 133 </script> | |
| 134 </body> | |
| 135 </html> | |
| OLD | NEW |