Not sure what title to use, so I'll try to explain clearly what I want to do.
Let's say I have a sketch that interactively puts different fixed sizes shapes when I click with the mouse. I want this sketch to, in the end, save as a (let's say) 2000 x 1000 px image or svg. Problem is this is too big for my screen, so I'd like to actually view the window in a smaller size (say 1000 x 500 px) that would scale everything down proportionally, on this view, but would still output to 2000 x 1000 px (properly sized) in the end.
I'm looking for the best way to do this. I define “best” as being something that's both simple, and can be easily reused across different sketches, so it'd ideally be a few lines of code that I can just dump to a sketch, without having to change any other values in the sketch itself.
Yes, by exporting as an svg I could scale it later, but that would entail that I'd need to tell the sketch to draw every shape in half the size of what it is now, and that can become laborious.
Even after searching and reading through the forums, I can't get my head around how to make this work. Here's some of my code.
String[] pulses = { "sin(t)", "cos(t)" };
void setup() {
size(500, 500);
}
void draw() {
float t = millis() * 0.15;
float sizeChange = …
ellipse(0, 0, sizeChange, sizeChange)
}
Now, the problem is that nothing seems to work on line 9. What I want is to be able to take some index from the array “pulses” and use it to be the “sizeChange”, but stuff like
float sizeChange = float(pulses[1]);
and other variants like the more complex (in writing) “Float.parseFloat()”, don't seem to work. The best I can get (when printing) is NaN. However, if I use “int()”, I always get 0, which of course will not work, since all the values will be between -1 an 1 anyway, I need the float.
It seems like it should be simple, but I'm not getting it to work.
The new selectInput() (and friends selectOutput() and selectFolder()) have a strange way of operating, and I'm not getting my head around the concept of how they work, it seems to be very confusing. You can
see the changes here.
What I'd like to do is something simple, like
PShape shapeToUse;
void setup() {
size(200, 200);
}
void draw() {
shapeToUse = loadShape("somethingIHaveSelected");
shape(somethingIHaveSelected);
}
How do I go about implementing selectInput() in it's new state, so that I can select the .svg to be loaded on the sketch?
I'm looking for a way to do boolean operations with SVGs. I've been at it for a while, and saw various libraries, but I'm stumped, since my programming knowledge is still limited. I want to do the “regular” operations you'd do with a vector graphics program, such as union, intersection, xor and others.
I don't care if I have to use a library (preferably one that's maintained), but it should be a straightforward way, and I'd also request a small example on how to do it.