I have a project due in a few days---and I just started today.. it's not the hardest thing in the world, but I always have a hard time figuring out how to move existing code into a class successfully.
this is what I have so far, It's a modified version of Example 15-14 "Pointillism"
----------------------------------------------------------------------------------------------------------------------------------
PImage purpleBrain;
Brain bb;
float pointillize = 16;
void setup() {
size(430, 550);
purpleBrain=loadImage("purple MRI.jpg");
bb = new Brain();
smooth();
}
void draw() {
background(0);
bb.pointillize();
bb.display();
}
class Brain {
int x;
int y;
int loc;
float r;
float g;
float b;
Brain() {
//purple---------
x = int(random(purpleBrain.width));
y = int(random(purpleBrain.height));
loc= x + y*purpleBrain.width;
}
void pointillize() {
loadPixels();
float r = red(purpleBrain.pixels[loc]);
float g = green(purpleBrain.pixels[loc]);
float b = blue(purpleBrain.pixels[loc]);
}
void display () {
noStroke();
fill(r, g, b, 100);
ellipse(x, y, pointillize, pointillize);
}
}
--------------------------------------------------------------------------------------------------------------
it just shows up black when I run it.
Thanks to anyone who can help!
1