From f5d7036a7eba6a5010ea9b46fa241dbfe2ad9035 Mon Sep 17 00:00:00 2001 From: Binit Shah Date: Tue, 6 Aug 2024 00:12:11 -0400 Subject: [PATCH] Fix Particles demos As per https://github.com/processing/processing-docs/issues/298#issuecomment-140218268, `size()` must be called within `settings` when using variables. This change was required to get the demo to run. --- .../Demos/Graphics/Particles/Particles.pde | 61 ++++++++++--------- 1 file changed, 32 insertions(+), 29 deletions(-) diff --git a/processing/mode/examples/Demos/Graphics/Particles/Particles.pde b/processing/mode/examples/Demos/Graphics/Particles/Particles.pde index 4d9cd03e6..8de4532b6 100644 --- a/processing/mode/examples/Demos/Graphics/Particles/Particles.pde +++ b/processing/mode/examples/Demos/Graphics/Particles/Particles.pde @@ -1,30 +1,33 @@ -// Particles, by Daniel Shiffman - -ParticleSystem ps; -PImage sprite; - -void setup() { - size(displayWidth, displayHeight, P2D); - orientation(LANDSCAPE); - sprite = loadImage("sprite.png"); - ps = new ParticleSystem(2000); - - // Writing to the depth buffer is disabled to avoid rendering - // artifacts due to the fact that the particles are semi-transparent - // but not z-sorted. - hint(DISABLE_DEPTH_MASK); -} - -void draw () { - background(0); - ps.update(); - ps.display(); - - ps.setEmitter(mouseX,mouseY); - - fill(255); - textSize(16); - text("Frame rate: " + int(frameRate),10,20); -} - +// Particles, by Daniel Shiffman + +ParticleSystem ps; +PImage sprite; + +void settings() { + size(displayWidth, displayHeight, P2D); +} + +void setup() { + orientation(LANDSCAPE); + sprite = loadImage("sprite.png"); + ps = new ParticleSystem(2000); + + // Writing to the depth buffer is disabled to avoid rendering + // artifacts due to the fact that the particles are semi-transparent + // but not z-sorted. + hint(DISABLE_DEPTH_MASK); +} + +void draw () { + background(0); + ps.update(); + ps.display(); + + ps.setEmitter(mouseX,mouseY); + + fill(255); + textSize(16); + text("Frame rate: " + int(frameRate),10,20); +} +