Skip to content

Instantly share code, notes, and snippets.

@dguti
Created February 2, 2019 16:57
Show Gist options
  • Save dguti/c2e4a7a73d550f810deafccfae598e95 to your computer and use it in GitHub Desktop.
Save dguti/c2e4a7a73d550f810deafccfae598e95 to your computer and use it in GitHub Desktop.
SCRIPT-8
initialState = {
color: 0,
angle: 5 // the rotation angle
}
update = (state, input, elapsed) => {
state.angle = state.angle + elapsed * -42 / 200
state.color = state.color + 1/10
}
draw = (state) => {
clear()
const { angle } = state
range(8).forEach(i => {
const halfSide = 8 * i / 2
const topLeft = [64 - halfSide, 64 - halfSide]
const topRight = [64 + halfSide, 64 - halfSide]
const bottomRight = [64 + halfSide, 64 + halfSide]
const bottomLeft = [64 - halfSide, 64 + halfSide]
const color = (i + Math.round(state.color)) % 7
polyStroke([topLeft, topRight, bottomRight, bottomLeft], angle, color)
})
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment