Skip to content

Instantly share code, notes, and snippets.

@slugbyte
Created September 26, 2021 13:12
Show Gist options
  • Save slugbyte/6e1c4fc925aaf80b14c23bc122b1d238 to your computer and use it in GitHub Desktop.
Save slugbyte/6e1c4fc925aaf80b14c23bc122b1d238 to your computer and use it in GitHub Desktop.
const canvasWidth = 400
const canvasHeight = 400
function randomRange(min, max){
min = Math.ceil(min);
max = Math.floor(max);
return Math.floor(Math.random() * (max - min + 1)) + min;
}
function getLocation(){
return [
randomRange(75, canvasWidth - 150), // x
randomRange(75, canvasHeight * .8), // y
]
}
function getColor(){
return [
237, // r
242, // g
84, // b
randomRange(0, 255), // a
]
}
function flower(x, y){
let height = 100
let width = 50 + randomRange(0, 10)
stroke('#53db65')
fill(...getColor())
circle(x + width / 2, y, width, width)
fill(0)
circle(x + width / 2, y, 20, 20)
noFill()
line(x + width / 2, y + 27, x + width / 2, y + 100)
fill('blue')
}
function setup(){
createCanvas(canvasWidth, canvasHeight)
noLoop()
background('#bdf9c6')
for (let i=0;i<10;i++){
flower(...getLocation())
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment