Hi.
I use Processing 1.5.1 in Windows to produce some PNG images and then call exit() as last command in setup().
The sketch is then compiled as applet and executed from command line with
> java -jar sketch_name.jar
This works.
What if I want to read some command line arguments to specify PNG's parameters (such as filename, size, etc) inside the sketch? I saw that args[] is always long 1 and contains the jar filename. Extra arguments are lost...
I would like to be able to call the applet with
> java -jar sketch_name.jar param1=value1 param2=value2
I tried -Dproperty=value but system property values don't look like working with this syntax in Processing.
Any hint?
Hi. I'm working with 10.000 moving points and need to search for the nearest to each given point.
Now this is implemented with two slow nested loops.
Some time ago I saw an example where the whole area had been split in little squares. Then distances between a given point and the closer ones was first calculated just into the square where the given point is. If no neighbors were found the search would have been extended to other neighbor squares. This reduces greatly the number of distance comparisons.
Can somebody help me locate that example? It was probably to illustrate a dedicated library and featured (according to my memories) 8000 white moving points on black background.
Or some alternative code/library to do so?
I read about the nearest neighbor algorithms but life is too short to reinvent the wheel.
I'm building an image from a database of around two millions lines. Each line is of one of 3 colors.
This process is very long and I would like to avoid it when possible.
After the image has been composed, according to the aestethical result, I would like to change a single color WITHOUT recalculating the whole database. I cannot find an algorithm to do this.
If there is no smooth (and no antialiasing) it is easy: I scan the image replacing pure original color pixels.
With smooth() antialiasing doesn't let this simple approach.
This source shows the problem:
color colbg = #000000;
color col1a = #008844;
color col2a = #884400;
color col3a = #440088;
color col1b = #ff88ff;
color col2b = #88ffff;
color col3b = #ffff88;
void setup() {
size(400,400);
background(colbg);
smooth();
strokeWeight(35);
noFill();
// draw lines
stroke(col2a);
bezier(70,50,150,650,300,-250,300,300);
stroke(col3a);
bezier(50,150,50,50,350,300,350,350);
stroke(col1a);
bezier(50,50,50,150,250,250,200,300);
// replace a single color
loadPixels();
for (int i=0; i<pixels.length; i++) {
if (pixels[i] == col1a) pixels[i] = col1b;
}
updatePixels();
}
void draw() {
}
With antialiasing the border of pink curve is greenish, a souvenir of its original color.
Is there an algorithm to replace the green original color in a more effective way to remove this artefact?
I thought to play with different PGraphics (one for each color) and find a way to manage transparencies but I saw that smooth() doesn't work in PGraphics.
I want to save on file a set of unbufferized records (1 int + 4 floats each). Their number ranges from half a million records to several millions.
To save these data I used FileOutputStream and writeInt/writeFloat but they are incredibly slow. Using a text file with the readable data instead and converting them when necessary is far faster. This puzzles me because I don't know anything about Java's file classes.
Can you redirect me on a snippet to solve this problem? I couldn't find anything in the forum.