I am just getting started with the geomerative library. I am trying to import a SVG file, get a set of points, and draw circles on them. I have created my SVG file in Inkscape - it consists of three paths. Everything is fine except that two of the paths are not drawn. My code is like this (written in Groovy, so slightly different syntax to processing):
import geomerative.*
RG.init(this)
RShape s = RG.loadShape("/home/martin/Dropbox/downloads/svg/1.svg")
ArrayList points = s.getPoints()
for (int i = 0; i < points.size(); i++) {
ellipse(points[i].x, points[i].y, 5, 5)
}
Could anyone take a look at the SVG -
download it here - and see if you can spot the problem? The main part of the bike is drawn fine, but the wheels are missing.
Say I want to draw 100 circles to the screen, and I want them randomly placed. It's easy enough to just call
ellipse(random(width), random(height), 5, 5)
100 times. But the resulting distribution of points is clumpy. What I'm looking for is a set of 100 points that are all roughly an equal distance from each other. My initial though is to use some sort of 2D physics simulation, with 100 particles with mutual repulsion, and run it until they stop moving. But is there a quicker way to do this? I don't want to animate the actual process of the particles (points) moving, just their final resting places. I'm sure this is a common-enough problem that there is an established algorithm for doing it.
I have a processing sketch that generates a different image every time a key is pressed. When it generates an image that I want to save, I would like to export the sketch for printing. What is the best way to do this? I have tried the following ways:
1. Export as PDF using the Processing library. This doesn't work because my sketch involves large numbers of PGraphics objects with transparent backgrounds, and the transparency doesn't seem to work on PDF output. It seems from looking at some older threads that PDF files might not support transparency anyway.
2. Export as SVG using a third-party library. I have not been able to get any third party library working. I have tried using this library:
but I get a NullPointerException, and I am reluctant to start digging through the code to figure out why it's not working.
3. Export as a PNG or JPEG at a higher resolution than the applet size. I don't know if it's possible to do this; my applet is running at 800x800 pixels, but in order to make large prints I would need at least 10 times this resolution, which obviously won't display properly on my monitor.
Does anybody have any suggestions? Obviously getting a working PDF or SVG exporter would be best since I can arbitrarily scale a vector graphics format. I'm sure that there are robust SVG export libraries available for Java - does anybody know how I can hook one of them up to Processing? I'm running my sketches from Java, not the Processing IDE.