xxxxxxxxxx
61
/*
Adapted from source:
Aesthetic Programming by Winnie Soon & Geoff Cox
https://www.aesthetic-programming.net/pages/3-infinite-loops.html#setup-70191
LICENSE
[Aesthetic Programming] is an open access book, licensed under the Creative Commons Attribution By Attribution Share Alike License. Under this license, authors allow anyone to download, reuse, reprint, modify, distribute, and/or copy their work so long as the authors and source are cited and resulting derivative works are licensed under the same or similar license. No permission is required from the authors or the publisher. Statutory fair use and other rights are in no way affected by the above. Read more about the license at https://creativecommons.org/licenses/by-sa/4.0/
See Creative Commons License and MIT License here: https://creativecommons.org/licenses/by/4.0/ and https://opensource.org/licenses/MIT
*/
let totalPositions = 9;
let positionIndex = 0;
//setup stuff
function setup() {
//canvas fills window
createCanvas(windowWidth, windowHeight);
//rotating something
angleMode(DEGREES);
//elements filled white
fill(255);
//no outline on elements
noStroke();
}
//sketch is resized to new window resolution when window is resized
function windowResized() {
console.log('Window Resized')
//resizing
resizeCanvas(windowWidth, windowHeight);
//set background to white
background(0);
}
//constantly drawing
function draw() {
//set background color to white, with an alpha/transparency of 20
background(0, 20);
//change the origin of the canvas to the center of the canvas
translate(width / 2, height / 2);
//rounding somehting
positionIndex = round(frameCount / totalPositions);
console.log(positionIndex);
let angle = (360 / totalPositions) * (positionIndex % totalPositions);
//technique for a repeating counter
console.log(positionIndex % totalPositions)
//rotate the canvas by this angle
rotate(angle);
//draw a circle that is relative to size of canvas
let minDimension = min(width, height);
let diam = minDimension * 0.05;
circle(50, 0, diam);
}