xxxxxxxxxx
67
function setup() {
createCanvas(6000, 3000);
background(0); // Set background to black
t = 0; // Initialize a variable t to 0
t1 = 0;
t2 = 0;
}
function draw() {
translate(width / 2, height / 2); // Translate the origin to the center of the canvas
noFill(); // Do not fill shapes with color
if (radians(t) < 6.42)
{ // Check if the rotation is less than 6.2 radians
push(); // Save the current transformation state
rotate(radians(t)); // Rotate the coordinate system by t degrees
translate(300, 0); // Move the drawing position 200 pixels to the right
rotate(radians(5 / 3 * t)); // Rotate the coordinate system by 5/3 times t degrees
strokeWeight(1);
stroke(255); // Set stroke 30lor to white
tri(300); // Call the tri() function to draw a triangle with a side length of 150
pop(); // Restore the previous transformation state
t = t + 2; // Increment the variable t
}
if (radians(t1) < 6.42)
{ // Check if the rotation is less than 6.2 radians
push(); // Save the current transformation state
rotate(radians(t)); // Rotate the coordinate system by t degrees
translate(700, 0); // Move the drawing position 200 pixels to the right
rotate(radians(5 / 3 * t1)); // Rotate the coordinate system by 5/3 times t degrees
strokeWeight(1);
stroke(255); // Set stroke 30lor to white
tri(300); // Call the tri() function to draw a triangle with a side length of 150
pop(); // Restore the previous transformation state
t1 = t1 + 2; // Increment the variable t
}
if (radians(t2) < 6.42)
{ // Check if the rotation is less than 6.2 radians
push(); // Save the current transformation state
rotate(radians(t)); // Rotate the coordinate system by t degrees
translate(1200, 0); // Move the drawing position 200 pixels to the right
rotate(radians(5 / 3 * t1)); // Rotate the coordinate system by 5/3 times t degrees
strokeWeight(1);
stroke(255); // Set stroke 30lor to white
tri(500); // Call the tri() function to draw a triangle with a side length of 150
pop(); // Restore the previous transformation state
t2 = t2 + 2; // Increment the variable t
}
}
function tri(length) {
// Draw an equilateral triangle
triangle(
0,
-length / sqrt(3),
length / 2,
length / (2 * sqrt(3)),
-length / 2,
length / (2 * sqrt(3))
);
}