From 620f6c6cea1116636624cd77b03ed02df6219d44 Mon Sep 17 00:00:00 2001 From: aashu2006 Date: Wed, 28 Jan 2026 22:24:29 +0530 Subject: [PATCH] Add WebGL visual regression tests for transform functions --- test/unit/visual/cases/webgl.js | 58 ++++++++++++++++++ .../000.png | Bin 0 -> 680 bytes .../metadata.json | 3 + .../scale() uniformly scales shapes/000.png | Bin 0 -> 552 bytes .../metadata.json | 3 + .../000.png | Bin 0 -> 584 bytes .../metadata.json | 3 + 7 files changed, 67 insertions(+) create mode 100644 test/unit/visual/screenshots/WebGL/Transforms/rotate() rotates shapes around z-axis/000.png create mode 100644 test/unit/visual/screenshots/WebGL/Transforms/rotate() rotates shapes around z-axis/metadata.json create mode 100644 test/unit/visual/screenshots/WebGL/Transforms/scale() uniformly scales shapes/000.png create mode 100644 test/unit/visual/screenshots/WebGL/Transforms/scale() uniformly scales shapes/metadata.json create mode 100644 test/unit/visual/screenshots/WebGL/Transforms/translate() moves shapes in x and y axes/000.png create mode 100644 test/unit/visual/screenshots/WebGL/Transforms/translate() moves shapes in x and y axes/metadata.json diff --git a/test/unit/visual/cases/webgl.js b/test/unit/visual/cases/webgl.js index ad3a3998af..6febdfb698 100644 --- a/test/unit/visual/cases/webgl.js +++ b/test/unit/visual/cases/webgl.js @@ -1145,4 +1145,62 @@ visualSuite('WebGL', function() { }); }); + visualSuite('Transforms', function() { + visualTest('translate() moves shapes in x and y axes', function(p5, screenshot) { + p5.createCanvas(50, 50, p5.WEBGL); + p5.background(200); + p5.noStroke(); + + // Red circle at origin + p5.fill('red'); + p5.circle(0, 0, 10); + + // Green circle translated by (15, 0) + p5.push(); + p5.translate(15, 0); + p5.fill('green'); + p5.circle(0, 0, 10); + p5.pop(); + + // Blue circle translated by (0, 15) + p5.push(); + p5.translate(0, 15); + p5.fill('blue'); + p5.circle(0, 0, 10); + p5.pop(); + + screenshot(); + }); + + visualTest('rotate() rotates shapes around z-axis', function(p5, screenshot) { + p5.createCanvas(50, 50, p5.WEBGL); + p5.background(200); + p5.noStroke(); + p5.fill('red'); + p5.rectMode(p5.CENTER); + p5.rotate(p5.PI / 4); + p5.rect(0, 0, 30, 30); + screenshot(); + }); + + visualTest('scale() uniformly scales shapes', function(p5, screenshot) { + p5.createCanvas(50, 50, p5.WEBGL); + p5.background(200); + p5.noStroke(); + p5.fill('red'); + + // Unscaled circle + p5.circle(-12, 0, 20); + + // Scaled circle (half size) + p5.push(); + p5.translate(12, 0); + p5.scale(0.5); + p5.circle(0, 0, 20); + p5.pop(); + + screenshot(); + }); + }); + }); diff --git a/test/unit/visual/screenshots/WebGL/Transforms/rotate() rotates shapes around z-axis/000.png b/test/unit/visual/screenshots/WebGL/Transforms/rotate() rotates shapes around z-axis/000.png new file mode 100644 index 0000000000000000000000000000000000000000..80f7767b677a0b04de097773a68efcb817c6041c GIT binary patch literal 680 zcmV;Z0$2TsP)GYy0gM`#ceH4h^XT_b5QdDSCeb~bw4?jmz3w247;Z&Y z_OyBQYIX%-z^K=xcb^BZp1W`m!VG%EXLfn==h#*STNN*cY`=^SUY;u922%Z|C=Bd9qcWiVTKK3 z$#N58^odmhx#)V7ECpkY7hqw z3FseL7_b~M90qYnfRO$X#T!G*yBUN4A%gmQ7Ej(0&rlFT1PSZ!QM`CYy~05V5@w*! zEFQdiJi3AqX23|FQM7sVYIg@=z=)xKWznQPqB#_V5ktoM6-A5YsMc^0hKvE|XNm@` z8I7qRi~#`AkCa;)Be&a|=^(^_0MhrA8@D|-wcRB_hywzqkCa_EmEG>~vLKv+0n{Ir z9lJ+6y>Cl{Fb4=!zgOPu?7hv*mIna?6tI3zFlY4 zb=}_*vL*G0zs#-Ng~m{jT{AZl}^uv$xr zV=Iq(CLoW3pZVSlLef}kj!(8)aG#yAb|Pox`3#G;+Wid07CK@7;-U{Yie;f z0HH}O3=rf}V{Y99!32g_wL0CF5cs_d!X*&EAkK*Qh%@F<|4sA0m9ikcDNF-{FpW5~ zHPpwod`ciK4XV8zM4i-JalR4bNf(#*jTDc}IKek!JmBK;zLDaQ87KHgj0ap?elZ*Q q2LJ&7|5PLEm;e9(21!IgR09BNf>?6QA#|$%0000mKxA?&McM{#uYFk&=kg1j=7aX|S`8Es4w?ozljVh|*wZA6pWcJvyb0 zB@v~;&OWvzGJAAN8%rXQ!Jd>B&Kb0>YlBuzV;;NiWKHVBeK>>ax7wiQy)oVA^j?)j z09f`QXfO)|F!Y96>Ey%Y?Fr_9nr<1_gd2T7UavYb*T zbNlFvgOCUZPl;4weG-Y)!&(Yf93;H-n(yKuhpNi@Ppzq*@_SQjZUVBmHVT_E87{WZ z@x9_8nA|0dVu)TU5lkZ1#Y8U!D-MDIV76^*Lc;(cdaOwav+YZ3Lc`PsrS_?Sa2XK5 zY`ixJ07Ne*Ab|0&-k=-==c$2k_%&5Pt~u>KE z0N~uR2U#AC0RarXV^Q!$90bEaq&(8ofDs4LFqs-kSQiH&k??}pJE_F#m(;{TE-@4A z{q?IjNL3xOCeB%tJ!G`tCLq@CM>a116bHeiwY#J#UIg0000dOo literal 0 HcmV?d00001 diff --git a/test/unit/visual/screenshots/WebGL/Transforms/translate() moves shapes in x and y axes/metadata.json b/test/unit/visual/screenshots/WebGL/Transforms/translate() moves shapes in x and y axes/metadata.json new file mode 100644 index 0000000000..2d4bfe30da --- /dev/null +++ b/test/unit/visual/screenshots/WebGL/Transforms/translate() moves shapes in x and y axes/metadata.json @@ -0,0 +1,3 @@ +{ + "numScreenshots": 1 +} \ No newline at end of file