MCPcopy
hub / github.com/processing/p5.js / draw

Function draw

test/manual-test-examples/webgl/framebuffer/feedback/sketch.js:16–53  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

14}
15
16function draw() {
17 // Swap prev and next so that we can use the previous frame as a texture
18 // when drawing the current frame
19 [fboPrev, fboNext] = [fboNext, fboPrev];
20
21 // Draw to the Framebuffer
22 fboNext.draw(() => {
23 clear();
24
25 background(255);
26
27 push();
28 scale(1.003);
29 image(fboPrev, 0, 0);
30 pop();
31
32 push();
33 // Fade to white slowly. This will leave a permanent trail if you don't
34 // use floating point textures.
35 fill(255, 2);
36 rect(0, 0, width, height);
37 pop();
38
39 push();
40 // Clear the depth buffer so the cube doesn't intersect with the background
41 // plane behind it
42 drawingContext.clear(drawingContext.DEPTH_BUFFER_BIT);
43 normalMaterial();
44 translate(100*sin(frameCount * 0.014), 100*sin(frameCount * 0.02), 0);
45 rotateX(frameCount * 0.01);
46 rotateY(frameCount * 0.01);
47 box(50);
48 pop();
49 });
50
51 clear();
52 image(fboNext, 0, 0);
53}

Callers

nothing calls this directly

Calls 3

imageFunction · 0.50
drawMethod · 0.45
clearMethod · 0.45

Tested by

no test coverage detected