Skip to content

Commit 270eb1c

Browse files
authored
Merge pull request #8465 from aashu2006/webgl-transform-visual-tests
Add WebGL visual regression tests for transform functions
2 parents bf773b7 + 620f6c6 commit 270eb1c

7 files changed

Lines changed: 67 additions & 0 deletions

File tree

test/unit/visual/cases/webgl.js

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1145,4 +1145,62 @@ visualSuite('WebGL', function() {
11451145
});
11461146
});
11471147

1148+
visualSuite('Transforms', function() {
1149+
visualTest('translate() moves shapes in x and y axes', function(p5, screenshot) {
1150+
p5.createCanvas(50, 50, p5.WEBGL);
1151+
p5.background(200);
1152+
p5.noStroke();
1153+
1154+
// Red circle at origin
1155+
p5.fill('red');
1156+
p5.circle(0, 0, 10);
1157+
1158+
// Green circle translated by (15, 0)
1159+
p5.push();
1160+
p5.translate(15, 0);
1161+
p5.fill('green');
1162+
p5.circle(0, 0, 10);
1163+
p5.pop();
1164+
1165+
// Blue circle translated by (0, 15)
1166+
p5.push();
1167+
p5.translate(0, 15);
1168+
p5.fill('blue');
1169+
p5.circle(0, 0, 10);
1170+
p5.pop();
1171+
1172+
screenshot();
1173+
});
1174+
1175+
visualTest('rotate() rotates shapes around z-axis', function(p5, screenshot) {
1176+
p5.createCanvas(50, 50, p5.WEBGL);
1177+
p5.background(200);
1178+
p5.noStroke();
1179+
p5.fill('red');
1180+
p5.rectMode(p5.CENTER);
1181+
p5.rotate(p5.PI / 4);
1182+
p5.rect(0, 0, 30, 30);
1183+
screenshot();
1184+
});
1185+
1186+
visualTest('scale() uniformly scales shapes', function(p5, screenshot) {
1187+
p5.createCanvas(50, 50, p5.WEBGL);
1188+
p5.background(200);
1189+
p5.noStroke();
1190+
p5.fill('red');
1191+
1192+
// Unscaled circle
1193+
p5.circle(-12, 0, 20);
1194+
1195+
// Scaled circle (half size)
1196+
p5.push();
1197+
p5.translate(12, 0);
1198+
p5.scale(0.5);
1199+
p5.circle(0, 0, 20);
1200+
p5.pop();
1201+
1202+
screenshot();
1203+
});
1204+
});
1205+
11481206
});
680 Bytes
Loading
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"numScreenshots": 1
3+
}
552 Bytes
Loading
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"numScreenshots": 1
3+
}
584 Bytes
Loading
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"numScreenshots": 1
3+
}

0 commit comments

Comments
 (0)