xxxxxxxxxx
58
/*
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;
//setup function
function setup() {
//Make Canvas resizable to window
createCanvas(windowWidth, windowHeight);
//Don't fill shapes
noFill();
//Outline color white
stroke(255);
}
//resize Canvas when window is resized
function windowResized() {
resizeCanvas(windowWidth, windowHeight);
}
//draw loop initiation
function draw() {
//set background to black
background(0);
//define minimum dimension to either width or height depending on which is smallest
let minDimension = min(width, height);
//define amount to a smooth sine movement with a smaller amplification of 0.6.
let amount = sin(angle)/2 + 0.6;
//define thickness to 1/20 of minimum dimension and multiply to by the amount movement pattern
let thickness = minDimension/20 * amount;
//set strokeWeight to thickness
strokeWeight(thickness);
//define diameter to half of minimum dimension
let diam = minDimension/2;
//create circle and set circle location to center of canvas.
circle(width / 2, height / 2, diam);
//increase the angle of the sine pattern 0.03 each repeat.
angle += 0.03;
}