Skip to content

Commit dc448e5

Browse files
authored
Merge pull request #8197 from processing/fix/rect-uvs
Fix generation of UVs in rounded rectangles
2 parents 70a16cb + 18d180e commit dc448e5

File tree

6 files changed

+27
-1
lines changed

6 files changed

+27
-1
lines changed

src/webgl/3d_primitives.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1967,7 +1967,7 @@ function primitives3D(p5, fn){
19671967
const prevOrder = this.bezierOrder();
19681968
this.bezierOrder(2);
19691969
this.beginShape();
1970-
const addUVs = (x, y) => [x, y, (x - x1)/width, (y - y1)/height];
1970+
const addUVs = (x, y) => [x, y, 0, (x - x1)/width, (y - y1)/height];
19711971
if (tr !== 0) {
19721972
this.vertex(...addUVs(x2 - tr, y1));
19731973
this.bezierVertex(...addUVs(x2, y1));

test/unit/visual/cases/webgl.js

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -673,4 +673,24 @@ visualSuite('WebGL', function() {
673673
screenshot();
674674
});
675675
});
676+
677+
visualSuite('texture()', () => {
678+
visualTest('on a rect', async (p5, screenshot) => {
679+
p5.createCanvas(50, 50, p5.WEBGL);
680+
const tex = await p5.loadImage('/unit/assets/cat.jpg');
681+
p5.texture(tex);
682+
p5.texture(tex);
683+
p5.rect(-20, -20, 40, 40);
684+
screenshot();
685+
});
686+
687+
visualTest('on a rect with rounded corners', async (p5, screenshot) => {
688+
p5.createCanvas(50, 50, p5.WEBGL);
689+
const tex = await p5.loadImage('/unit/assets/cat.jpg');
690+
p5.texture(tex);
691+
p5.texture(tex);
692+
p5.rect(-20, -20, 40, 40, 10);
693+
screenshot();
694+
});
695+
});
676696
});
5.13 KB
Loading
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"numScreenshots": 1
3+
}
5.17 KB
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)