public class NanoSVG
extends java.lang.Object
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 |
|---|---|
static int |
NSVG_CAP_BUTT
NSVGlineCap
|
static int |
NSVG_CAP_ROUND
NSVGlineCap
|
static int |
NSVG_CAP_SQUARE
NSVGlineCap
|
static int |
NSVG_FILLRULE_EVENODD
NSVGfillRule
|
static int |
NSVG_FILLRULE_NONZERO
NSVGfillRule
|
static int |
NSVG_FLAGS_VISIBLE
NSVGflags
|
static int |
NSVG_JOIN_BEVEL
NSVGlineJoin
|
static int |
NSVG_JOIN_MITER
NSVGlineJoin
|
static int |
NSVG_JOIN_ROUND
NSVGlineJoin
|
static int |
NSVG_PAINT_COLOR
NSVGpaintType
|
static int |
NSVG_PAINT_LINEAR_GRADIENT
NSVGpaintType
|
static int |
NSVG_PAINT_NONE
NSVGpaintType
|
static int |
NSVG_PAINT_RADIAL_GRADIENT
NSVGpaintType
|
static int |
NSVG_SPREAD_PAD
NSVGspreadType
|
static int |
NSVG_SPREAD_REFLECT
NSVGspreadType
|
static int |
NSVG_SPREAD_REPEAT
NSVGspreadType
|
| Modifier and Type | Method and Description |
|---|---|
static void |
nnsvgDelete(long image)
Unsafe version of:
Delete |
static void |
nnsvgDeleteRasterizer(long rasterizer)
Unsafe version of:
DeleteRasterizer |
static long |
nnsvgDuplicatePath(long p)
Unsafe version of:
DuplicatePath |
static long |
nnsvgParse(long input,
long units,
float dpi)
Unsafe version of:
Parse |
static long |
nnsvgParseFromFile(long filename,
long units,
float dpi)
Unsafe version of:
ParseFromFile |
static void |
nnsvgRasterize(long r,
long image,
float tx,
float ty,
float scale,
long dst,
int w,
int h,
int stride)
Unsafe version of:
Rasterize |
static long |
nsvgCreateRasterizer()
Allocates rasterizer context.
|
static void |
nsvgDelete(NSVGImage image)
Deletes an image.
|
static void |
nsvgDeleteRasterizer(long rasterizer)
Deletes rasterizer context.
|
static NSVGPath |
nsvgDuplicatePath(NSVGPath p)
Duplicates a path.
|
static NSVGImage |
nsvgParse(java.nio.ByteBuffer input,
java.nio.ByteBuffer units,
float dpi)
Parses SVG file from a null terminated string, returns SVG image as paths.
|
static NSVGImage |
nsvgParse(java.lang.CharSequence input,
java.lang.CharSequence units,
float dpi)
Parses SVG file from a null terminated string, returns SVG image as paths.
|
static NSVGImage |
nsvgParseFromFile(java.nio.ByteBuffer filename,
java.nio.ByteBuffer units,
float dpi)
Parses SVG file from a file, returns SVG image as paths.
|
static NSVGImage |
nsvgParseFromFile(java.lang.CharSequence filename,
java.lang.CharSequence units,
float dpi)
Parses SVG file from a file, returns SVG image as paths.
|
static void |
nsvgRasterize(long r,
NSVGImage image,
float tx,
float ty,
float scale,
java.nio.ByteBuffer dst,
int w,
int h,
int stride)
Rasterizes SVG image, returns RGBA image (non-premultiplied alpha).
|
public static final int NSVG_PAINT_NONE
public static final int NSVG_PAINT_COLOR
public static final int NSVG_PAINT_LINEAR_GRADIENT
public static final int NSVG_PAINT_RADIAL_GRADIENT
public static final int NSVG_SPREAD_PAD
public static final int NSVG_SPREAD_REFLECT
public static final int NSVG_SPREAD_REPEAT
public static final int NSVG_JOIN_MITER
public static final int NSVG_JOIN_ROUND
public static final int NSVG_JOIN_BEVEL
public static final int NSVG_CAP_BUTT
public static final int NSVG_CAP_ROUND
public static final int NSVG_CAP_SQUARE
public static final int NSVG_FILLRULE_NONZERO
public static final int NSVG_FILLRULE_EVENODD
public static final int NSVG_FLAGS_VISIBLE
public static long nnsvgParseFromFile(long filename,
long units,
float dpi)
ParseFromFile@Nullable public static NSVGImage nsvgParseFromFile(java.nio.ByteBuffer filename, java.nio.ByteBuffer units, float dpi)
@Nullable public static NSVGImage nsvgParseFromFile(java.lang.CharSequence filename, java.lang.CharSequence units, float dpi)
public static long nnsvgParse(long input,
long units,
float dpi)
Parse@Nullable public static NSVGImage nsvgParse(java.nio.ByteBuffer input, java.nio.ByteBuffer units, float dpi)
Important note: changes the string.
@Nullable public static NSVGImage nsvgParse(java.lang.CharSequence input, java.lang.CharSequence units, float dpi)
Important note: changes the string.
public static long nnsvgDuplicatePath(long p)
DuplicatePathpublic static void nnsvgDelete(long image)
Deletepublic static void nsvgDelete(NSVGImage image)
public static long nsvgCreateRasterizer()
public static void nnsvgRasterize(long r,
long image,
float tx,
float ty,
float scale,
long dst,
int w,
int h,
int stride)
Rasterizepublic static void nsvgRasterize(long r,
NSVGImage image,
float tx,
float ty,
float scale,
java.nio.ByteBuffer dst,
int w,
int h,
int stride)
r - pointer to rasterizer contextimage - pointer to image to rasterizetx - image x offset (applied after scaling)ty - image y offset (applied after scaling)scale - image scaledst - pointer to destination image data, 4 bytes per pixel (RGBA)w - width of the image to renderh - height of the image to renderstride - number of bytes per scaleline in the destination bufferpublic static void nnsvgDeleteRasterizer(long rasterizer)
DeleteRasterizerpublic static void nsvgDeleteRasterizer(long rasterizer)
rasterizer - the rasterizer context to deleteCopyright LWJGL. All Rights Reserved. License terms.