From a9051291b1bbf5207417a0aeef9efd740e2047b1 Mon Sep 17 00:00:00 2001 From: kcz Date: Thu, 5 Dec 2024 20:25:47 -0500 Subject: [PATCH] test: Add test for flash.geom.transform matrix ops --- tests/tests/swfs/avm2/geom_transform/Test.as | 129 ++++++++++++++++++ .../avm2/geom_transform/output.expected.png | Bin 0 -> 7177 bytes .../tests/swfs/avm2/geom_transform/output.txt | 21 +++ tests/tests/swfs/avm2/geom_transform/test.swf | Bin 0 -> 1832 bytes .../tests/swfs/avm2/geom_transform/test.toml | 7 + 5 files changed, 157 insertions(+) create mode 100644 tests/tests/swfs/avm2/geom_transform/Test.as create mode 100644 tests/tests/swfs/avm2/geom_transform/output.expected.png create mode 100644 tests/tests/swfs/avm2/geom_transform/output.txt create mode 100644 tests/tests/swfs/avm2/geom_transform/test.swf create mode 100644 tests/tests/swfs/avm2/geom_transform/test.toml diff --git a/tests/tests/swfs/avm2/geom_transform/Test.as b/tests/tests/swfs/avm2/geom_transform/Test.as new file mode 100644 index 000000000000..a2a52baa21a0 --- /dev/null +++ b/tests/tests/swfs/avm2/geom_transform/Test.as @@ -0,0 +1,129 @@ +package { + import flash.display.*; + import flash.text.*; + import flash.geom.*; + + [SWF(width="500", height="500")] + public class Test extends MovieClip { + public function Test() { + super(); + + test2D(); + trace(""); + + test3D(); + trace(""); + + testImageComparison(); + } + + private function test2D() : void { + var sprite2D : Sprite = new Sprite(); + var mat2D : Matrix = new Matrix(); + mat2D.identity(); + + trace("// sprite2D: new Sprite has null matrix3D and valid matrix"); + trace("sprite2D.transform.matrix", sprite2D.transform.matrix); + trace("sprite2D.transform.matrix3D", sprite2D.transform.matrix3D); + + trace("// sprite2D: set identity matrix"); + sprite2D.transform.matrix = mat2D; + trace("sprite2D.transform.matrix", sprite2D.transform.matrix); + trace("sprite2D.transform.matrix3D", sprite2D.transform.matrix3D); + trace("mat2D", mat2D); + + trace("// sprite2D: set x = 30, y = 50"); + sprite2D.x = 30; + sprite2D.y = 50; + trace("sprite2D.transform.matrix", sprite2D.transform.matrix); + trace("sprite2D.transform.matrix3D", sprite2D.transform.matrix3D); + trace("mat2D", mat2D); + } + + private function test3D() : void { + var sprite3D : Sprite = new Sprite(); + var mat3D : Matrix3D = new Matrix3D(); + mat3D.identity(); + + trace("// sprite3D: set identity matrix3D"); + sprite3D.transform.matrix3D = mat3D; + trace("sprite3D.transform.matrix", sprite3D.transform.matrix); + trace("sprite3D.transform.matrix3D", sprite3D.transform.matrix3D); + trace("sprite3D.transform.matrix3D.rawData", sprite3D.transform.matrix3D.rawData); + trace("mat3D.rawData", mat3D.rawData); + + trace("// sprite3D: set x = 30, y = 50"); + sprite3D.x = 30; + sprite3D.y = 50; + trace("sprite3D.transform.matrix", sprite3D.transform.matrix); + trace("sprite3D.transform.matrix3D", sprite3D.transform.matrix3D); + trace("sprite3D.transform.matrix3D.rawData", sprite3D.transform.matrix3D.rawData); + trace("mat3D.rawData", mat3D.rawData); + } + + private function testImageComparison() : void { + var m : Matrix3D = new Matrix3D(); + + // id + var s1 : Sprite = new Sprite(); + s1.x = 10; + s1.y = 10; + var bd1 : BitmapData = new BitmapData(50, 50, false, 0xFF0000); + var b1 : Bitmap = new Bitmap(bd1); + m.identity(); + b1.transform.matrix3D = m.clone(); + s1.addChild(b1); + addChild(s1); + + // scale + var s2 : Sprite = new Sprite(); + s2.x = 160; + s2.y = 10; + var bd2 : BitmapData = new BitmapData(50, 50, false, 0x00FF00); + var b2 : Bitmap = new Bitmap(bd2); + m.identity(); + m.appendScale(1.5, 3, 1); + b2.transform.matrix3D = m.clone(); + s2.addChild(b2); + addChild(s2); + + // rotation + var s3 : Sprite = new Sprite(); + s3.x = 310; + s3.y = 10; + var bd3 : BitmapData = new BitmapData(50, 50, false, 0x00FFFF); + var b3 : Bitmap = new Bitmap(bd3); + m.identity(); + m.appendRotation(30, Vector3D.Z_AXIS); + b3.transform.matrix3D = m.clone(); + s3.addChild(b3); + addChild(s3); + + // translation + var s4 : Sprite = new Sprite(); + s4.x = 10; + s4.y = 160; + var bd4 : BitmapData = new BitmapData(50, 50, false, 0x0000FF); + var b4 : Bitmap = new Bitmap(bd4); + m.identity(); + m.appendTranslation(50, 50, 0); + b4.transform.matrix3D = m.clone(); + s4.addChild(b4); + addChild(s4); + + // scale + rotation + translation + var s5 : Sprite = new Sprite(); + s5.x = 160; + s5.y = 160; + var bd5 : BitmapData = new BitmapData(50, 50, false, 0xFF00FF); + var b5 : Bitmap = new Bitmap(bd5); + m.identity(); + m.appendScale(2, 3, 1); + m.appendRotation(30, Vector3D.Z_AXIS); + m.appendTranslation(50, 50, 0); + b5.transform.matrix3D = m.clone(); + s5.addChild(b5); + addChild(s5); + } + } +} diff --git a/tests/tests/swfs/avm2/geom_transform/output.expected.png b/tests/tests/swfs/avm2/geom_transform/output.expected.png new file mode 100644 index 0000000000000000000000000000000000000000..06a24583337195bab0eaedf91dc8b728b3c905dd GIT binary patch literal 7177 zcmeHMe{7U@883AFu)s=TrCZrJ3M-A2d4*2QVA~5FP@t@xY?q6y^w`QQN@mAu`O(Q< zS8Ql$kxT_aBe$_c$X(JiS(HN8ynyEh13dZTBwEdB$!IKL7t|9x?tLGhUvJGq!XG;Q zV`&1H_Pyu(JfG+DJm2U0`M&LVrn+)cPGL?~R@S6dE0?X!${O`|`agawJ~{u}#Gb6I z>AzXEZ0U2`M_oUa{no=@Iq?1s*!J<>vlouOT2>PjRRk8N@?Z(QF z#5&xaPJH)6c7h)%>!JPZgg(s0bN?M+>n8%dckE%O=4U5{%zKNvTQ1$-6z^Q|Z43l{ z32l33bx-ymMBnBcf8sb$wk7TZ?=y@hZB#sN4&*f9lLo<;HkM@0NAs_S!cOdMMwx=H zo->#SJa7+#fb$*Zbn?-lKFl?>FA&Ht3P|YefcwQ~X`bYtnm2&{{71x}^@CfnqV6)v zajfJBZBg^dEp3GRhEkTQ=qSB_^z2*y3Q?7^x^5+lD9SvgqVKGrtW=a%`>o(o0dkK5 zscMHEV)VQVBsm9tSos=uOccH)NI!DJdRDU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file mode 100644 index 000000000000..8bea6327f073 --- /dev/null +++ b/tests/tests/swfs/avm2/geom_transform/test.toml @@ -0,0 +1,7 @@ +num_frames = 1 + +[image_comparisons.output] +tolerance = 0 + +[player_options] +with_renderer = { optional = true, sample_count = 1 }