Last active
June 6, 2018 02:45
-
-
Save gabrielflorit/5d903096ac975e3aa9a2e0d394292502 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: 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