Problems using PShape with SVGs
Hi there,
I am using APDE 0.5.1. It seems that PShape doesn't work properly with SVG files. The examples (Examples/Basiscs/Shape/{LoadDisplaySVG,ScaleShape} compile but don't display properly on my mobile phone.
The following code illustrates one particular problem. Ishould put the graphics into a rectangle.
PShape myShape;
void setup() {
size( 540, 960 );
myShape = loadShape( "TriangleRight.svg" );
}
void draw () {
background( 240 );
int x = 40, y = 40;
float w = myShape.width, h = myShape.height;
rect( x, y, w, h );
shape( myShape, x, y );
}
Instead the SVG is off by a factor of 3. If I replace the line
rect( x, y, w, h );
by
rect( 3*x, 3*y, w, h );
then the graphics lies exactly on top of the rectangle.
PS.: Within the processing IDE the code with the identical SVG file works fine.
This seems to be a bug in Android mode itself. There are two issues on the android-processing repo that may be related. If this is indeed the case, then I can't fix the problem through APDE.
The examples do not display the bot1.svg properly because of the file itself. You have to take out the translate item. I wrote the issue here.
LoadShape() really is limited, it just works with simple shapes, and can not handle transparency (donut). You have to adapt the file manually.
I started here ( Click "next post" to read more about the subject)
I also do recommend the excellent geomerative library. It is not well documented but once you have a grip on it you do every thing you want.
Could you give a link of the TriangleRight.svg file to try it.