I have a program that takes info from an XML file, makes a force-directed graph from it using the toxicLibs physics library, generates a voronoi diagram on each frame from the points in the graph, then trims the voronoi with a metaball... I am trying to find a way to color specific polygon regions of the voronoi. I have a "Node" class which is an XML object, and generates the verletparticles for my flowgraph. Each "Node" has a color value, so I would like use that value to color the corresponding polygon. Here is an image of the current program without the metaball:
There are two sets of VerletParticles in this, one is the set from the directed graph, the other is a set of perimeter particles to constrain the graph. All of these particles feed into my voronoi, and only the poly's containing graph particles are drawn.
Right now, I am checking each polygon in the voronoi to see if it contains a Vec2D from my list of graph particles, but it is terribly inefficient:
I would rather make a hashmap from the graph particles to the voronoi polys, but since the voronoi is re-instantiated on each draw call, the index values are always changing.
How can I link the polygons to the particles without checking to see if the polygon contains the vector? I have no formal training in programming, so I'm kind of winging it here...Can anybody point me in the right direction?
Hello, I am learning processing and working on a school project. I am having some trouble understanding text parsing and arrays. I can parse a .tsv and create a single Array, but how do I split the array every time there is a blank line in the .tsv? I have quite a few files that I would like to combine and pass into the constructor once, rather than running each file through this individually.
I found this snippet of code that I am using to parse .tsv's into an Array:
public Table2(PApplet p5, String filename) {
String[] rows = p5.loadStrings(filename);
data = new String[rows.length][];
for (int i = 0; i < rows.length; i++) {
if (PApplet.trim(rows[i]).length() == 0) continue;
if (rows[i].startsWith("#")) continue;
String[] pieces = PApplet.split(rows[i], PApplet.TAB);
data[rowCount] = pieces;
rowCount++;
}
data = (String[][]) PApplet.subset(data, 0, rowCount);
}
Is it possible to make an array of arrays? I was thinking of wrapping all of this inside of a "for" loop that splits at the "/n" symbol (kind of like the line that ends in PApplet.TAB) Unfortunately, all of my tutorial resources have left me with a lot of questions about iteration and arrays :/