sketch
//Nami Numoto
//mnumoto
//Section A
var dx1;
var dy1;
var dx2;
var dy2;
var numLines = 50;
var r = 0; //red
var g = 0; //green
var b = 0; //blue
function setup() {
createCanvas(400, 400);
background(200);
line(50, 50, 150, 300);
line(300, 300, 350, 100);
var r = random(0,255);
var g = random(0,255);
var b = random(0,255);
dx1 = (150-50)/numLines;
dy1 = (300-50)/numLines;
dx2 = (350-300)/numLines;
dy2 = (100-300)/numLines; //shape 1 (given)
ex1 = 2 * (150-50)/numLines;
ey1 = 2 * (300-50)/numLines;
ex2 = 2 * (350-300)/numLines;
ey2 = 2 * (100-300)/numLines; //shape 2
fx1 = 4 * (150-50)/numLines;
fy1 = 4 * (300-50)/numLines;
fx2 = 4 * (350-300)/numLines;
fy2 = 4 * (100-300)/numLines; //shape 3
}
function draw() {
var x1 = 50;
var y1 = 50;
var x2 = 300;
var y2 = 300;
stroke(r, 0, 0); //set the stroke colour to some shade of red
for (var i = 0; i <= numLines; i += 1) {
line(x1, y1, x2, y2);
x1 += dx1;
y1 += dy1;
x2 += dx2;
y2 += dy2;
}
stroke(0, g, 0); //set the stroke colour to some shade of green
for (var i = 0; i <= numLines; i += 1) {
line(x1, y1, x2, y2);
x1 += ex1;
y1 += ey1;
x2 += ex2;
y2 += ey2;
}
stroke(0, 0, b); //set the stroke colour to some shade of blue
for (var i = 0; i <= numLines; i += 1) {
line(x1, y1, x2, y2);
x1 += fx1;
y1 += fy1;
x2 += fx2;
y2 += fy2;
}
noLoop();
}
I’m not sure why it’s showing up the way it is – baseline, I struggled a lot with this project (mostly technically).
The idea was to make a fractal of sorts by squaring (hence the doubling and quadrupling) the original shape. I also intended to make each segment a different shade of red, blue, and green, infinitely.
Any suggestions? I was going to do a loop, but I was running low on time so I simply did it manually three times.