xxxxxxxxxx
64
i = 0;
lines = 1;
function setup() {
createCanvas(700, 700);
strokeWeight(1);
background(248)
}
function draw() {
translate(width / 2, height / 2);
rR = random(0, 255);
rG = random(0, 255);
rB = random(0, 255);
stroke(rR, rG, rB);
var radius = 300;
var angle = TAU / 100;
var x = cos(angle * i) * radius;
var y = sin(angle * i) * radius;
i = i + 0.1;
if (lines == 1) {
line(0, 0, x, y);
} else if (lines == 2) {
line(0, 200, x, y);
} else if (lines == 3) {
line(200, 50, x, y);
line(50, 200, x, y);
} else if (lines == 4) {
line(100, 100, x, y);
line(-100, -100, x, y);
} else if (lines == 5) {
line(-300, 0, x, y);
line(300, 0, x, y);
} else if (lines == 6) {
line(0, 0, x, y);
line(50, -150, x, y);
line(100, -280, x, y);
} else if (lines == 7) {
line(-300, 0, x, y);
line(300, 0, x, y);
line(0, -300, x, y);
line(0, 300, x, y);
}
}
function keyReleased() {
if (keyCode == DELETE || keyCode == BACKSPACE) noLoop();
if (keyCode == ENTER || keyCode == RETURN) loop();
if (keyCode == ESCAPE) background(248);
if (key == 's' || key == 'S') saveCanvas();
if (key == '1') lines = 1;
if (key == '2') lines = 2;
if (key == '3') lines = 3;
if (key == '4') lines = 4;
if (key == '5') lines = 5;
if (key == '6') lines = 6;
if (key == '7') lines = 7;
}