Problem using PShape to import SVG graphics
in
Programming Questions
•
2 years ago
Hi all!
I am realtively new to processing, and was just told about processing's capabillity to load and manipulate SVG graphics.
I am simply trying to get a simple radial gradient (basically, a 'glowy' circle) to display using PShape. All that shows up is a black circle, and I get this error: "url SVGID_1_ refers to unexpected data"
Here is the xml code behind the radial gradient:
So my question is: is the problem arising because of how I exported the SVG file (and if it is, how do I export it properly?) or is it with my code? I am using processing 1.0.9.
Thanks for taking a look, I am at a total loss!
PShape img;
void setup() {
size(500, 500);
background(255);
}
void draw() {
img= loadShape("glowy2.svg");
shapeMode(CENTER);
smooth();
shape(img, width/2, height/2);
}
I am realtively new to processing, and was just told about processing's capabillity to load and manipulate SVG graphics.
I am simply trying to get a simple radial gradient (basically, a 'glowy' circle) to display using PShape. All that shows up is a black circle, and I get this error: "url SVGID_1_ refers to unexpected data"
Here is the xml code behind the radial gradient:
<?xml version="1.0" encoding="utf-8"?>.
<!-- Generator: Adobe Illustrator 14.0.0, SVG Export Plug-In . SVG Version: 6.00 Build 43363) -->
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.0//EN" "http://www.w3.org/TR/2001/REC-SVG-20010904/DTD/svg10.dtd">
<svg version="1.0" id="Layer_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px"
width="316.79px" height="316.79px" viewBox="0 0 316.79 316.79" enable-background="new 0 0 316.79 316.79" xml:space="preserve">
<radialGradient id="SVGID_1_" cx="158.394" cy="159.1836" r="158.3938" gradientUnits="userSpaceOnUse">
<stop offset="0" style="stop-color:#35469D"/>
<stop offset="1" style="stop-color:#2D409A;stop-opacity:0"/>
</radialGradient>
<circle fill="url(#SVGID_1_)" cx="158.394" cy="159.184" r="158.394"/>
</svg>
So my question is: is the problem arising because of how I exported the SVG file (and if it is, how do I export it properly?) or is it with my code? I am using processing 1.0.9.
Thanks for taking a look, I am at a total loss!
PShape img;
void setup() {
size(500, 500);
background(255);
}
void draw() {
img= loadShape("glowy2.svg");
shapeMode(CENTER);
smooth();
shape(img, width/2, height/2);
}
1