We are about to switch to a new forum software. Until then we have removed the registration on this forum.
Hi Guys,
I'm new at p5.js and I'm trying to change the code in the below link from the p5.js examples to do the same effect with a line or rect. It would be really really great if someone could help. :)
Answers
@Siehstdumich --
Try using beginShape(QUAD_STRIP)
Note that you may need to change how many points are in the loop -- a TRIANGLE_STRIP begins with three points for the first triangle, then one point per additional triangle. On the other hand, a QUAD_STRIP begins with four points for the first quad, then two points per additional quad.
For more details see:
@jeremydouglass
thank you for the quick answer :)
but maybe I wasn't clear enough, sorry it's really hard for me to explane it in english, ^^" I have now done the below code. But I want a fixed area where the number of points increases and decreases by moving the mouse like in the image below: http://img5.fotos-hochladen.net/uploads/unbenannt0xajoi8gfz.png
Please format your code:
https://forum.processing.org/two/discussion/15473/readme-how-to-format-code-and-text
Your example fits different numbers of points into the same circle angle by creating a variable
angleStep
:You could use this approach for your rectangular triangleStrip -- compute
var heightStep
based onnumPoints
, then increment it for each pair of points.Alternately, use map() or lerp() to dynamically find the current point height based on the step, number of points, and total height:
okay thank you I will try it :) (and thanks for the advise. I have formatted the code above)