inkscape_tools
Tools to extract images from SVG files using Inkscape, either to create icons or game sprites
This tool uses Inkscape to prepare assets for Nit applications from a single SVG file.
It selects objects to extract from the SVG file when their id begins with 0
.
It will produce two files:
A Nit source file that declares a single class with an attribute for each selected object. The attribute usually holds a single texture, except if the the id ends with a digit, then it will be an array.
A single PNG image file that contains all the selected objects. With the option
--pow2
, the image size is rounded to the next of 2.
Usage
- Create a new Inkscape document.
- Create objects and set their ids to begin with
0
. - Save the document to
drawing.svg
(for this example), the name of the file is used to name the Nit class. - Execute
bin/svg_to_png_and_nit drawing.svg
- From your code, import the generated source file at
src/drawing.nit
. - Use the class
DrawingImages
and its attributes.
Examples
The minimal test in tests/app/
shows the basic usage of this tool.
The Dino example ../../../../examples/mnit_dino
also uses this tool and is a more complete and practical example.
Content
- inkscape_tools: Tools to extract images from SVG files using Inkscape, either to create icons or game sprites (contrib/inkscape_tools)
- src (contrib/inkscape_tools/src)
- svg_to_icons: Tool to extract PNGs of different resolution from a SVG file (contrib/inkscape_tools/src/svg_to_icons.nit)
- svg_to_png_and_nit: Extract images of objects from an SVG file using Inkscape (contrib/inkscape_tools/src/svg_to_png_and_nit.nit)
- src (contrib/inkscape_tools/src)