Skip to content

Instantly share code, notes, and snippets.

@gabrielflorit
Last active December 27, 2021 23:26
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save gabrielflorit/1fa7a9d8ec2d63b61ac47c8f5d2de162 to your computer and use it in GitHub Desktop.
Save gabrielflorit/1fa7a9d8ec2d63b61ac47c8f5d2de162 to your computer and use it in GitHub Desktop.
SCRIPT-8
// title: Sine rects
initialState = {
i: 0,
dir: 1
}
update = state => {
state.i += state.dir
state.dir *= Math.abs(state.i) > 64 ? -1 : 1
}
draw = state => {
clear()
range(128).forEach(x => {
const y = Math.sin(x * Math.PI / 64) * state.i + 64
rectFill(x, y, 7, 4, x)
})
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment