Problem with classes
in
Programming Questions
•
1 year ago
I don't think I made it clear what I was trying to do in my previous code. I want to make a class which consists of the ellipse which is controlled by noise as in the code posted below. I also want it to include the if statements for dist so I can have any number of ellipses and for it to work just like the code does below. Any help would be greatly appreciated. I have tried to put it into a class but it either stays static on the screen or I keep getting error messages.
import processing.opengl.*;
float diam = 100;
float a = 0;
void setup() {
size(1200,700);
background(0);
noFill();
}
void draw() {
background(0);
float x = noise(a,10) * width;
float y = noise(a,20) * height;
float d = dist(x,y,mouseX,mouseY);
if(d > diam) {
strokeWeight(1);
} else {
strokeWeight(random(7));
}
if(d > 100) {
noFill();
stroke(0,190,100);
ellipse(x,y,100-d,100-d);
noFill();
noStroke();
}
stroke(150,255,50);
ellipse(x,y,diam,diam);
stroke(200,100,255);
ellipse(mouseX,mouseY,diam,diam);
a = a + 0.01;
}
import processing.opengl.*;
float diam = 100;
float a = 0;
void setup() {
size(1200,700);
background(0);
noFill();
}
void draw() {
background(0);
float x = noise(a,10) * width;
float y = noise(a,20) * height;
float d = dist(x,y,mouseX,mouseY);
if(d > diam) {
strokeWeight(1);
} else {
strokeWeight(random(7));
}
if(d > 100) {
noFill();
stroke(0,190,100);
ellipse(x,y,100-d,100-d);
noFill();
noStroke();
}
stroke(150,255,50);
ellipse(x,y,diam,diam);
stroke(200,100,255);
ellipse(mouseX,mouseY,diam,diam);
a = a + 0.01;
}
1