Is there a smart way to have a dot (point, ellipse) move in the path defined by a random shape/trajectory? I want the shape to visible, and the dot to move 1px at a time.
Hello guys!
I m working on the same stuff. I created the shapes with PShape, thus I generated an ArrayList<PVector> with lerp() that is the list of the coordinates that my dot has to follow at each time.
It works, but every time the dot has to follow a new paths or repeat the old one, it goes along it faster and faster.
Is it possibile that is related to the graphic acceleration?
Answers
You need to be more specific about the shape. Is it a bitmap image or a PShape object or something else?
I want to draw the shape myself (PShape or even with rect/ellipse). This is pretty straightforward with a circle, e.g.:
dotX = circleX + cos(radians(angle)) * radius; dotY = circleY + sin(radians(angle)) * radius;
But I wonder if there's a simple way of achieving the same if the shape is different, e.g., a rotated square with rounded corners.
You will probably have better luck with PShape because I think it can be used to store paths.
Someone more familiar with PShape could advise you better.
you probably loop all vertexes / vertices in the PShape and use
lerp()
for the transitionto avoid that the speed is higher for longer passages, set amt (see reference on lerp) depending on
dist()
of the 2 verticesHello guys! I m working on the same stuff. I created the shapes with PShape, thus I generated an
ArrayList<PVector>
withlerp()
that is the list of the coordinates that my dot has to follow at each time.It works, but every time the dot has to follow a new paths or repeat the old one, it goes along it faster and faster.
Is it possibile that is related to the graphic acceleration?
Solved! It was just a mistake on my code, sorry.