//Na-yeon Kim
//15-104, B section
//nayeonk1@andrew.cmu.edu
//Project-04_ (String Art)
function setup() {
createCanvas(300, 400);
background(0);
angleMode(DEGREES);
}
function draw() {
var x = 0;
var y = 0;
var x1 = 300;
var y1 = 400;
var xspacing = 7.5;
var yspacing = 10;
var i;
var r = map(mouseX, 0, width, 100, 200);
var g = map(mouseX, 0, width, 0, 100);
var b = map(mouseY, 0, height, 200, 250);
for (i = 0; i < 50; i++) {
stroke(r, g, b);
strokeWeight(0.5);
line(x, y + i * yspacing, x + i * xspacing, y1);
line(x + i * xspacing, y, x1, y + i * yspacing);
stroke(b, r, g);
line(x + i * xspacing, y, x, y1 - i * yspacing);
line(x + i * xspacing, y1, x1, y1 - i * yspacing);
}
}
I found that string art is simple yet so aesthetic. Numberless lines drawn by mathematics create beautiful composition which makes you just zone into.
I wish I could figure out more complicated formulas.