Skip to content

Instantly share code, notes, and snippets.

@gabrielflorit
Last active June 6, 2018 02:40
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 gabrielflorit/bfc06774010529414e2295f0e46fd330 to your computer and use it in GitHub Desktop.
Save gabrielflorit/bfc06774010529414e2295f0e46fd330 to your computer and use it in GitHub Desktop.
SCRIPT-8
// 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