Skip to content

Commit 386b69c

Browse files
committed
test: use exact contour data that reproduces tessellation bug
Replace textToContours test with hardcoded contour data from #8186 This test actually shows the tessellation artifacts before the fix
1 parent 291f70f commit 386b69c

1 file changed

Lines changed: 65 additions & 24 deletions

File tree

test/unit/visual/cases/webgl.js

Lines changed: 65 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -695,32 +695,73 @@ visualSuite('WebGL', function() {
695695
});
696696

697697
visualSuite('Tessellation', function() {
698-
visualTest('Handles nearly identical consecutive vertices from textToContours', async function(p5, screenshot) {
699-
p5.createCanvas(200, 200, p5.WEBGL);
700-
p5.background(255);
701-
p5.fill(0);
702-
p5.noStroke();
703-
704-
const font = await p5.loadFont('/unit/assets/Inconsolata-Bold.ttf');
705-
const contours = font.textToContours('p', 0, 0, 60);
706-
707-
if (contours && contours.length > 0) {
708-
p5.translate(-p5.width / 4, -p5.height / 4);
709-
p5.beginShape();
710-
for (let contourIdx = 0; contourIdx < contours.length; contourIdx++) {
711-
const contour = contours[contourIdx];
712-
if (contourIdx > 0) {
713-
p5.beginContour();
714-
}
715-
for (let i = 0; i < contour.length; i++) {
716-
p5.vertex(contour[i].x, contour[i].y, 0);
717-
}
718-
if (contourIdx > 0) {
719-
p5.endContour();
720-
}
698+
visualTest('Handles nearly identical consecutive vertices', function(p5, screenshot) {
699+
p5.createCanvas(400, 400, p5.WEBGL);
700+
701+
const contours = [
702+
[
703+
[-3.8642425537109375, -6.120738636363637, 0],
704+
[3.2025188099254267, -6.120738636363637, 0],
705+
[3.2025188099254267, -4.345170454545455, 0],
706+
[-3.8642425537109375, -4.345170454545455, 0],
707+
[-3.8642425537109375, -6.120738636363637, 0]
708+
],
709+
[
710+
[-1.8045834628018462, 4.177556818181818, 0],
711+
[-1.8045834628018462, -9.387784090909093, 0],
712+
[0.29058699174360836, -9.387784090909093, 0],
713+
[0.2905869917436083, 3.609374411367136, 0],
714+
[0.31044303036623855, 4.068235883781435, 0],
715+
[0.38522861430307975, 4.522728865422799, 0],
716+
[0.548044378107245, 4.941051136363637, 0],
717+
[0.8364672032828204, 5.2932224887960775, 0],
718+
[1.2227602871981542, 5.526988636363637, 0],
719+
[1.6572258237923885, 5.634502949876295, 0],
720+
[2.101666537198154, 5.669034090909091, 0],
721+
[2.6695604948237173, 5.633568761673102, 0],
722+
[3.0249619917436084, 5.5625, 0],
723+
[3.4510983553799726, 7.4446022727272725, 0],
724+
[2.8568950819856695, 7.613138889205699, 0],
725+
[2.3751340936529037, 7.676962586830456, 0],
726+
[1.8892600236717598, 7.693181792704519, 0],
727+
[1.2922705720786674, 7.649533731133848, 0],
728+
[0.7080836288276859, 7.519788939617751, 0],
729+
[0.14854153719815422, 7.311434659090909, 0],
730+
[-0.38643934048179873, 7.00959666478984, 0],
731+
[-0.858113258144025, 6.61653855366859, 0],
732+
[-1.25415732643821, 6.1484375, 0],
733+
[-1.5108595282965422, 5.697682732328092, 0],
734+
[-1.6824918355513252, 5.207533878495854, 0],
735+
[-1.7762971052870198, 4.695933154267308, 0],
736+
[-1.8045834628018462, 4.177556818181818, 0]
737+
]
738+
];
739+
740+
p5.background('red');
741+
p5.push();
742+
p5.stroke(0);
743+
p5.fill('#EEE');
744+
p5.scale(15);
745+
p5.beginShape();
746+
for (const contour of contours) {
747+
p5.beginContour();
748+
for (const v of contour) {
749+
p5.vertex(...v);
750+
}
751+
p5.endContour();
752+
}
753+
p5.endShape();
754+
755+
p5.stroke(0, 255, 0);
756+
p5.strokeWeight(5);
757+
p5.beginShape(p5.POINTS);
758+
for (const contour of contours) {
759+
for (const v of contour) {
760+
p5.vertex(...v);
721761
}
722-
p5.endShape(p5.CLOSE);
723762
}
763+
p5.endShape();
764+
p5.pop();
724765

725766
screenshot();
726767
});

0 commit comments

Comments
 (0)