diff --git a/java/examples/Topics/Simulate/SmokeParticleSystem/SmokeParticleSystem.pde b/java/examples/Topics/Simulate/SmokeParticleSystem/SmokeParticleSystem.pde index c499d83b0..879d6b4d9 100644 --- a/java/examples/Topics/Simulate/SmokeParticleSystem/SmokeParticleSystem.pde +++ b/java/examples/Topics/Simulate/SmokeParticleSystem/SmokeParticleSystem.pde @@ -10,7 +10,6 @@ ParticleSystem ps; Random generator; void setup() { - size(640, 360); colorMode(RGB, 255, 255, 255, 100); @@ -19,10 +18,12 @@ void setup() { // Create an alpha masked image to be applied as the particle's texture PImage msk = loadImage("texture.gif"); - PImage img = new PImage(msk.width,msk.height); - for (int i = 0; i < img.pixels.length; i++) img.pixels[i] = color(255); + PImage img = createImage(msk.width, msk.height, RGB); + for (int i = 0; i < img.pixels.length; i++) { + img.pixels[i] = color(255); + } img.mask(msk); - ps = new ParticleSystem(0, new PVector(width/2,height-20 ),img); + ps = new ParticleSystem(0, new PVector(width/2, height-20), img); smooth(); } @@ -41,29 +42,19 @@ void draw() { } } - void displayVector(PVector v, float x, float y, float scayl) { - pushMatrix(); - float arrowsize = 4; - // Translate to location to render vector - translate(x,y); - stroke(255); - // Call vector heading function to get direction (note that pointing up is a heading of 0) and rotate - rotate(v.heading2D()); - // Calculate length of vector & scale it to be bigger or smaller if necessary - float len = v.mag()*scayl; - // Draw three lines to make an arrow (draw pointing up since we've rotate to the proper direction) - line(0,0,len,0); - line(len,0,len-arrowsize,+arrowsize/2); - line(len,0,len-arrowsize,-arrowsize/2); - popMatrix(); - } - - - - - - - - - - +void displayVector(PVector v, float x, float y, float scayl) { + pushMatrix(); + float arrowsize = 4; + // Translate to location to render vector + translate(x,y); + stroke(255); + // Call vector heading function to get direction (note that pointing up is a heading of 0) and rotate + rotate(v.heading2D()); + // Calculate length of vector & scale it to be bigger or smaller if necessary + float len = v.mag()*scayl; + // Draw three lines to make an arrow (draw pointing up since we've rotate to the proper direction) + line(0,0,len,0); + line(len,0,len-arrowsize,+arrowsize/2); + line(len,0,len-arrowsize,-arrowsize/2); + popMatrix(); +} \ No newline at end of file