contrib/inkscape_tools: update README
[nit.git] / contrib / inkscape_tools / README.md
1 tools to extract images from SVG files: `svg_to_icons` for app icons and `svg_to_png_and_nit` for game sprites
2
3 Both tools use Inkscape for to read the SVG files and extract the images.
4
5 # Create applications icons
6
7 `svg_to_icons` creates icons for Android, iOS and the stores from an SVG file.
8 The icons are generated with the formats and minimum file structure expected by the target platform.
9 This tools works especially well with _app.nit_.
10
11 ## Variations
12
13 The `--android` option generates the folders drawable-hdpi, drawable-xhdpi, etc. with the corresponding icon within.
14
15 The `--ios` option generates many different icon formats for different iOS devices,
16 along with the `Contents.json` file as expected by Xcode.
17
18 ## Usage examples
19
20 See the portable applications at `contrib/tnitter` and `examples/calculator` for practical usages of this tool.
21
22 # Create game sprites and a module to load them
23
24 `svg_to_png_and_nit` prepares sprite assets for Nit applications from a single SVG file.
25 It selects the objects to extract from the SVG file when their id begins with `0`.
26
27 It produces two files:
28
29 * A Nit source file that declares a single class with an attribute for each selected object.
30         The attribute usually holds a single texture, except if the id ends with a digit, then it will be an array.
31
32 * A single PNG image file that contains all the selected objects.
33         With the option `--pow2`, the image size is rounded to the next power of 2.
34
35 ## Usage
36
37 1. Create a new Inkscape document.
38 2. Create objects and set their ids to begin with `0`.
39 3. Save the document to `drawing.svg` (for this example), the name of the file is used to name the Nit class.
40 4. Execute `bin/svg_to_png_and_nit drawing.svg`
41 5. From your code, import the generated source file at `src/drawing.nit`.
42 6. Use the class `DrawingImages` and its attributes.
43
44 ## Examples
45
46 The minimal test in `tests/app/` shows the basic usage of this tool.
47
48 The Dino example `../../../../examples/mnit_dino` also uses this tool and is a more complete and practical example.