joriszwart.nl

// how to control the frequency?

const context = document.querySelector(‘canvas’).getContext(‘2d’)

// const k = 256 let sin = 0, cos = 75 * 256

for(let x = 0; x < context.canvas.width; x += .1) { sin += cos » 8 // divide by 256 (k) cos -= sin » 8

context.fillStyle = 'blue'
context.fillRect(x, context.canvas.height / 2 + sin / 256, 1, 1)
context.fillStyle = 'red'
context.fillRect(x, context.canvas.height / 2 + cos / 256, 1, 1)

}