We are about to switch to a new forum software. Until then we have removed the registration on this forum.
Hi, I am new to Processing, our instructor asks us to make a graphic calculator, and I just don't have a clue how to draw the trig graph. (I am thinking for loops and while loops, but I am not sure if that's the right approach) how does the sin(x) work in the code actually? Thank you in advance.
Answers
There's an example.
Thank you, Ater. I tried to make a solid curve, here's my code, but I think some of them are not ideal or appropriate code....
:((
https://forum.processing.org/two/discussion/8045/how-to-format-code-and-text#latest
Thanks TfGuy44, I've fixed the code format. One question, how do I make the graph staying after I click the mouse, and replace it by new graph when I click the next button?
Well, now that I can copy, paste, and run your code without the nightmare that it was before, I can see what the problem is.
You're doing your function-drawing inside mousePressed(). But whatever functions you draw are just going to get wiped away when the next frame is drawn by draw().
What you need to do is add some booleans that track which functions should be drawn. When the user clicks a button, set those booleans to true or false depending on which button was pressed.
Then just draw all the functions, but conditionally, based on if the relevant boolean is true.
Here's an example for you.
OR since only ONE of them red, yellow, green, blue; can be true at one time you might as well say (before
setup()
)and then in draw()
Thank you guys, I really appreciate the responses.