Last active
December 27, 2021 23:26
-
-
Save gabrielflorit/1fa7a9d8ec2d63b61ac47c8f5d2de162 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: 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