{"id":13418232,"url":"https://github.com/memononen/nanosvg","last_synced_at":"2025-05-14T05:10:46.784Z","repository":{"id":1058092,"uuid":"13346990","full_name":"memononen/nanosvg","owner":"memononen","description":"Simple stupid SVG parser","archived":false,"fork":false,"pushed_at":"2024-12-19T20:14:31.000Z","size":714,"stargazers_count":1772,"open_issues_count":129,"forks_count":373,"subscribers_count":81,"default_branch":"master","last_synced_at":"2025-04-12T13:50:03.582Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"C","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"zlib","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/memononen.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.txt","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2013-10-05T15:04:21.000Z","updated_at":"2025-04-09T15:07:07.000Z","dependencies_parsed_at":"2023-07-05T15:45:59.421Z","dependency_job_id":"f08d7919-11f6-4357-a1ae-e9ee709c2cac","html_url":"https://github.com/memononen/nanosvg","commit_stats":{"total_commits":111,"total_committers":43,"mean_commits":"2.5813953488372094","dds":0.7747747747747747,"last_synced_commit":"9da543e8329fdd81b64eb48742d8ccb09377aed1"},"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/memononen%2Fnanosvg","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/memononen%2Fnanosvg/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/memononen%2Fnanosvg/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/memononen%2Fnanosvg/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/memononen","download_url":"https://codeload.github.com/memononen/nanosvg/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254076850,"owners_count":22010611,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-07-30T22:00:59.957Z","updated_at":"2025-05-14T05:10:46.744Z","avatar_url":"https://github.com/memononen.png","language":"C","readme":"*This project is not actively maintained.*\n\nNano SVG\n==========\n\n## Parser\n\n![screenshot of some splines rendered with the sample program](/example/screenshot-1.png?raw=true)\n\nNanoSVG is a simple stupid single-header-file SVG parse. The output of the parser is a list of cubic bezier shapes.\n\nThe library suits well for anything from rendering scalable icons in your editor application to prototyping a game.\n\nNanoSVG supports a wide range of SVG features, but something may be missing, feel free to create a pull request!\n\nThe shapes in the SVG images are transformed by the viewBox and converted to specified units.\nThat is, you should get the same looking data as your designed in your favorite app.\n\nNanoSVG can return the paths in few different units. For example if you want to render an image, you may choose\nto get the paths in pixels, or if you are feeding the data into a CNC-cutter, you may want to use millimeters. \n\nThe units passed to NanoSVG should be one of: 'px', 'pt', 'pc' 'mm', 'cm', or 'in'.\nDPI (dots-per-inch) controls how the unit conversion is done.\n\nIf you don't know or care about the units stuff, \"px\" and 96 should get you going.\n\n## Rasterizer\n\n![screenshot of tiger.svg rendered with NanoSVG rasterizer](/example/screenshot-2.png?raw=true)\n\nThe parser library is accompanied with really simpler SVG rasterizer. Currently it only renders flat filled shapes.\n\nThe intended usage for the rasterizer is to for example bake icons of different size into a texture. The rasterizer is not particular fast or accurate, but it's small and packed in one header file.\n\n\n## Example Usage\n\n``` C\n// Load\nstruct NSVGimage* image;\nimage = nsvgParseFromFile(\"test.svg\", \"px\", 96);\nprintf(\"size: %f x %f\\n\", image-\u003ewidth, image-\u003eheight);\n// Use...\nfor (shape = image-\u003eshapes; shape != NULL; shape = shape-\u003enext) {\n\tfor (path = shape-\u003epaths; path != NULL; path = path-\u003enext) {\n\t\tfor (i = 0; i \u003c path-\u003enpts-1; i += 3) {\n\t\t\tfloat* p = \u0026path-\u003epts[i*2];\n\t\t\tdrawCubicBez(p[0],p[1], p[2],p[3], p[4],p[5], p[6],p[7]);\n\t\t}\n\t}\n}\n// Delete\nnsvgDelete(image);\n```\n\n## Using NanoSVG in your project\n\nIn order to use NanoSVG in your own project, just copy nanosvg.h to your project.\nIn one C/C++ define `NANOSVG_IMPLEMENTATION` before including the library to expand the NanoSVG implementation in that file.\nNanoSVG depends on `stdio.h` ,`string.h` and `math.h`, they should be included where the implementation is expanded before including NanoSVG. \n\n``` C\n#include \u003cstdio.h\u003e\n#include \u003cstring.h\u003e\n#include \u003cmath.h\u003e\n#define NANOSVG_IMPLEMENTATION\t// Expands implementation\n#include \"nanosvg.h\"\n```\n\nBy default, NanoSVG parses only the most common colors. In order to get support for full list of [SVG color keywords](http://www.w3.org/TR/SVG11/types.html#ColorKeywords), define `NANOSVG_ALL_COLOR_KEYWORDS` before expanding the implementation.\n\n``` C\n#include \u003cstdio.h\u003e\n#include \u003cstring.h\u003e\n#include \u003cmath.h\u003e\n#define NANOSVG_ALL_COLOR_KEYWORDS\t// Include full list of color keywords.\n#define NANOSVG_IMPLEMENTATION\t\t// Expands implementation\n#include \"nanosvg.h\"\n```\n\nAlternatively, you can install the library using CMake and import it into your project using the standard CMake `find_package` command.\n\n```CMake\nadd_executable(myexe main.c)\n\nfind_package(NanoSVG REQUIRED)\n\ntarget_link_libraries(myexe NanoSVG::nanosvg NanoSVG::nanosvgrast)\n```\n\n## Compiling Example Project\n\nIn order to compile the demo project, your will need to install [GLFW](http://www.glfw.org/) to compile.\n\nNanoSVG demo project uses [premake4](http://industriousone.com/premake) to build platform specific projects, now is good time to install it if you don't have it already. To build the example, navigate into the root folder in your favorite terminal, then:\n\n- *OS X*: `premake4 xcode4`\n- *Windows*: `premake4 vs2010`\n- *Linux*: `premake4 gmake`\n\nSee premake4 documentation for full list of supported build file types. The projects will be created in `build` folder. An example of building and running the example on OS X:\n\n```bash\n$ premake4 gmake\n$ cd build/\n$ make\n$ ./example\n```\n\n# License\n\nThe library is licensed under [zlib license](LICENSE.txt)\n","funding_links":[],"categories":["C","Graphics"],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmemononen%2Fnanosvg","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmemononen%2Fnanosvg","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmemononen%2Fnanosvg/lists"}