xxxxxxxxxx
74
/*
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.
*/
//variable initialization
let angle = 0;
let angle2 = 0;
//setup initialization
function setup() {
//resizable canvas
createCanvas(windowWidth, windowHeight);
//allows rotation to be set by degrees
angleMode(DEGREES);
//fill shapes white
fill(255);
}
//start draw loop
function draw() {
//set default color blend mode
blendMode(BLEND);
//background set to black
background(255);
//change blend mode to difference between two colors overlapping
blendMode(DIFFERENCE);
//define x and y variable to center of screen
let x = width / 2;
let y = height / 2;
//define variable for minimum sizing of objects to be the width or height of the screen
let minDimension = min(width, height);
//define variable for spacing to set size of shapes within resizable canvas
let spacing = minDimension / 12;
//draw circle with spacing offset and size set to 4x the minimum dimension
circle(x - spacing, y - spacing, spacing * 2);
//draw triangle with spacing offsets applied
triangle(
x - spacing,
y - spacing * 6,
x - spacing,
y + spacing,
x - spacing * 6,
y + spacing
);
//save the current settings
push();
//move shapes to center
translate(x, y);
//rotate square by angle
rotate(angle);
//make rectangle from center point
rectMode(CENTER);
//make square and set sizing 4x minimum dimension
square(0, 0, spacing * 6);
square(20, 0, spacing * 6);
//rotate square +0.5 per loop
angle -= 0.5;
//reset to original state
pop();
}