xxxxxxxxxx
64
/*
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 variables
let angle = 0;
//start setup function
function setup() {
//make canvas resizable with window
createCanvas(windowWidth, windowHeight);
//don't fill objects
noFill();
//make outline white
stroke(0);
}
//function for when window is resized, it will automatically resize the canvas
function windowResized() {
//resize the canvas to windowWidth and windowHeight
resizeCanvas(windowWidth, windowHeight);
}
//draw loop function
function draw() {
//set background to black
background(255);
//define minimum size to width or height depending on whats smaller
let minDimension = min(width, height);
//set outline thickness
strokeWeight(minDimension * 0.015 + angle*5);
//set the start of the x movement to 1/4 of canvas width
let xStart = width * 0.15;
//set the end of the x movement to 3/4 of canvas width
let xEnd = width * 0.85;
//set x movement to a sin of the angle and scale it the window width
let x = width * 0.5;
//set y to half of window height
let y = (map(sin(angle), -1, 1, xStart, xEnd));
//set diameter to 3/10 of minimum dimension
let diam = minDimension * 0.3;
//draw circle
circle(x, y, diam);
circle(x+25, y, diam);
circle(x-25, y, diam);
//increase angle
angle += 0.02;
}