I was wondering how i could change the following code so that the circles forming the petals are stored in an array. so i could use it in another function.
void setup() {
size(400, 400);
smooth();
noStroke();
// frameRate(15);
}
void draw() {
String[] circles = new String[5];
int c1 = 0;
int c2 = -40;
int c3 = 50;
int c4 = 50;
// set centre point
translate(width/2, height/2);
fill(#c6ff89); // green
for (int i = 0; i < circles.length; i++) {
ellipse(c1, c2, c3, c4);
rotate(radians(72));
}
// centre circle
fill(#fff9bb); // light yellow
ellipse(0, 0, 50, 50);
}
Could anyone also explain to me how to change this to a more object oriented form? This is in Processing.
Assuming your
ellipseis returningEclipseObject and you want to create5 circles, create an arrays as class variable asprivate Eclipse[] myCircles = new Eclipse[5]; and then change yourforloop as below:Please Note: Change the Object class name and array size as per your program.