Created
November 5, 2019 16:54
-
-
Save mimetaur/0a702de6f674264b58e55d11cb396047 to your computer and use it in GitHub Desktop.
Code 1 Week 7 exercise 3 possible solution for Oli
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
let diameters = [] | |
let locationX = [] | |
let locationY = [] | |
let circleHues = [] | |
let numCircles = 10; | |
let circlesFilled = [] | |
function setup() { | |
createCanvas(600, 400); | |
for (let i = 0; i < 10; i++) { | |
diameters[i] = random(0, 50) | |
locationX[i] = random(0, 400); | |
locationY[i] = random(100, 200); | |
circleHues[i] = floor(random(280, 320)); | |
circlesFilled[i] = random(100); | |
} | |
} | |
function draw() { | |
background(0); | |
colorMode(RGB); | |
for (let i = 0; i < numCircles; i++) { | |
colorMode(HSB); | |
fill(100); | |
// so there is a 50% chance that it will fill the circles | |
// and a 50% it will only draw the strokes | |
if (circlesFilled[i] > 50) { | |
fill(circleHues[i], circleHues[i], circleHues[i]); | |
noStroke(); | |
strokeWeight(0); | |
} else { | |
noFill(); | |
stroke(circleHues[i], circleHues[i], circleHues[i]); | |
strokeWeight(2); | |
} | |
circle(locationX[i], locationY[i], diameters[i]) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment