Last active
June 6, 2018 02:40
-
-
Save gabrielflorit/bfc06774010529414e2295f0e46fd330 to your computer and use it in GitHub Desktop.
SCRIPT-8
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
// title: Wobbly circle | |
initialState = { | |
x: 64, | |
y: 64, | |
r: 1, | |
dr: 1 | |
} | |
update = (state, input, elapsed) => { | |
state.x += random(-1, 1) | |
state.y += random(-1, 1) | |
state.x = clamp(state.x, 0, 128) | |
state.y = clamp(state.y, 0, 128) | |
state.r += state.dr | |
state.dr *= state.r > 63 || state.r < 2 ? -1 : 1 | |
} | |
draw = state => { | |
clear() | |
range(state.r) | |
.reverse() | |
.forEach((r, i) => { | |
circFill(state.x, state.y, r * 1, i) | |
}) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment