xxxxxxxxxx
/*
Jaza Samuel -
For this conceptual piece I want to have a combination of triangles that are varying in shapes and stork thickness.
There will be a grey background.
The triangles should have a black stroke with varying thicknesses.
The piece should be modular in the sense that all the shapes should be joined and should be moving at the same time.
The modular triangles should be moving in a circular motion (almost like a kaleidoscope effect).
The triangles should be in 2 sizes, one small and one big and should be joined from any vertex (creating a fan shape).
Then this shape should form a 45-degree angle and then that should be mirrored on the other side (almost like 2 flaps).
These modular shapes should be zooming in and out while moving in a circular motion.
*/
Triangle sTriangle;
Triangle lTriangle;
float angle = PI/4; //45 degrees
float scale = 1;
float min = 0.7; //minimum size when shrinking
float max = 1.5; //maximum size when expanding
float dir = 1; //positive or negative growth
void setup() {
size(500,500);
smooth();
sTriangle = new Triangle(int(random(5)), int(random(255)), 100); //strokeweight, fill, hypotenuse
lTriangle = new Triangle(int(random(5)), int(random(255)), 120);
}
void draw() {
background(150);
translate(width/2, height/2);
rotate(angle);
scale(scale);
sTriangle.display();
rotate(radians(22.5));
lTriangle.display();
angle = angle+.01;
if(dir > 0 && scale >= max) { //if scale reaches max, start to shrink
dir = -1;
}
if (dir < 0 && scale <= min) { //if scale reaches minimum, start to grow
dir = 1;
}
scale += .01* dir; //growing and shrinking speed
}
class Triangle {
float r; //hypotenuse
float sw;
float f;
Triangle(float tempSw, float tempF, float tempR) {
sw = tempSw;
f = tempF;
r = tempR;
}
void display() {
stroke(0);
strokeWeight(sw);
fill(f);
for (int i = 0; i < 8; i++) {
triangle(0, 0, r, 0, r/cos(radians(22.5))*cos(radians(22.5)), r/cos(radians(22.5))*sin(radians(22.5)));
/* soh cah toa --> cos(angle) = o/h, o/cos(angle) = h */
rotate(radians(45)); //rotate it so there are 8 triangles equally spaced
}
}
}