Moving effect of a set of dots

Hi, I have a function to create one set of dots, which are individually created by ellipse() function. I hope to move one set (=individual dots within the set) right and left according to the frame rate, and each set moves at its own pace.

I’m thinking of storing positions of individual dots (that would be many dots though!) and then within draw(), calling another function to increment and decrement the x and y of each dot within a set and update the ellipses to make a moving effect.

Could anyone think of a more efficient way to do this?

Thank you for your help in advance!

image

If you want a simple and effective way to move clusters of circles (that stay fixed relative to themselves), you can create choose a center of the cluster and the positions of the circles are relative to it. You can move the circles while moving the center.

You can use cartesian/polar coordinates. Polar would be best if you want to move the circles towards/around the center of the cluster in circular pattern, while cartesian would be best if you want them to move up/down/left/right from their position.

Now for the movement of the cluster. It is nothing difficult, you can just create a class that represents a cluster and move it in any way you want.

I am not 100% sure this is what you wanted, so yeah…
In any case, good luck with your coding!

1 Like

when all sets look the same and are not moving internally (inside a set) you can use PShape and write cluster.addChild(childSphere);

see PShape \ Processing.org

and just use shape(cluster,x,y); in your Cluster class

you could also just use an ArrayList<PVector> list = new ArrayList(); to get things started, so you don’t need a class

1 Like

@Chrisir

This is a p5.js topic.
Your last post in this topic is for Processing and may confound a p5.js user.

It happens and I have done the same on occasion.

:)

1 Like