xxxxxxxxxx
//
//
// (c) Tariq Rashid 2018
// sketch supports content of Make Your Own Algorithmic Art
// https://www.amazon.com/Make-Your-Own-Algorithmic-Art-ebook/dp/B07BP13VPR
//
//
function setup() {
createCanvas(800, 600);
background('white');
noLoop();
}
function draw() {
stroke(0); noFill(); rect(0,0,799, 599);
// set angles to be in degrees (not radians)
angleMode(DEGREES);
fill(255, 0, 0, 5);
noStroke();
// circle radius
var radius = 180;
// loop to count angle
for (var angle = 0; angle < 360; angle += 0.1) {
// loop to create a factor for varying angle
for (var t = 0; t < 100; t += 1) {
// calculate (x,y) for point P
var x1 = radius * cos(angle+ (0.1*t));
var y1 = radius * sin(angle+ (0.1*t));
// calculate how far point Q is from P
var x2 = radius / 3 * cos(15 * (angle + (0.2*t)));
var y2 = radius / 3 * sin(15 * (angle + (0.2*t)));
// calculate how far point S is from Q
var x3 = radius / 6 * cos(20 * (angle+ (0.3*t)));
var y3 = radius / 6 * sin(20 * (angle+ (0.3*t)));
// point S is at (x1 + x2 + x3, y1 + y2 + x3)
var x = x1 + x2 + x3;
var y = y1 + y2 + y3;
ellipse(400 + x, 300 - y, 2);
}
}
}