Skip to content

Instantly share code, notes, and snippets.

@gabrielflorit
Last active June 6, 2018 02:45
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/5d903096ac975e3aa9a2e0d394292502 to your computer and use it in GitHub Desktop.
Save gabrielflorit/5d903096ac975e3aa9a2e0d394292502 to your computer and use it in GitHub Desktop.
SCRIPT-8
// title: Dot 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 / 4
})
}
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
circFill(x, y, 4, c)
})
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment