We are about to switch to a new forum software. Until then we have removed the registration on this forum.
Hello community!
I would like to understand how to create a Plexus effect from the scratch. I want to create this effect step by step in order to understand the code properly and hopefully be able to create a few things by myself.
I put together a simple code that generates ellipses in random positions. In my mind, the next step is to capture the X and Y off each ellipse and create lines that use those to connect each primitive based on some sort of criteria such as distance or a maximum number of connections.
How can I connect these ellipses having in mind the limit of 3 connections per primitives?
Thank you in advance.
Initial code:
int sizCircle = 10; // Size
int numCircles = 10; // # of circles
void setup() {
size(320, 530);
background (255);
for (int i=0; i< numCircles; i++) {
noStroke();
fill (random(255), random(255), random (255), random(255));
ellipse (random(width), random(height), sizCircle, sizCircle);
}
}
Answers
Hi diegooriani,
I think you're going to want a "node" class for each of your ellipsis. A data-file may also help structure out the setup.
I created something similar to what I think you have in mind. more of a dendrite model, but may get you started. You'll need the ControlP5 lib, and there are sliders along the top to control the spring, gravity, friction, randomness, and pulsewidth. The last changes the mode of animation from a free floating, bouncy, ballpit, random orbit, chaotic orbit, and a pulsing orbit.
Hope this helps get you started!
main class:
Node.pde (with overloaded constructor for versatility)
LiveNode.pde (makes it move)
model.json, the json file that holds the node data
@akiersky, Thank you for your help so far. You see, I am one of those individuals who is learning code using Code Academy and that means I have a very basic level of programming language.
I would like to see the code you shared in action but even that I cannot make it run :(( I should've mentioned my actual capabilities regarding coding in the first topic. I am hoping that with the help of experienced users (such as you) I can learn how to create the plexus effect step by step so that I can really understand what I am writing.
Right now I want to crack how I can get the ellipse coordinates and create those connections. I hope this is the first logical step (I might be very wrong about that though).
Thanks once again.
How can I print the X position of each ellipse?
I can't see where you defined and instantiated the array related to variable circles! :-/
@GoToLoop, forgive my ignorance in the next following lines.
Okay, looking at the reference and I came with this:
By the way, could I use int instead float?
Now I am getting an error regarding the ellipse. It says that cannot find a class or type name ellipse.
How can I fix this?
It's b/c "ellipse" is neither a class nor a type. It's a function which draws an ellipse() on the screen:
http://processing.org/reference/ellipse_.html
Moreover,
float
is a primitive type. Each 1 can only store 1 value. But it seems like you're trying to fit 4 values in? @-)Perhaps you should try PVector. It allows 3
float
values to be stored in it -> x, y, z:processing.org/reference/PVector.html
This is hard to understand dude :-? Thank you for the help anyway. What I am trying to do is to hold the value of each ellipse in the Array circles[i] and then print the X value from it. To be honest I am not even sure if this is method is correct.
For now, I basically want to understand how can I connect random generated ellipses with a lines. Hopefully after understanding this I can make things more complex and exciting.
In Java, we gotta specify which type an array is. :-B
We already know that you want an array w/ its reference in variable circles.
But what's its type, what's being stored in that array? :-??
We can't store function references, like ellipse(), straight into variables in Java.
Unless it's JavaScript or the newest Java 8, which Processing isn't compatible yet.
Here's an online Processing code which uses an array of PVector objects in order
to store coordinates in their x, y fields, plus the sizes in their z fields:
http://studio.processingtogether.com/sp/pad/export/ro.98wJk9FLLhbUE/latest
Thanks, I will have a look into it.