Skip to content

Instantly share code, notes, and snippets.

@pketh
Created February 7, 2019 22:05
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save pketh/6e62b93e2c1a1af914707c767bd7845e to your computer and use it in GitHub Desktop.
Save pketh/6e62b93e2c1a1af914707c767bd7845e to your computer and use it in GitHub Desktop.
random splatters
# addRandomSplatter = ->
# maxX = window.innerWidth
# maxY = window.innerHeight
# x = _.random 0, maxX
# y = _.random 0, maxY
# if consecutiveRandomSplatters < MAX_CONSECUTIVE_SPLATTERS
# consecutiveRandomSplatters += 1
# addSplatter x, y
#
# autoSplatter = ->
# currentDelay = 0
# AUTO_SPLATTERS.forEach (delay) ->
# setTimeout addRandomSplatter, currentDelay + delay
# currentDelay = currentDelay + delay
addSplatter = (x, y, size, color) ->
if x and y
color = color or _.sample palette
size = size or DEFAULT_SIZE
drawContext.beginPath()
drawContext.arc(x, y, size, 0, 2 * Math.PI)
drawContext.closePath()
drawContext.fillStyle = color
drawContext.fill()
drawCanvasImage = drawContext.getImageData(0, 0, window.innerWidth, window.innerHeight)
# window.setInterval ->
# addRandomSplatter()
# , RANDOM_SPLATTER_DELAY
# RANDOM_SPLATTER_DELAY = 1000
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment