Skip to content

Commit d9083ca

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 c4a910c commit d9083ca

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
@@ -1244,32 +1244,73 @@ visualSuite('WebGL', function() {
12441244
});
12451245

12461246
visualSuite('Tessellation', function() {
1247-
visualTest('Handles nearly identical consecutive vertices from textToContours', async function(p5, screenshot) {
1248-
p5.createCanvas(200, 200, p5.WEBGL);
1249-
p5.background(255);
1250-
p5.fill(0);
1251-
p5.noStroke();
1252-
1253-
const font = await p5.loadFont('/unit/assets/Inconsolata-Bold.ttf');
1254-
const contours = font.textToContours('p', 0, 0, 60);
1255-
1256-
if (contours && contours.length > 0) {
1257-
p5.translate(-p5.width / 4, -p5.height / 4);
1258-
p5.beginShape();
1259-
for (let contourIdx = 0; contourIdx < contours.length; contourIdx++) {
1260-
const contour = contours[contourIdx];
1261-
if (contourIdx > 0) {
1262-
p5.beginContour();
1263-
}
1264-
for (let i = 0; i < contour.length; i++) {
1265-
p5.vertex(contour[i].x, contour[i].y, 0);
1266-
}
1267-
if (contourIdx > 0) {
1268-
p5.endContour();
1269-
}
1247+
visualTest('Handles nearly identical consecutive vertices', function(p5, screenshot) {
1248+
p5.createCanvas(400, 400, p5.WEBGL);
1249+
1250+
const contours = [
1251+
[
1252+
[-3.8642425537109375, -6.120738636363637, 0],
1253+
[3.2025188099254267, -6.120738636363637, 0],
1254+
[3.2025188099254267, -4.345170454545455, 0],
1255+
[-3.8642425537109375, -4.345170454545455, 0],
1256+
[-3.8642425537109375, -6.120738636363637, 0]
1257+
],
1258+
[
1259+
[-1.8045834628018462, 4.177556818181818, 0],
1260+
[-1.8045834628018462, -9.387784090909093, 0],
1261+
[0.29058699174360836, -9.387784090909093, 0],
1262+
[0.2905869917436083, 3.609374411367136, 0],
1263+
[0.31044303036623855, 4.068235883781435, 0],
1264+
[0.38522861430307975, 4.522728865422799, 0],
1265+
[0.548044378107245, 4.941051136363637, 0],
1266+
[0.8364672032828204, 5.2932224887960775, 0],
1267+
[1.2227602871981542, 5.526988636363637, 0],
1268+
[1.6572258237923885, 5.634502949876295, 0],
1269+
[2.101666537198154, 5.669034090909091, 0],
1270+
[2.6695604948237173, 5.633568761673102, 0],
1271+
[3.0249619917436084, 5.5625, 0],
1272+
[3.4510983553799726, 7.4446022727272725, 0],
1273+
[2.8568950819856695, 7.613138889205699, 0],
1274+
[2.3751340936529037, 7.676962586830456, 0],
1275+
[1.8892600236717598, 7.693181792704519, 0],
1276+
[1.2922705720786674, 7.649533731133848, 0],
1277+
[0.7080836288276859, 7.519788939617751, 0],
1278+
[0.14854153719815422, 7.311434659090909, 0],
1279+
[-0.38643934048179873, 7.00959666478984, 0],
1280+
[-0.858113258144025, 6.61653855366859, 0],
1281+
[-1.25415732643821, 6.1484375, 0],
1282+
[-1.5108595282965422, 5.697682732328092, 0],
1283+
[-1.6824918355513252, 5.207533878495854, 0],
1284+
[-1.7762971052870198, 4.695933154267308, 0],
1285+
[-1.8045834628018462, 4.177556818181818, 0]
1286+
]
1287+
];
1288+
1289+
p5.background('red');
1290+
p5.push();
1291+
p5.stroke(0);
1292+
p5.fill('#EEE');
1293+
p5.scale(15);
1294+
p5.beginShape();
1295+
for (const contour of contours) {
1296+
p5.beginContour();
1297+
for (const v of contour) {
1298+
p5.vertex(...v);
12701299
}
1271-
p5.endShape(p5.CLOSE);
1300+
p5.endContour();
12721301
}
1302+
p5.endShape();
1303+
1304+
p5.stroke(0, 255, 0);
1305+
p5.strokeWeight(5);
1306+
p5.beginShape(p5.POINTS);
1307+
for (const contour of contours) {
1308+
for (const v of contour) {
1309+
p5.vertex(...v);
1310+
}
1311+
}
1312+
p5.endShape();
1313+
p5.pop();
12731314

12741315
screenshot();
12751316
});

0 commit comments

Comments
 (0)