Skip to content

Instantly share code, notes, and snippets.

@gabrielflorit
Last active June 29, 2018 12:51
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/3ccb3ef6111d5f105d0a7437d2fbbf17 to your computer and use it in GitHub Desktop.
Save gabrielflorit/3ccb3ef6111d5f105d0a7437d2fbbf17 to your computer and use it in GitHub Desktop.
SCRIPT-8
// title: plumber spiral
initialState = {
circles: range(64)
.map(i => ({
a: 0,
r: i,
c: 7 - Math.floor(i / 8),
d: i % 2 === 0 ? 1 : 1
}))
}
update = state => {
state.circles.forEach(circle => {
circle.a += circle.d * circle.r / 32
})
}
draw = state => {
clear()
state.circles.forEach(circle => {
const { a, r, c } = circle
const x = 64 + Math.cos(a * Math.PI / 180) * r
const y = 64 + Math.sin(a * Math.PI / 180) * r
sprite(x, y, 0)
})
}
{
"0": [
" 2220 ",
" 22222",
" 303 0 ",
" 300330",
" 3000 ",
" 220331 ",
"0 333352",
" 3 4 "
]
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment