How do you do this with modulus?
| | | |
||| ||| ||| |||
||||| ||||| ||||| |||||
|||||||||||||||||||||||||
I would like to have the 4th slot be 1, the 8th be 2, 12th be 3, 16th be 4, 20th be 3, 24th be 2, 28th be 1, 32nd be 0, and repeat, etc.. I tried for a while with modulus and ended up trying to write a more manual function, but even then didn't get to it.
let i = 0
let heights = []
while (i < 1024) {
if (i % 4) {
heights.push(getHeight(i))
} else {
heights.push(0)
}
i++
}
function getHeight(i: number) {
if (i % 16 === 0) {
return 4
}
if (i % 12 === 0) {
return 3
}
if (i % 8 === 0) {
return 2
}
if (i % 4 === 0) {
return 1
}
}
It doesn't even begin to account for the rising and falling, instead my first attempt was more like an always rising escalator, getting to 16 at the highest, then starting over. But I'd like to make it rise and fall sort of like a wave if possible. Any ideas?
It should go down to zero (unlike my first diagram), so there are 8 slots every repeat.