change to createImage()

This commit is contained in:
benfry
2011-09-06 12:13:50 +00:00
parent 9775dedaad
commit e5b871b4db

View File

@@ -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();
}