Hi Jarin7,
You can use abs(cos())
function to get something similar.
Do you mean, draw that exact shape with bars, or should it be based on something – like a particular curve / wave, or probability distribution?
Or hooked up to something, like audio?
Or visualizing a list of data entries like a bar graph…?
Yeah, it should look “something” like this. It’s 1 period of two-way regulated sinusoid. y = 0 at (0,0),(50,0)(100,0) Lines should be 1 pixel big and between lines there should be 1 pixel gap. It has nothing to do with audio. Sorry for not specifing closer earlier, thanks for any idea.
It sounds like you want to draw a series of rectangles, starting rom 0 and going to x – use a for
loop for that, and rect()
.
Then, you want to change the height of each rectangle according to a sine wave function. Use sin()
for that.
…in fact… you might want to take a look at the Processing short example for using sin
…
That is if you want to use Processing. If you want to use p5.js, you can go to https://p5js.org/reference/ to find the equivalent functions.
Oops! That’s right – I missed that it was p5.js.
A guide on how to sin, you say?
Thanks a lot! I really appreciate it.