Skip to content

Commit 053d350

Browse files
committed
Add flat filter API test
1 parent afbcf85 commit 053d350

File tree

3 files changed

+23
-0
lines changed

3 files changed

+23
-0
lines changed

test/unit/visual/cases/webgpu.js

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -252,6 +252,26 @@ visualSuite("WebGPU", function () {
252252

253253
await screenshot();
254254
});
255+
256+
visualTest('filter shaders with flat API', async function(p5, screenshot) {
257+
await p5.createCanvas(50, 50, p5.WEBGPU);
258+
p5.background(255);
259+
p5.noStroke();
260+
p5.fill(0);
261+
p5.circle(0, 0, 20);
262+
const invert = p5.buildFilterShader(({ p5 }) => {
263+
p5.filterColor.begin();
264+
const regular = p5.getTexture(
265+
p5.filterColor.canvasContent,
266+
p5.filterColor.texCoord
267+
);
268+
const inverted = [1 - regular.rgb, regular.a];
269+
p5.filterColor.set(inverted);
270+
p5.filterColor.end();
271+
}, { p5 });
272+
p5.filter(invert);
273+
await screenshot();
274+
});
255275
});
256276

257277
visualSuite('filters', function() {
356 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)