function v2(x, y) { this.x = x; this.y = y; } function gradient() { this.color = [255, 0, 0]; this.index = 1; this.direction = 1; } gradient.prototype.next = function() { this.color[this.index] += this.direction; if (this.color[this.index] == max(this.direction, 0) * 255) { this.index = (this.index + 2) % 3; this.direction *= -1; } return this.color; }; let count = 250; let multiple = 1; let radius = 400; let step = 0.01; let center = new v2(radius, radius); let theta = 2 * Math.PI / count; let alpha = n => (theta * n) % count; let f_x = n => cos(alpha(n)) * radius + center.x; let f_y = n => sin(alpha(n)) * radius + center.y; let f = n => new v2(f_x(n), f_y(n)); let canvasW = radius * 2; let canvasH = radius * 2; function setup() { createCanvas(canvasW, canvasH); } let grad = new gradient(); function draw() { background(0); fill(0); c = grad.next(); stroke(c); circle(center.x, center.y, radius * 2); for (n = 0; n < count; n++) { p1 = f(n); p2 = f(multiple * n); stroke(c); line(p1.x, p1.y, p2.x, p2.y); } multiple += step; }