xxxxxxxxxx
/******************
Code by Vamoss
Original code link:
https://www.openprocessing.org/sketch/624877
Author links:
http://vamoss.com.br
http://twitter.com/vamoss
http://github.com/vamoss
******************/
var prevPos = {}
var pos = {}
var dir = 1
var radius = 1
var angle = 0
var pg
function setup() {
createCanvas(600, 600);
background(255);
prevPos = {x: width/2, y: height/2}
pos = {x: width/2, y: height/2}
strokeWeight(1)
}
function draw() {
angle += 1/radius*dir
pos.x += cos(angle) * radius
pos.y += sin(angle) * radius
if(get(round(pos.x), round(pos.y))[0] < 255 || pos.x < 0 || pos.x > width || pos.y < 0 || pos.y > height){
dir *= -1
radius = random(1, 20)
angle += PI * dir
}
line(prevPos.x, prevPos.y, pos.x, pos.y)
prevPos.x = pos.x
prevPos.y = pos.y
}