xxxxxxxxxx
62
/*
Based on p5.js demos by Matt DesLauriers
https://github.com/mattdesl/workshop-p5-intro
The MIT License (MIT) Copyright (c) 2019 Matt DesLauriers
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
//define variable for angle
let angle = 0;
//initiate setup function
function setup() {
//create scalable canvas depending on window size
createCanvas(windowWidth, windowHeight);
//dont fill shapes
noFill();
//fill shapes white
stroke(0);
}
//function for window resizing
function windowResized() {
//resize canvas if window is resized
resizeCanvas(windowWidth, windowHeight);
//set background to black
background(255);
}
//initiate draw loop
function draw() {
//draw background black with an alpha of 25 to create blur trail effect
background(255, 5);
//move shapes to center of canvas
translate(width / 2, height / 2);
//set minimum dimension to either width or height depending on which is smaller
let minDimension = min(width, height);
//set thickness of outline
strokeWeight(minDimension * 0.05);
//set radius to 1/4 of minimum dimension
let radius = minDimension * 0.25;
//set x to the cos of angle and scales it to the radius of the circle
let x = cos(angle) * radius;
//set y to the sin of angle and scales it to the radius of the circle, these lines create the rotation of the circle around the center.
let y = sin(angle) * radius;
//create circle with variables and set to 3/4 of radius.
circle(x, y, radius * 0.75);
circle(y, x, radius * 0.75);
//add 0.02 to angle for each loop.
angle += 0.05;
}