Hi guys I have this situation: I created an exercise where inside of it I created a class object called A_square, but my goal would be has in a square 666x666, four different classes (A_B_C_D) which different graphic output.
My question: How Could I create a square 666x666 with inside of it four different smaller square (333x333) with different dynamic settings? Maybe with some PGraphics settings?
Sorry for my English, it is not my first Language.
//This below is the first situation:
A_square a1;
void setup () {
size (333, 333);
frameRate(12);
background (0);
a1 = new A_square();
}
void draw() {
background (0);
a1.graphic();
}
// ========================================================
class A_square {
int x;
int y;
float r=0;
boolean rotationMode = true;
A_square () {
// empty constructor
}
void graphic() {
if (rotationMode) {
translate (width/2, height/2);
rotate (radians(r));
r = r + 1;
}
for (int y=-width; y<width; y=y+20) {
for ( int x=-height; x<height; x=x+20) {
fill(random(0, 255), random(0, 255), random(0, 255));
ellipse (x, y, random(5, 15), random(5, 15));
}
}
}
}
Could be, actually I don’t fully understand the second part of your message. However the concept is based on the idea to have different square (dynamic) inside of a bigger one.
The other three (B-C-D) I’m going to create, but before I would like to achive the 333x333 A_square inside of the 666x666 one, maybe A in the upper right of it.
Do you suggest to use map funcition for adjust the A_square output? Or inside the for loops?
The concept is simple but technically I’m stuck because the first A_square is based on the width and height of a square which is misured 333x333.
Thank you so much!!! I have a question about the first case: Why the code is still? I mean the rotation, I would like to achive the rotation of the loops