We are about to switch to a new forum software. Until then we have removed the registration on this forum.
Hi, I have a straight vertical line. When mouseX goes over it (right direction) the line will curve (as a semi circle) to the right and then remain curved until my mouseX goes back to the initial position (left of the line) I tried bezier() and curve() but they looks quite confusing in how to use them..is there a simple way to curve a straight line()? thanks
Answers
I suggest that you use the example code in the reference section for bezier() and curve () and play with them by changing the parameter values to see how they work. There is no simpler method, because you would have to create a lot of code to do the same thing.
ok thanks..after some work I managed to do something similar to what I need. the code below act as I want (referring to the mouse input) but my problem is that I don't understand how to make a straight vertical line. At the beginning (while mouseX < 146) the curve has to be a straight vertical line and then gradually increase (until mouseX reach 160)
thank you!
update..looks fine although I don't fully understand how curve() works..I still don't understand which are the points I need to modify to increase/decrease the rounding of the curve (to reach a perfect half circle)
To make the curve fit a perfect semi-circle it is easier to use bezier() rather than curve().
This sketch demonstrates draws a bezier curve between 2 points, the curvature based on the mouse X position. If you move the mouse you will find there is a position which duplicates a semicircle.
The code is show here
thanks!