xxxxxxxxxx
63
var new_step = 150;
var transparency = 100; // 0-255
var x_pos, y_pos;
var angle = 0;
var color1, color2;
var colorFlag;
function setup() {
createCanvas(600, 600);
background(250);
color1 = color(random(250), random(255), random(255), transparency);
color2 = color(150, 0, 0, transparency);
x_pos = width / 2;
y_pos = height / 2;
stroke(color1);
colorFlag = false;
strokeWeight(2);
angleMode(DEGREES);
}
function draw() {
color1 = color(random(255), random(255), random(255), transparency);
//color2 = color(150, 0, 0, transparency);
translate(x_pos, y_pos);
rotate(angle);
line(0, 0, -150, -150);
// line(0, 0, 100, 100);
angle = angle + 1.5;
if (colorFlag) {
stroke(color2);
colorFlag = false;
} else {
stroke(color1);
colorFlag = true;
}
x_pos -= 1;
y_pos -= 1;
if (angle > 1800) {
// x_pos += random(-new_step, new_step);
// y_pos += random(-new_step, new_step);
// angle = 0;
// color2 = color(250, 0, 0, transparency);
transparency -= 10;
}
// checking if it is out of canvas and resetting / Wrap Around
if (x_pos > width) {
x_pos = 0;
}
if (x_pos < 0) {
x_pos = width;
}
if (y_pos > height) {
y_pos = 0;
}
if (y_pos < 0) {
y_pos = height;
}
}