HTML SVG Loading

I’m not really sure how to explain this, but I’ll give it a shot.

I have a URL that has a SVG file on it, and want to load it in and display it in my project.

Something like:

PShape costume;
costume = loadShape("https://assets.scratch.mit.edu/internalapi/asset/638caba865e74c287e8424d3cc1230ad.svg/get");

The issue is that the URL has the SVG file in the format of a HTML document, and I don’t know If its possible to load it in or not. Is there any way to do this?

EDIT: I think it’s actually XML, not 100% sure what that is…

1 Like

looks for me like a good SVG
should not be a problem

but it says here ( RPI / Raspbian / Processing 3.4 / JAVA mode )
using the
/example/basics/shape/loaddsiplaySVG/

Unsupported format: https://assets.scratch.mit.edu/internalapi/asset/638caba865e74c287e8424d3cc1230ad.svg/get

here looks better

but saving the content to a local svg file OK

PShape bot;

void setup() {
  size(500, 500);
  //  bot = loadShape("https://assets.scratch.mit.edu/internalapi/asset/638caba865e74c287e8424d3cc1230ad.svg/get");
  bot = loadShape("data/mitsvg.svg");
} 

void draw() {
  shape(bot, 0, 0);
}

2 Likes

Thank you so much! I’ll be sure to try that.

I was looking at your code, and wondered if there was anyway that the file could be downloaded and saved to the computer all in the project instead of being done manually before hand.

?? that question i not understand

but i did a test and uploaded it to my blog and loaded it from there

  bot = loadShape("http://kll.engineering-news.org/kllfusion01/downloads/mitsvg.svg");

and it works,
( but i can not be your file server… )

so i think there might be a problem about the

/get

Sure – you can use

  1. loadXML to get the svg file from a url, then
  2. saveXML to save it to your sketch folder, then
  3. loadShape to load the local SVG file as a PShape.