Created
February 7, 2019 22:05
-
-
Save pketh/6e62b93e2c1a1af914707c767bd7845e to your computer and use it in GitHub Desktop.
random splatters
This file contains 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
# 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