Skip to content

Instantly share code, notes, and snippets.

@rraallvv
Created June 19, 2012 16:23
Show Gist options
  • Save rraallvv/2955078 to your computer and use it in GitHub Desktop.
Save rraallvv/2955078 to your computer and use it in GitHub Desktop.
nanosvg description
Project web page http://code.google.com/p/nanosvg/
Overview
Nanosvg is simple stupid SVG parser for game prototypes and the likes. It is not meant to be a full fledged SVG parser, but just the bare bones to read the vector data from a SVG file. The parser supports many of the SVG shapes and most of the path commands (except arc).
If you're looking for nice and free vector drawing program capable of saving SVG files take a look at Inkscape.
Example Usage
// Load
struct SVGPath* plist;
plist = svgParseFromFile("test.svg.");
// Use...
for (SVGPath* it = plist; it; it = it->next)
{
glBegin(it->closed ? GL_LINE_LOOP : GL_LINE_STRIP);
for (int i = 0; i < it->npts; ++i)
glVertex2f(it->pts[i*2], it->pts[i*2+1]);
glEnd();
}
// Delete
svgDelete(plist);
Version 1.0 - Initial version
Version 1.1 - Fixed path parsing, implemented curves, implemented circle.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment