We are about to switch to a new forum software. Until then we have removed the registration on this forum.
Hi everyone,
I'm trying to transform a loaded SVG-file, but one line doesn't transform, despite I'm looping through all the children. Does anybody know how to fix this?
Link to my SVG-file: https://dl.dropboxusercontent.com/u/104619472/a-01.svg
My code:
PShape s;
void setup() {
size(1200, 800);
}
void draw() {
background(0);
translate(400, 100);
s = loadShape("a-01.svg");
editCharacter(s);
shape(s);
}
void editCharacter(PShape s) {
s.disableStyle();
for (int i = 0; i < s.getVertexCount(); i++) {
PVector v = s.getVertex(i);
if (v.y < 50){
v.x = v.x * mouseX/100;
} else {
v.x = v.x * mouseX/100;
}
s.setVertex(i, v.x, v.y);
noFill();
stroke(255);
}
if (s.getChildCount() > 0) {
for (int i = 0; i < s.getChildCount(); i++) {
editCharacter(s.getChild(i));
}
}
}
Answers
Assuming you use Illustrator, I suggest using the pen tool and add an extra vertex on the line that doesn't alter.
Cause right now it's a line in the svg code:
<line fill="none" stroke="#000000" stroke-width="2.5" stroke-linecap="square" stroke-linejoin="bevel" stroke-miterlimit="10" x1="276.992" y1="269.125" x2="276.992" y2="141.627"/>
If you add 1 more point it will be forced into a path.
For people that need the parameters (vertices of the line that doesn't move):
But as the comment states. There is no way to change them since setParams if private.
One other way I can think of (which I don't recommend), is to program that PRIMITIVE shapes get replaced by PATH shapes. (if possible).
I have opened an issue about the problem here:
https://github.com/processing/processing/issues/4433
private
& packaged-protected are the #1 enemy of Processing programmers!!! X(Adding an extra vertex point works! Thanks! :)
@GoToLoop
I agree, I'm against using
private
in general. Unless something has to do with security or something. I wasted countless hours by trying to do something and then reach a dead end cause of one method that is private.Maybe time for you to move away from processing :)
private
. :O)protected
be enough to label that some class member isn't intended for general access?public
members! 8-Xprotected
instead ofprivate
, loadShape() still wouldn't give us our modified PShape class, but always the original! :-O@Override
loadShape() as well, forcing it to return our hacked PShape. :P