The library suits well for anything from rendering scalable icons in your editor application to prototyping a game.
NanoSVG supports a wide range of SVG features, but something may be missing, feel free to create a pull request!
The shapes in the SVG images are transformed by the viewBox and converted to specified units. That is, you should get the same looking data as your designed in your favorite app.
NanoSVG can return the paths in few different units. For example if you want to render an image, you may choose to get the paths in pixels, or if you are feeding the data into a CNC-cutter, you may want to use millimeters.
The units passed to NanoSVG should be one of: 'px', 'pt', 'pc' 'mm', 'cm', or 'in'. DPI (dots-per-inch) controls how the unit conversion is done.
If you don't know or care about the units stuff, "px" and 96 should get you going.
| Modifier and Type | Field and Description |
|---|---|
| public static final int | |
| public static final int | |
| public static final int | |
| public static final int | |
| public static final int | |
| public static final int | NSVG_FLAGS_VISIBLE
NSVGflags |
| public static final int | |
| public static final int | |
| public static final int | |
| public static final int | NSVG_PAINT_COLOR
NSVGpaintType Enum values: |
| public static final int | NSVG_PAINT_LINEAR_GRADIENT
NSVGpaintType Enum values: |
| public static final int | NSVG_PAINT_NONE
NSVGpaintType Enum values: |
| public static final int | NSVG_PAINT_RADIAL_GRADIENT
NSVGpaintType Enum values: |
| public static final int | NSVG_PAINT_UNDEF
NSVGpaintType Enum values: |
| public static final int | |
| public static final int | |
| public static final int |
| Access | Constructor and Description |
|---|---|
| protected |
| Modifier and Type | Method and Description |
|---|---|
| public static native void | |
| public static native void | |
| public static native long | |
| public static native long | |
| public static native long | |
| public static native void | nnsvgRasterize(long r, long image, float tx, float ty, float scale, long dst, int w, int h, int stride)
Unsafe version of: |
| public static native long | |
| public static void | |
| public static void | |
| public static NSVGPath | |
| public static NSVGImage | nsvgParse(ByteBuffer input, ByteBuffer units, float dpi)
Parses SVG file from a null terminated string, returns SVG image as paths. |
| public static NSVGImage | nsvgParse(CharSequence input, CharSequence units, float dpi)
Parses SVG file from a null terminated string, returns SVG image as paths. |
| public static NSVGImage | nsvgParseFromFile(ByteBuffer filename, ByteBuffer units, float dpi)
Parses SVG file from a file, returns SVG image as paths. |
| public static NSVGImage | nsvgParseFromFile(CharSequence filename, CharSequence units, float dpi)
Parses SVG file from a file, returns SVG image as paths. |
| public static void | nsvgRasterize(long
pointer to rasterizer context r, NSVGImage pointer to image to rasterize image, float image x offset (applied after scaling) tx, float image y offset (applied after scaling) ty, float image scale scale, ByteBuffer pointer to destination image data, 4 bytes per pixel (RGBA) dst, int width of the image to render w, int height of the image to render h, int number of bytes per scaleline in the destination buffer stride)Rasterizes SVG image, returns RGBA image (non-premultiplied alpha). |
| NSVG_CAP_BUTT | back to summary |
|---|---|
| public static final int NSVG_CAP_BUTT NSVGlineCap Enum values: | |
| NSVG_CAP_ROUND | back to summary |
|---|---|
| public static final int NSVG_CAP_ROUND NSVGlineCap Enum values: | |
| NSVG_CAP_SQUARE | back to summary |
|---|---|
| public static final int NSVG_CAP_SQUARE NSVGlineCap Enum values: | |
| NSVG_FILLRULE_EVENODD | back to summary |
|---|---|
| public static final int NSVG_FILLRULE_EVENODD NSVGfillRule Enum values: | |
| NSVG_FILLRULE_NONZERO | back to summary |
|---|---|
| public static final int NSVG_FILLRULE_NONZERO NSVGfillRule Enum values: | |
| NSVG_FLAGS_VISIBLE | back to summary |
|---|---|
| public static final int NSVG_FLAGS_VISIBLE NSVGflags | |
| NSVG_JOIN_BEVEL | back to summary |
|---|---|
| public static final int NSVG_JOIN_BEVEL NSVGlineJoin Enum values: | |
| NSVG_JOIN_MITER | back to summary |
|---|---|
| public static final int NSVG_JOIN_MITER NSVGlineJoin Enum values: | |
| NSVG_JOIN_ROUND | back to summary |
|---|---|
| public static final int NSVG_JOIN_ROUND NSVGlineJoin Enum values: | |
| NSVG_PAINT_COLOR | back to summary |
|---|---|
| public static final int NSVG_PAINT_COLOR NSVGpaintType Enum values: | |
| NSVG_PAINT_LINEAR_GRADIENT | back to summary |
|---|---|
| public static final int NSVG_PAINT_LINEAR_GRADIENT NSVGpaintType Enum values: | |
| NSVG_PAINT_NONE | back to summary |
|---|---|
| public static final int NSVG_PAINT_NONE NSVGpaintType Enum values: | |
| NSVG_PAINT_RADIAL_GRADIENT | back to summary |
|---|---|
| public static final int NSVG_PAINT_RADIAL_GRADIENT NSVGpaintType Enum values: | |
| NSVG_PAINT_UNDEF | back to summary |
|---|---|
| public static final int NSVG_PAINT_UNDEF NSVGpaintType Enum values: | |
| NSVG_SPREAD_PAD | back to summary |
|---|---|
| public static final int NSVG_SPREAD_PAD NSVGspreadType Enum values: | |
| NSVG_SPREAD_REFLECT | back to summary |
|---|---|
| public static final int NSVG_SPREAD_REFLECT NSVGspreadType Enum values: | |
| NSVG_SPREAD_REPEAT | back to summary |
|---|---|
| public static final int NSVG_SPREAD_REPEAT NSVGspreadType Enum values: | |
| NanoSVG | back to summary |
|---|---|
| protected NanoSVG() | |
| nnsvgDelete | back to summary |
|---|---|
| public static native void nnsvgDelete(long image) Unsafe version of: | |
| nnsvgDeleteRasterizer | back to summary |
|---|---|
| public static native void nnsvgDeleteRasterizer(long rasterizer) Unsafe version of: | |
| nnsvgDuplicatePath | back to summary |
|---|---|
| public static native long nnsvgDuplicatePath(long p) Unsafe version of: | |
| nnsvgParse | back to summary |
|---|---|
| public static native long nnsvgParse(long input, long units, float dpi) Unsafe version of: | |
| nnsvgParseFromFile | back to summary |
|---|---|
| public static native long nnsvgParseFromFile(long filename, long units, float dpi) Unsafe version of: | |
| nnsvgRasterize | back to summary |
|---|---|
| public static native void nnsvgRasterize(long r, long image, float tx, float ty, float scale, long dst, int w, int h, int stride) Unsafe version of: | |
| nsvgCreateRasterizer | back to summary |
|---|---|
| public static native long nsvgCreateRasterizer() Allocates rasterizer context.
| |
| nsvgDelete | back to summary |
|---|---|
| public static void nsvgDelete(NSVGImage image) Deletes an image. | |
| nsvgDeleteRasterizer | back to summary |
|---|---|
| public static void nsvgDeleteRasterizer(long rasterizer) Deletes rasterizer context.
| |
| nsvgDuplicatePath | back to summary |
|---|---|
| public static NSVGPath nsvgDuplicatePath(NSVGPath p) Duplicates a path.
| |
| nsvgParse | back to summary |
|---|---|
| public static NSVGImage nsvgParse(ByteBuffer input, ByteBuffer units, float dpi) Parses SVG file from a null terminated string, returns SVG image as paths. Important Note changes the string.
| |
| nsvgParse | back to summary |
|---|---|
| public static NSVGImage nsvgParse(CharSequence input, CharSequence units, float dpi) Parses SVG file from a null terminated string, returns SVG image as paths. Important Note changes the string.
| |
| nsvgParseFromFile | back to summary |
|---|---|
| public static NSVGImage nsvgParseFromFile(ByteBuffer filename, ByteBuffer units, float dpi) Parses SVG file from a file, returns SVG image as paths.
| |
| nsvgParseFromFile | back to summary |
|---|---|
| public static NSVGImage nsvgParseFromFile(CharSequence filename, CharSequence units, float dpi) Parses SVG file from a file, returns SVG image as paths.
| |
| nsvgRasterize | back to summary |
|---|---|
| public static void nsvgRasterize(long r, NSVGImage image, float tx, float ty, float scale, ByteBuffer dst, int w, int h, int stride) Rasterizes SVG image, returns RGBA image (non-premultiplied alpha).
| |