We are about to switch to a new forum software. Until then we have removed the registration on this forum.
Proceessing has own class line(float,float,float,float), but I want to create something like enhanced line, consisting of little rectangles, or ellipses. I need it to change line stroke color to smooth gradient (for example in the beginning the line is green, and the green color becomes yellow when the line ends). Any ideas how to create this?
Answers
Write your own function.
This question is solved.
Then please do us some good and post the solution here.
Here is my solution:
OK. Thanks on behalf of anyone wanting a solution.
or use lerp()
@koogs, cool, thanks for this variation. A little remark - you forgot to declare PVectors A nad B.
no, i only posted the draw() because that's the only thing i changed (and only half of that). the rest of the code is the same.
Though I would recommend turning it into a function for better reusability (it's fairly easy, so you don't need to bother if you don't want to).
Thanks. I have a more complex project, and this little sketch goes as a part of my big project. A big project has a PGraphics layers. I tried to use function there, but there is an unexpected conflict - PGraphics don't work with functions (or I'm doing something wrong). That's why I writing a code without functions.
For it to work, you'd need to have the function take a PGraphics object as an extra parameter and draw everything on it - and to make code smaller, assume that beginDraw() was already called. For example, the code for polygon from this tutorial adapted for PGraphics -