Top Description Fields Constructors Methods
org.lwjgl.nanovg

public Class NanoVG

extends Object
Class Inheritance
Imports
javax.annotation.*, java.nio.*, org.lwjgl.system.*

NanoVG is a small antialiased vector graphics rendering library for OpenGL. It has lean API modeled after HTML5 canvas API. It is aimed to be a practical and fun toolset for building scalable user interfaces and visualizations.

Color utils

Colors in NanoVG are stored as unsigned ints in ABGR format.

State Handling

NanoVG contains state which represents how paths will be rendered. The state contains transform, fill and stroke styles, text and font styles, and scissor clipping.

Render styles

Fill and stroke render style can be either a solid color or a paint which is a gradient or a pattern. Solid color is simply defined as a color value, different kinds of paints can be created using LinearGradient, BoxGradient, RadialGradient and ImagePattern.

Current render style can be saved and restored using Save and Restore.

Transforms

The paths, gradients, patterns and scissor region are transformed by an transformation matrix at the time when they are passed to the API. The current transformation matrix is a affine matrix:


[sx kx tx]
[ky sy ty]
[ 0  0  1]

Where: sx,sy define scaling, kx,ky skewing, and tx,ty translation. The last row is assumed to be 0,0,1 and is not stored.

Apart from ResetTransform, each transformation function first creates specific transformation matrix and pre-multiplies the current transformation by it.

Current coordinate system (transformation) can be saved and restored using Save and Restore.

Images

NanoVG allows you to load jpg, png, psd, tga, pic and gif files to be used for rendering. In addition you can upload your own image. The image loading is provided by stb_image.

Paints

NanoVG supports four types of paints: linear gradient, box gradient, radial gradient and image pattern. These can be used as paints for strokes and fills.

Scissoring

Scissoring allows you to clip the rendering into a rectangle. This is useful for various user interface cases like rendering a text edit or a timeline.

Paths

Drawing a new shape starts with BeginPath, it clears all the currently defined paths. Then you define one or more paths and sub-paths which describe the shape. The are functions to draw common shapes like rectangles and circles, and lower level step-by-step functions, which allow to define a path curve by curve.

NanoVG uses even-odd fill rule to draw the shapes. Solid shapes should have counter clockwise winding and holes should have counter clockwise order. To specify winding of a path you can call PathWinding. This is useful especially for the common shapes, which are drawn CCW.

Finally you can fill the path using current fill style by calling Fill, and stroke it with current stroke style by calling Stroke.

The curve segments and sub-paths are transformed by the current transform.

Text

NanoVG allows you to load .ttf files and use the font to render text.

The appearance of the text can be defined by setting the current text style and by specifying the fill color. Common text and font settings such as font size, letter spacing and text align are supported. Font blur allows you to create simple text effects such as drop shadows.

At render time the font face can be set based on the font handles or name.

Font measure functions return values in local space, the calculations are carried in the same resolution as the final rendering. This is done because the text glyph positions are snapped to the nearest pixels sharp rendering.

The local space means that values are not rotated or scale as per the current transformation. For example if you set font size to 12, which would mean that line height is 16, then regardless of the current scaling and rotation, the returned line height is always 16. Some measures may vary because of the scaling since aforementioned pixel snapping.

While this may sound a little odd, the setup allows you to always render the same way regardless of scaling. I.e. following works regardless of scaling:


const char* txt = "Text me up.";
nvgTextBounds(vg, x,y, txt, NULL, bounds);
nvgBeginPath(vg);
nvgRoundedRect(vg, bounds[0],bounds[1], bounds[2]-bounds[0], bounds[3]-bounds[1]);
nvgFill(vg);

Note

currently only solid color fill is supported for text.

Field Summary

Modifier and TypeField and Description
public static final int
NVG_ALIGN_BASELINE

Alignments.

public static final int
NVG_ALIGN_BOTTOM

Alignments.

public static final int
NVG_ALIGN_CENTER

Alignments.

public static final int
NVG_ALIGN_LEFT

Alignments.

public static final int
NVG_ALIGN_MIDDLE

Alignments.

public static final int
NVG_ALIGN_RIGHT

Alignments.

public static final int
NVG_ALIGN_TOP

Alignments.

public static final int
NVG_ATOP

Composite operations.

public static final int
NVG_BEVEL

Line caps and joins.

public static final int
NVG_BUTT

Line caps and joins.

public static final int
NVG_CCW

Winding order.

public static final int
NVG_COPY

Composite operations.

public static final int
NVG_CW

Winding order.

public static final int
NVG_DESTINATION_ATOP

Composite operations.

public static final int
NVG_DESTINATION_IN

Composite operations.

public static final int
NVG_DESTINATION_OUT

Composite operations.

public static final int
NVG_DESTINATION_OVER

Composite operations.

public static final int
NVG_DST_ALPHA

Blend factors.

public static final int
NVG_DST_COLOR

Blend factors.

public static final int
NVG_HOLE

Solidity.

public static final int
NVG_IMAGE_FLIPY

Image flags.

public static final int
public static final int
NVG_IMAGE_NEAREST

Image flags.

public static final int
public static final int
NVG_IMAGE_REPEATX

Image flags.

public static final int
NVG_IMAGE_REPEATY

Image flags.

public static final int
NVG_LIGHTER

Composite operations.

public static final int
NVG_MITER

Line caps and joins.

public static final int
NVG_ONE

Blend factors.

public static final int
public static final int
public static final int
public static final int
public static final float
public static final int
NVG_ROUND

Line caps and joins.

public static final int
NVG_SOLID

Solidity.

public static final int
NVG_SOURCE_IN

Composite operations.

public static final int
NVG_SOURCE_OUT

Composite operations.

public static final int
NVG_SOURCE_OVER

Composite operations.

public static final int
NVG_SQUARE

Line caps and joins.

public static final int
NVG_SRC_ALPHA

Blend factors.

public static final int
NVG_SRC_ALPHA_SATURATE

Blend factors.

public static final int
NVG_SRC_COLOR

Blend factors.

public static final int
NVG_XOR

Composite operations.

public static final int
NVG_ZERO

Blend factors.

pack-priv static final long
pack-priv static final long
pack-priv static final long

Constructor Summary

AccessConstructor and Description
protected

Method Summary

Modifier and TypeMethod and Description
public static native int
nnvgAddFallbackFont(long ctx, long baseFont, long fallbackFont)

Unsafe version of: AddFallbackFont

public static native int
nnvgAddFallbackFontId(long ctx, int baseFont, int fallbackFont)

Unsafe version of: AddFallbackFontId

public static native void
nnvgArc(long ctx, float cx, float cy, float r, float a0, float a1, int dir)

Unsafe version of: Arc

public static native void
nnvgArcTo(long ctx, float x1, float y1, float x2, float y2, float radius)

Unsafe version of: ArcTo

public static native void
nnvgBeginFrame(long ctx, float windowWidth, float windowHeight, float devicePixelRatio)

Unsafe version of: BeginFrame

public static native void
nnvgBeginPath(long ctx)

Unsafe version of: BeginPath

public static native void
nnvgBezierTo(long ctx, float c1x, float c1y, float c2x, float c2y, float x, float y)

Unsafe version of: BezierTo

public static native void
nnvgBoxGradient(long ctx, float x, float y, float w, float h, float r, float f, long icol, long ocol, long __result)

Unsafe version of: BoxGradient

public static native void
nnvgCancelFrame(long ctx)

Unsafe version of: CancelFrame

public static native void
nnvgCircle(long ctx, float cx, float cy, float r)

Unsafe version of: Circle

public static native void
nnvgClosePath(long ctx)

Unsafe version of: ClosePath

public static native int
nnvgCreateFont(long ctx, long name, long filename)

Unsafe version of: CreateFont

public static native int
nnvgCreateFontAtIndex(long ctx, long name, long filename, int fontIndex)

Unsafe version of: CreateFontAtIndex

public static native int
nnvgCreateFontMem(long ctx, long name, long data, int
the font data size, in bytes
ndata
,
int freeData)

Unsafe version of: CreateFontMem

public static native int
nnvgCreateFontMemAtIndex(long ctx, long name, long data, int
the font data size, in bytes
ndata
,
int freeData, int fontIndex)

Unsafe version of: CreateFontMemAtIndex

public static native int
nnvgCreateImage(long ctx, long filename, int imageFlags)

Unsafe version of: CreateImage

public static native int
nnvgCreateImageMem(long ctx, int imageFlags, long data, int
the image data size, in bytes
ndata
)

Unsafe version of: CreateImageMem

public static native int
nnvgCreateImageRGBA(long ctx, int w, int h, int imageFlags, long data)

Unsafe version of: CreateImageRGBA

public static native void
nnvgCurrentTransform(long ctx, long xform)

Unsafe version of: CurrentTransform

public static native void
nnvgCurrentTransform(long ctx, float[] xform)

Array version of: nnvgCurrentTransform

public static native void
nnvgDeleteImage(long ctx, int image)

Unsafe version of: DeleteImage

public static native void
nnvgEllipse(long ctx, float cx, float cy, float rx, float ry)

Unsafe version of: Ellipse

public static native void
nnvgEndFrame(long ctx)

Unsafe version of: EndFrame

public static native void
nnvgFill(long ctx)

Unsafe version of: Fill

public static native void
nnvgFillColor(long ctx, long color)

Unsafe version of: FillColor

public static native void
nnvgFillPaint(long ctx, long paint)

Unsafe version of: FillPaint

public static native int
nnvgFindFont(long ctx, long name)

Unsafe version of: FindFont

public static native void
nnvgFontBlur(long ctx, float blur)

Unsafe version of: FontBlur

public static native void
nnvgFontFace(long ctx, long font)

Unsafe version of: FontFace

public static native void
nnvgFontFaceId(long ctx, int font)

Unsafe version of: FontFaceId

public static native void
nnvgFontSize(long ctx, float size)

Unsafe version of: FontSize

public static native void
nnvgGlobalAlpha(long ctx, float alpha)

Unsafe version of: GlobalAlpha

public static native void
nnvgGlobalCompositeBlendFunc(long ctx, int sfactor, int dfactor)

Unsafe version of: GlobalCompositeBlendFunc

public static native void
nnvgGlobalCompositeBlendFuncSeparate(long ctx, int srcRGB, int dstRGB, int srcAlpha, int dstAlpha)

Unsafe version of: GlobalCompositeBlendFuncSeparate

public static native void
nnvgGlobalCompositeOperation(long ctx, int op)

Unsafe version of: GlobalCompositeOperation

public static native void
nnvgHSL(float h, float s, float l, long __result)

Unsafe version of: HSL

public static native void
nnvgHSLA(float h, float s, float l, byte a, long __result)

Unsafe version of: HSLA

public static native void
nnvgImagePattern(long ctx, float ox, float oy, float ex, float ey, float angle, int image, float alpha, long __result)

Unsafe version of: ImagePattern

public static native void
nnvgImageSize(long ctx, int image, long w, long h)

Unsafe version of: ImageSize

public static native void
nnvgImageSize(long ctx, int image, int[] w, int[] h)

Array version of: nnvgImageSize

public static native void
nnvgIntersectScissor(long ctx, float x, float y, float w, float h)

Unsafe version of: IntersectScissor

public static native void
nnvgLerpRGBA(long c0, long c1, float u, long __result)

Unsafe version of: LerpRGBA

public static native void
nnvgLinearGradient(long ctx, float sx, float sy, float ex, float ey, long icol, long ocol, long __result)

Unsafe version of: LinearGradient

public static native void
nnvgLineCap(long ctx, int cap)

Unsafe version of: LineCap

public static native void
nnvgLineJoin(long ctx, int join)

Unsafe version of: LineJoin

public static native void
nnvgLineTo(long ctx, float x, float y)

Unsafe version of: LineTo

public static native void
nnvgMiterLimit(long ctx, float limit)

Unsafe version of: MiterLimit

public static native void
nnvgMoveTo(long ctx, float x, float y)

Unsafe version of: MoveTo

public static native void
nnvgPathWinding(long ctx, int dir)

Unsafe version of: PathWinding

public static native void
nnvgQuadTo(long ctx, float cx, float cy, float x, float y)

Unsafe version of: QuadTo

public static native void
nnvgRadialGradient(long ctx, float cx, float cy, float inr, float outr, long icol, long ocol, long __result)

Unsafe version of: RadialGradient

public static native void
nnvgRect(long ctx, float x, float y, float w, float h)

Unsafe version of: Rect

public static native void
nnvgReset(long ctx)

Unsafe version of: Reset

public static native void
nnvgResetFallbackFonts(long ctx, long baseFont)

Unsafe version of: ResetFallbackFonts

public static native void
nnvgResetFallbackFontsId(long ctx, int baseFont)

Unsafe version of: ResetFallbackFontsId

public static native void
nnvgResetScissor(long ctx)

Unsafe version of: ResetScissor

public static native void
nnvgResetTransform(long ctx)

Unsafe version of: ResetTransform

public static native void
nnvgRestore(long ctx)

Unsafe version of: Restore

public static native void
nnvgRGB(byte r, byte g, byte b, long __result)

Unsafe version of: RGB

public static native void
nnvgRGBA(byte r, byte g, byte b, byte a, long __result)

Unsafe version of: RGBA

public static native void
nnvgRGBAf(float r, float g, float b, float a, long __result)

Unsafe version of: RGBAf

public static native void
nnvgRGBf(float r, float g, float b, long __result)

Unsafe version of: RGBf

public static native void
nnvgRotate(long ctx, float angle)

Unsafe version of: Rotate

public static native void
nnvgRoundedRect(long ctx, float x, float y, float w, float h, float r)

Unsafe version of: RoundedRect

public static native void
nnvgRoundedRectVarying(long ctx, float x, float y, float w, float h, float radTopLeft, float radTopRight, float radBottomRight, float radBottomLeft)

Unsafe version of: RoundedRectVarying

public static native void
nnvgSave(long ctx)

Unsafe version of: Save

public static native void
nnvgScale(long ctx, float x, float y)

Unsafe version of: Scale

public static native void
nnvgScissor(long ctx, float x, float y, float w, float h)

Unsafe version of: Scissor

public static native void
nnvgShapeAntiAlias(long ctx, int enabled)

Unsafe version of: ShapeAntiAlias

public static native void
nnvgSkewX(long ctx, float angle)

Unsafe version of: SkewX

public static native void
nnvgSkewY(long ctx, float angle)

Unsafe version of: SkewY

public static native void
nnvgStroke(long ctx)

Unsafe version of: Stroke

public static native void
nnvgStrokeColor(long ctx, long color)

Unsafe version of: StrokeColor

public static native void
nnvgStrokePaint(long ctx, long paint)

Unsafe version of: StrokePaint

public static native void
nnvgStrokeWidth(long ctx, float size)

Unsafe version of: StrokeWidth

public static native float
nnvgText(long ctx, float x, float y, long string, long
a pointer to the end of the sub-string to draw, or NULL
end
)

Unsafe version of: Text

public static native void
nnvgTextAlign(long ctx, int align)

Unsafe version of: TextAlign

public static native float
nnvgTextBounds(long ctx, float x, float y, long string, long
a pointer to the end of the sub-string to measure, or NULL
end
,
long bounds)

Unsafe version of: TextBounds

public static native float
nnvgTextBounds(long ctx, float x, float y, long string, long end, float[] bounds)

Array version of: nnvgTextBounds

public static native void
nnvgTextBox(long ctx, float x, float y, float breakRowWidth, long string, long
a pointer to the end of the sub-string to draw, or NULL
end
)

Unsafe version of: TextBox

public static native void
nnvgTextBoxBounds(long ctx, float x, float y, float breakRowWidth, long string, long
a pointer to the end of the sub-string to measure, or NULL
end
,
long bounds)

Unsafe version of: TextBoxBounds

public static native void
nnvgTextBoxBounds(long ctx, float x, float y, float breakRowWidth, long string, long end, float[] bounds)

Array version of: nnvgTextBoxBounds

public static native int
nnvgTextBreakLines(long ctx, long string, long
a pointer to the end of the sub-string to measure, or NULL
end
,
float breakRowWidth, long rows, int
the maximum number of text rows to return
maxRows
)

Unsafe version of: TextBreakLines

public static native int
nnvgTextGlyphPositions(long ctx, float x, float y, long string, long
a pointer to the end of the sub-string to measure, or NULL
end
,
long positions, int
the maximum number of glyph positions to return
maxPositions
)

Unsafe version of: TextGlyphPositions

public static native void
nnvgTextLetterSpacing(long ctx, float spacing)

Unsafe version of: TextLetterSpacing

public static native void
nnvgTextLineHeight(long ctx, float lineHeight)

Unsafe version of: TextLineHeight

public static native void
nnvgTextMetrics(long ctx, long ascender, long descender, long lineh)

Unsafe version of: TextMetrics

public static native void
nnvgTextMetrics(long ctx, float[] ascender, float[] descender, float[] lineh)

Array version of: nnvgTextMetrics

public static native void
nnvgTransform(long ctx, float a, float b, float c, float d, float e, float f)

Unsafe version of: Transform

public static native void
nnvgTransformIdentity(long dst)

Unsafe version of: TransformIdentity

public static native void
nnvgTransformIdentity(float[] dst)

Array version of: nnvgTransformIdentity

public static native int
nnvgTransformInverse(long dst, long src)

Unsafe version of: TransformInverse

public static native int
nnvgTransformInverse(float[] dst, float[] src)

Array version of: nnvgTransformInverse

public static native void
nnvgTransformMultiply(long dst, long src)

Unsafe version of: TransformMultiply

public static native void
nnvgTransformMultiply(float[] dst, float[] src)

Array version of: nnvgTransformMultiply

public static native void
nnvgTransformPoint(long dstx, long dsty, long xform, float srcx, float srcy)

Unsafe version of: TransformPoint

public static native void
nnvgTransformPoint(float[] dstx, float[] dsty, float[] xform, float srcx, float srcy)

Array version of: nnvgTransformPoint

public static native void
nnvgTransformPremultiply(long dst, long src)

Unsafe version of: TransformPremultiply

public static native void
nnvgTransformPremultiply(float[] dst, float[] src)

Array version of: nnvgTransformPremultiply

public static native void
nnvgTransformRotate(long dst, float a)

Unsafe version of: TransformRotate

public static native void
nnvgTransformRotate(float[] dst, float a)

Array version of: nnvgTransformRotate

public static native void
nnvgTransformScale(long dst, float sx, float sy)

Unsafe version of: TransformScale

public static native void
nnvgTransformScale(float[] dst, float sx, float sy)

Array version of: nnvgTransformScale

public static native void
nnvgTransformSkewX(long dst, float a)

Unsafe version of: TransformSkewX

public static native void
nnvgTransformSkewX(float[] dst, float a)

Array version of: nnvgTransformSkewX

public static native void
nnvgTransformSkewY(long dst, float a)

Unsafe version of: TransformSkewY

public static native void
nnvgTransformSkewY(float[] dst, float a)

Array version of: nnvgTransformSkewY

public static native void
nnvgTransformTranslate(long dst, float tx, float ty)

Unsafe version of: TransformTranslate

public static native void
nnvgTransformTranslate(float[] dst, float tx, float ty)

Array version of: nnvgTransformTranslate

public static native void
nnvgTranslate(long ctx, float x, float y)

Unsafe version of: Translate

public static native void
nnvgTransRGBA(long c0, byte a, long __result)

Unsafe version of: TransRGBA

public static native void
nnvgTransRGBAf(long c0, float a, long __result)

Unsafe version of: TransRGBAf

public static native void
nnvgUpdateImage(long ctx, int image, long data)

Unsafe version of: UpdateImage

public static int
nvgAddFallbackFont(long
the NanoVG context
ctx
,
ByteBuffer baseFont, ByteBuffer fallbackFont)

Adds fallback font by name.

public static int
nvgAddFallbackFont(long
the NanoVG context
ctx
,
CharSequence baseFont, CharSequence fallbackFont)

Adds fallback font by name.

public static int
nvgAddFallbackFontId(long
the NanoVG context
ctx
,
int baseFont, int fallbackFont)

Adds fallback font by handle.

public static void
nvgArc(long
the NanoVG context
ctx
,
float
the arc center X axis coordinate
cx
,
float
the arc center Y axis coordinate
cy
,
float
the arc radius
r
,
float
the arc starting angle, in radians
a0
,
float
the arc ending angle, in radians
a1
,
int
the arc direction. One of:
CCWCW
dir
)

Creates new circle arc shaped sub-path.

public static void
nvgArcTo(long
the NanoVG context
ctx
,
float
the first point X axis coordinate
x1
,
float
the first point Y axis coordinate
y1
,
float
the second point X axis coordinate
x2
,
float
the second point Y axis coordinate
y2
,
float
the arc radius, in radians
radius
)

Adds an arc segment at the corner defined by the last path point, and two specified points.

public static void
nvgBeginFrame(long
the NanoVG context
ctx
,
float
the window width
windowWidth
,
float
the window height
windowHeight
,
float
the device pixel ratio
devicePixelRatio
)

Begins drawing a new frame.

public static void
nvgBeginPath(long
the NanoVG context
ctx
)

Clears the current path and sub-paths.

public static void
nvgBezierTo(long
the NanoVG context
ctx
,
float
the first control point X axis coordinate
c1x
,
float
the first control point Y axis coordinate
c1y
,
float
the second control point X axis coordinate
c2x
,
float
the second control point Y axis coordinate
c2y
,
float
the point X axis coordinate
x
,
float
the point Y axis coordinate
y
)

Adds cubic bezier segment from last point in the path via two control points to the specified point.

public static NVGPaint
nvgBoxGradient(long
the NanoVG context
ctx
,
float
the rectangle left coordinate
x
,
float
the rectangle top coordinate
y
,
float
the rectangle width
w
,
float
the rectangle height
h
,
float
the corner radius
r
,
float
the feather value. Feather defines how blurry the border of the rectangle is.
f
,
NVGColor
the inner color
icol
,
NVGColor
the outer color
ocol
,
NVGPaint __result)

Creates and returns a box gradient.

public static void
nvgCancelFrame(long
the NanoVG context
ctx
)

Cancels drawing the current frame.

public static void
nvgCircle(long
the NanoVG context
ctx
,
float
the circle center X axis coordinate
cx
,
float
the circle center Y axis coordinate
cy
,
float
the circle radius
r
)

Creates new circle shaped sub-path.

public static void
nvgClosePath(long
the NanoVG context
ctx
)

Closes current sub-path with a line segment.

public static int

Returns:

a handle to the font
nvgCreateFont
(long
the NanoVG context
ctx
,
ByteBuffer
the font name
name
,
ByteBuffer
the font file name
filename
)

Creates font by loading it from the disk from specified file name.

public static int

Returns:

a handle to the font
nvgCreateFont
(long
the NanoVG context
ctx
,
CharSequence
the font name
name
,
CharSequence
the font file name
filename
)

Creates font by loading it from the disk from specified file name.

public static int

Returns:

a handle to the font
nvgCreateFontAtIndex
(long
the NanoVG context
ctx
,
ByteBuffer
the font name
name
,
ByteBuffer
the font file name
filename
,
int
specifies which font face to load from a .ttf/.ttc file
fontIndex
)

Creates font by loading it from the disk from specified file name.

public static int

Returns:

a handle to the font
nvgCreateFontAtIndex
(long
the NanoVG context
ctx
,
CharSequence
the font name
name
,
CharSequence
the font file name
filename
,
int
specifies which font face to load from a .ttf/.ttc file
fontIndex
)

Creates font by loading it from the disk from specified file name.

public static int

Returns:

a handle to the font
nvgCreateFontMem
(long
the NanoVG context
ctx
,
ByteBuffer
the font name
name
,
ByteBuffer
the font data
data
,
boolean
1 if the font data should be freed automatically, 0 otherwise
freeData
)

Creates font by loading it from the specified memory chunk.

public static int

Returns:

a handle to the font
nvgCreateFontMem
(long
the NanoVG context
ctx
,
CharSequence
the font name
name
,
ByteBuffer
the font data
data
,
boolean
1 if the font data should be freed automatically, 0 otherwise
freeData
)

Creates font by loading it from the specified memory chunk.

public static int

Returns:

a handle to the font
nvgCreateFontMemAtIndex
(long
the NanoVG context
ctx
,
ByteBuffer
the font name
name
,
ByteBuffer
the font data
data
,
boolean
1 if the font data should be freed automatically, 0 otherwise
freeData
,
int
specifies which font face to load from a .ttf/.ttc file
fontIndex
)

Creates font by loading it from the specified memory chunk.

public static int

Returns:

a handle to the font
nvgCreateFontMemAtIndex
(long
the NanoVG context
ctx
,
CharSequence
the font name
name
,
ByteBuffer
the font data
data
,
boolean
1 if the font data should be freed automatically, 0 otherwise
freeData
,
int
specifies which font face to load from a .ttf/.ttc file
fontIndex
)

Creates font by loading it from the specified memory chunk.

public static int

Returns:

a handle to the image
nvgCreateImage
(long
the NanoVG context
ctx
,
ByteBuffer
the image file name
filename
,
int imageFlags)

Creates image by loading it from the disk from specified file name.

public static int

Returns:

a handle to the image
nvgCreateImage
(long
the NanoVG context
ctx
,
CharSequence
the image file name
filename
,
int imageFlags)

Creates image by loading it from the disk from specified file name.

public static int

Returns:

a handle to the image
nvgCreateImageMem
(long
the NanoVG context
ctx
,
int imageFlags, ByteBuffer
the image data
data
)

Creates image by loading it from the specified chunk of memory.

public static int

Returns:

a handle to the image
nvgCreateImageRGBA
(long
the NanoVG context
ctx
,
int
the image width
w
,
int
the image height
h
,
int imageFlags, ByteBuffer
the image data
data
)

Creates image from specified image data.

private static native long
public static void
nvgCurrentTransform(long
the NanoVG context
ctx
,
FloatBuffer
the destination buffer
xform
)

Stores the top part (a-f) of the current transformation matrix in to the specified buffer.

public static void
nvgCurrentTransform(long ctx, float[] xform)

Array version of: CurrentTransform

public static native float
nvgDegToRad(float
the rotation value, in degrees
deg
)

Converts degrees to radians.

public static void
nvgDeleteImage(long
the NanoVG context
ctx
,
int
the image handle to delete
image
)

Deletes created image.

private static native long
public static void
nvgEllipse(long
the NanoVG context
ctx
,
float
the ellipse center X axis coordinate
cx
,
float
the ellipse center Y axis coordinate
cy
,
float
the ellipse X axis radius
rx
,
float
the ellipse Y axis radius
ry
)

Creates new ellipse shaped sub-path.

public static void
nvgEndFrame(long
the NanoVG context
ctx
)

Ends drawing flushing remaining render state.

public static void
nvgFill(long
the NanoVG context
ctx
)

Fills the current path with current fill style.

public static void
nvgFillColor(long
the NanoVG context
ctx
,
NVGColor
the color to set
color
)

Sets current fill style to a solid color.

public static void
nvgFillPaint(long
the NanoVG context
ctx
,
NVGPaint
the paint to set
paint
)

Sets current fill style to a paint, which can be a one of the gradients or a pattern.

public static int
nvgFindFont(long
the NanoVG context
ctx
,
ByteBuffer
the font name
name
)

Finds a loaded font of specified name, and returns handle to it, or -1 if the font is not found.

public static int
nvgFindFont(long
the NanoVG context
ctx
,
CharSequence
the font name
name
)

Finds a loaded font of specified name, and returns handle to it, or -1 if the font is not found.

public static void
nvgFontBlur(long
the NanoVG context
ctx
,
float
the blur amount to set
blur
)

Sets the blur of current text style.

public static void
nvgFontFace(long
the NanoVG context
ctx
,
ByteBuffer
the font name
font
)

Sets the font face based on specified name of current text style.

public static void
nvgFontFace(long
the NanoVG context
ctx
,
CharSequence
the font name
font
)

Sets the font face based on specified name of current text style.

public static void
nvgFontFaceId(long
the NanoVG context
ctx
,
int
the font id
font
)

Sets the font face based on specified id of current text style.

public static void
nvgFontSize(long
the NanoVG context
ctx
,
float
the font size to set
size
)

Sets the font size of current text style.

public static void
nvgGlobalAlpha(long
the NanoVG context
ctx
,
float
the alpha value to set
alpha
)

Sets the transparency applied to all rendered shapes.

public static void
public static void
public static void
nvgGlobalCompositeOperation(long
the NanoVG context
ctx
,
int op)

Sets the composite operation.

public static NVGColor
nvgHSL(float
the hue value
h
,
float
the saturation value
s
,
float
the lightness value
l
,
NVGColor __result)

Returns color value specified by hue, saturation and lightness.

public static NVGColor
nvgHSLA(float
the hue value
h
,
float
the saturation value
s
,
float
the lightness value
l
,
byte
the alpha value
a
,
NVGColor __result)

Returns color value specified by hue, saturation and lightness and alpha.

public static NVGPaint
nvgImagePattern(long
the NanoVG context
ctx
,
float
the image pattern left coordinate
ox
,
float
the image pattern top coordinate
oy
,
float
the image width
ex
,
float
the image height
ey
,
float
the rotation angle around the top-left corner
angle
,
int
the image to render
image
,
float
the alpha value
alpha
,
NVGPaint __result)

Creates and returns an image patter.

public static void
nvgImageSize(long
the NanoVG context
ctx
,
int
the image handle
image
,
IntBuffer
returns the image width
w
,
IntBuffer
returns the image height
h
)

Returns the dimensions of a created image.

public static void
nvgImageSize(long ctx, int image, int[] w, int[] h)

Array version of: ImageSize

private static native long
public static void
nvgIntersectScissor(long
the NanoVG context
ctx
,
float
the rectangle X axis coordinate
x
,
float
the rectangle Y axis coordinate
y
,
float
the rectangle width
w
,
float
the rectangle height
h
)

Intersects current scissor rectangle with the specified rectangle.

public static NVGColor
nvgLerpRGBA(NVGColor
the first color
c0
,
NVGColor
the second color
c1
,
float
the interpolation factor
u
,
NVGColor __result)

Linearly interpolates from color c0 to c1, and returns resulting color value.

public static NVGPaint
nvgLinearGradient(long
the NanoVG context
ctx
,
float
the X axis start coordinate
sx
,
float
the Y axis start coordinate
sy
,
float
the X axis end coordinate
ex
,
float
the Y axis end coordinate
ey
,
NVGColor
the start color
icol
,
NVGColor
the end color
ocol
,
NVGPaint __result)

Creates and returns a linear gradient.

public static void
nvgLineCap(long
the NanoVG context
ctx
,
int
the line cap to set. One of:
BUTTROUNDSQUARE
cap
)

Sets how the end of the line (cap) is drawn.

public static void
nvgLineJoin(long
the NanoVG context
ctx
,
int
the line join to set. One of:
MITERROUNDBEVEL
join
)

Sets how sharp path corners are drawn.

public static void
nvgLineTo(long
the NanoVG context
ctx
,
float
the point X axis coordinate
x
,
float
the point Y axis coordinate
y
)

Adds line segment from the last point in the path to the specified point.

public static void
nvgMiterLimit(long
the NanoVG context
ctx
,
float
the miter limit to set
limit
)

Sets the miter limit of the stroke style.

public static void
nvgMoveTo(long
the NanoVG context
ctx
,
float
the point X axis coordinate
x
,
float
the point Y axis coordinate
y
)

Starts new sub-path with specified point as first point.

public static void
nvgPathWinding(long
the NanoVG context
ctx
,
int
the sub-path winding. One of:
CCWCW
dir
)

Sets the current sub-path winding.

public static void
nvgQuadTo(long
the NanoVG context
ctx
,
float
the control point X axis coordinate
cx
,
float
the control point Y axis coordinate
cy
,
float
the point X axis coordinate
x
,
float
the point Y axis coordinate
y
)

Adds quadratic bezier segment from last point in the path via a control point to the specified point.

public static NVGPaint
nvgRadialGradient(long
the NanoVG context
ctx
,
float
the X axis center coordinate
cx
,
float
the Y axis center coordinate
cy
,
float
the inner radius
inr
,
float
the outer radius
outr
,
NVGColor
the start color
icol
,
NVGColor
the end color
ocol
,
NVGPaint __result)

Creates and returns a radial gradient.

public static native float
nvgRadToDeg(float
the rotation value, in radians
rad
)

Converts radians to degrees.

public static void
nvgRect(long
the NanoVG context
ctx
,
float
the rectangle X axis coordinate
x
,
float
the rectangle Y axis coordinate
y
,
float
the rectangle width
w
,
float
the rectangle height
h
)

Creates new rectangle shaped sub-path.

public static void
nvgReset(long
the NanoVG context
ctx
)

Resets current render state to default values.

public static void
nvgResetFallbackFonts(long
the NanoVG context
ctx
,
ByteBuffer baseFont)

Resets fallback fonts by name.

public static void
nvgResetFallbackFonts(long
the NanoVG context
ctx
,
CharSequence baseFont)

Resets fallback fonts by name.

public static void
nvgResetFallbackFontsId(long
the NanoVG context
ctx
,
int baseFont)

Resets fallback fonts by handle.

public static void
nvgResetScissor(long
the NanoVG context
ctx
)

Resets and disables scissoring.

public static void
nvgResetTransform(long
the NanoVG context
ctx
)

Resets current transform to an identity matrix.

public static void
nvgRestore(long
the NanoVG context
ctx
)

Pops and restores current render state.

public static NVGColor
nvgRGB(byte
the red value
r
,
byte
the green value
g
,
byte
the blue value
b
,
NVGColor __result)

Returns a color value from red, green, blue values.

public static NVGColor
nvgRGBA(byte
the red value
r
,
byte
the green value
g
,
byte
the blue value
b
,
byte
the alpha value
a
,
NVGColor __result)

Returns a color value from red, green, blue and alpha values.

public static NVGColor
nvgRGBAf(float
the red value
r
,
float
the green value
g
,
float
the blue value
b
,
float
the alpha value
a
,
NVGColor __result)

Returns a color value from red, green, blue and alpha values.

public static NVGColor
nvgRGBf(float
the red value
r
,
float
the green value
g
,
float
the blue value
b
,
NVGColor __result)

Returns a color value from red, green, blue values.

public static void
nvgRotate(long
the NanoVG context
ctx
,
float
the rotation angle, in radians
angle
)

Rotates current coordinate system.

public static void
nvgRoundedRect(long
the NanoVG context
ctx
,
float
the rectangle X axis coordinate
x
,
float
the rectangle Y axis coordinate
y
,
float
the rectangle width
w
,
float
the rectangle height
h
,
float
the corner radius
r
)

Creates new rounded rectangle shaped sub-path.

public static void
nvgRoundedRectVarying(long
the NanoVG context
ctx
,
float
the rectangle X axis coordinate
x
,
float
the rectangle Y axis coordinate
y
,
float
the rectangle width
w
,
float
the rectangle height
h
,
float
the top-left corner radius
radTopLeft
,
float
the top-right corner radius
radTopRight
,
float
the bottom-right corner radius
radBottomRight
,
float
the bottom-left corner radius
radBottomLeft
)

Creates new rounded rectangle shaped sub-path with varying radii for each corner.

public static void
nvgSave(long
the NanoVG context
ctx
)

Pushes and saves the current render state into a state stack.

public static void
nvgScale(long
the NanoVG context
ctx
,
float
the X axis scale factor
x
,
float
the Y axis scale factor
y
)

Scales the current coordinate system.

public static void
nvgScissor(long
the NanoVG context
ctx
,
float
the rectangle X axis coordinate
x
,
float
the rectangle Y axis coordinate
y
,
float
the rectangle width
w
,
float
the rectangle height
h
)

Sets the current scissor rectangle.

public static void
nvgShapeAntiAlias(long
the NanoVG context
ctx
,
boolean
the flag to set
enabled
)

Sets whether to draw antialias for Stroke and Fill.

public static void
nvgSkewX(long
the NanoVG context
ctx
,
float
the skew angle, in radians
angle
)

Skews the current coordinate system along X axis.

public static void
nvgSkewY(long
the NanoVG context
ctx
,
float
the skew angle, in radians
angle
)

Skews the current coordinate system along Y axis.

public static void
nvgStroke(long
the NanoVG context
ctx
)

Fills the current path with current stroke style.

public static void
nvgStrokeColor(long
the NanoVG context
ctx
,
NVGColor
the color to set
color
)

Sets current stroke style to a solid color.

public static void
nvgStrokePaint(long
the NanoVG context
ctx
,
NVGPaint
the paint to set
paint
)

Sets current stroke style to a paint, which can be a one of the gradients or a pattern.

public static void
nvgStrokeWidth(long
the NanoVG context
ctx
,
float
the stroke width to set
size
)

Sets the stroke width of the stroke style.

public static float
nvgText(long
the NanoVG context
ctx
,
float
the text X axis coordinate
x
,
float
the text Y axis coordinate
y
,
ByteBuffer
the text string to draw
string
)

Draws text string at specified location.

public static float
nvgText(long
the NanoVG context
ctx
,
float
the text X axis coordinate
x
,
float
the text Y axis coordinate
y
,
CharSequence
the text string to draw
string
)

Draws text string at specified location.

public static void
nvgTextAlign(long
the NanoVG context
ctx
,
int align)

Sets the text align of current text style.

public static float

Returns:

the horizontal advance of the measured text (i.e. where the next character should drawn)
nvgTextBounds
(long
the NanoVG context
ctx
,
float
the text X axis coordinate
x
,
float
the text Y axis coordinate
y
,
ByteBuffer
the text string to measure
string
,
FloatBuffer
returns the bounding box of the text
bounds
)

Measures the specified text string.

public static float

Returns:

the horizontal advance of the measured text (i.e. where the next character should drawn)
nvgTextBounds
(long
the NanoVG context
ctx
,
float
the text X axis coordinate
x
,
float
the text Y axis coordinate
y
,
CharSequence
the text string to measure
string
,
FloatBuffer
returns the bounding box of the text
bounds
)

Measures the specified text string.

public static float
nvgTextBounds(long ctx, float x, float y, ByteBuffer string, float[] bounds)

Array version of: TextBounds

public static float
nvgTextBounds(long ctx, float x, float y, CharSequence string, float[] bounds)

Array version of: TextBounds

public static void
nvgTextBox(long
the NanoVG context
ctx
,
float
the text box X axis coordinate
x
,
float
the text box Y axis coordinate
y
,
float
the maximum row width
breakRowWidth
,
ByteBuffer
the text string to draw
string
)

Draws multi-line text string at specified location wrapped at the specified width.

public static void
nvgTextBox(long
the NanoVG context
ctx
,
float
the text box X axis coordinate
x
,
float
the text box Y axis coordinate
y
,
float
the maximum row width
breakRowWidth
,
CharSequence
the text string to draw
string
)

Draws multi-line text string at specified location wrapped at the specified width.

public static void
nvgTextBoxBounds(long
the NanoVG context
ctx
,
float
the text box X axis coordinate
x
,
float
the text box Y axis coordinate
y
,
float
the maximum row width
breakRowWidth
,
ByteBuffer
the text string to measure
string
,
FloatBuffer
returns the bounding box of the text box
bounds
)

Measures the specified multi-text string.

public static void
nvgTextBoxBounds(long
the NanoVG context
ctx
,
float
the text box X axis coordinate
x
,
float
the text box Y axis coordinate
y
,
float
the maximum row width
breakRowWidth
,
CharSequence
the text string to measure
string
,
FloatBuffer
returns the bounding box of the text box
bounds
)

Measures the specified multi-text string.

public static void
nvgTextBoxBounds(long ctx, float x, float y, float breakRowWidth, ByteBuffer string, float[] bounds)

Array version of: TextBoxBounds

public static void
nvgTextBoxBounds(long ctx, float x, float y, float breakRowWidth, CharSequence string, float[] bounds)

Array version of: TextBoxBounds

public static int
nvgTextBreakLines(long
the NanoVG context
ctx
,
ByteBuffer
the text string to measure
string
,
float
the maximum row width
breakRowWidth
,
NVGTextRow.Buffer
returns the text rows
rows
)

Breaks the specified text into lines.

public static int
nvgTextBreakLines(long
the NanoVG context
ctx
,
CharSequence
the text string to measure
string
,
float
the maximum row width
breakRowWidth
,
NVGTextRow.Buffer
returns the text rows
rows
)

Breaks the specified text into lines.

public static int
nvgTextGlyphPositions(long
the NanoVG context
ctx
,
float
the text X axis coordinate
x
,
float
the text Y axis coordinate
y
,
ByteBuffer
the text string to measure
string
,
NVGGlyphPosition.Buffer
returns the glyph x positions
positions
)

Calculates the glyph x positions of the specified text.

public static int
nvgTextGlyphPositions(long
the NanoVG context
ctx
,
float
the text X axis coordinate
x
,
float
the text Y axis coordinate
y
,
CharSequence
the text string to measure
string
,
NVGGlyphPosition.Buffer
returns the glyph x positions
positions
)

Calculates the glyph x positions of the specified text.

public static void
nvgTextLetterSpacing(long
the NanoVG context
ctx
,
float
the letter spacing amount to set
spacing
)

Sets the letter spacing of current text style.

public static void
nvgTextLineHeight(long
the NanoVG context
ctx
,
float
the line height to set
lineHeight
)

Sets the proportional line height of current text style.

public static void
nvgTextMetrics(long
the NanoVG context
ctx
,
FloatBuffer
the line ascend
ascender
,
FloatBuffer
the line descend
descender
,
FloatBuffer
the line height
lineh
)

Returns the vertical metrics based on the current text style.

public static void
nvgTextMetrics(long ctx, float[] ascender, float[] descender, float[] lineh)

Array version of: TextMetrics

public static void
nvgTransform(long
the NanoVG context
ctx
,
float
the a value
a
,
float
the b value
b
,
float
the c value
c
,
float
the d value
d
,
float
the e value
e
,
float
the f value
f
)

Premultiplies current coordinate system by specified matrix.

public static void
nvgTransformIdentity(FloatBuffer
the destination buffer
dst
)

Sets the transform to identity matrix.

public static void
nvgTransformIdentity(float[] dst)

Array version of: TransformIdentity

public static boolean

Returns:

1 if the inverse could be calculated, else 0
nvgTransformInverse
(FloatBuffer
the destination buffer
dst
,
FloatBuffer
the transformation matrix to inverse
src
)

Sets the destination to inverse of specified transform.

public static boolean
nvgTransformInverse(float[] dst, float[] src)

Array version of: TransformInverse

public static void
nvgTransformMultiply(FloatBuffer
the destination buffer
dst
,
FloatBuffer
the B transformation matrix
src
)

Sets the transform to the result of multiplication of two transforms, of A = A*B.

public static void
nvgTransformMultiply(float[] dst, float[] src)

Array version of: TransformMultiply

public static void
nvgTransformPoint(FloatBuffer
returns the transformed X axis coordinate
dstx
,
FloatBuffer
returns the transformed Y axis coordinate
dsty
,
FloatBuffer
the transformation matrix
xform
,
float
the point X axis coordinate
srcx
,
float
the point Y axis coordinate
srcy
)

Transform a point by given transform.

public static void
nvgTransformPoint(float[] dstx, float[] dsty, float[] xform, float srcx, float srcy)

Array version of: TransformPoint

public static void
nvgTransformPremultiply(FloatBuffer
the destination buffer
dst
,
FloatBuffer
the B transformation matrix
src
)

Sets the transform to the result of multiplication of two transforms, of A = B*A.

public static void
nvgTransformPremultiply(float[] dst, float[] src)

Array version of: TransformPremultiply

public static void
nvgTransformRotate(FloatBuffer
the destination buffer
dst
,
float
the rotation angle, in radians
a
)

Sets the transform to rotate matrix.

public static void
nvgTransformRotate(float[] dst, float a)

Array version of: TransformRotate

public static void
nvgTransformScale(FloatBuffer
the destination buffer
dst
,
float
the X axis scale factor
sx
,
float
the Y axis scale factor
sy
)

Sets the transform to scale matrix.

public static void
nvgTransformScale(float[] dst, float sx, float sy)

Array version of: TransformScale

public static void
nvgTransformSkewX(FloatBuffer
the destination buffer
dst
,
float
the skew angle, in radians
a
)

Sets the transform to skew-x matrix.

public static void
nvgTransformSkewX(float[] dst, float a)

Array version of: TransformSkewX

public static void
nvgTransformSkewY(FloatBuffer
the destination buffer
dst
,
float
the skew angle, in radians
a
)

Sets the transform to skew-y matrix.

public static void
nvgTransformSkewY(float[] dst, float a)

Array version of: TransformSkewY

public static void
nvgTransformTranslate(FloatBuffer
the destination buffer
dst
,
float
the X axis translation amount
tx
,
float
the Y axis translation amount
ty
)

Sets the transform to translation matrix matrix.

public static void
nvgTransformTranslate(float[] dst, float tx, float ty)

Array version of: TransformTranslate

public static void
nvgTranslate(long
the NanoVG context
ctx
,
float
the X axis translation amount
x
,
float
the Y axis translation amount
y
)

Translates current coordinate system.

public static NVGColor
nvgTransRGBA(NVGColor
the color
c0
,
byte
the alpha value
a
,
NVGColor __result)

Sets transparency of a color value.

public static NVGColor
nvgTransRGBAf(NVGColor
the color
c0
,
float
the alpha value
a
,
NVGColor __result)

Sets transparency of a color value.

public static void
nvgUpdateImage(long
the NanoVG context
ctx
,
int
the image handle
image
,
ByteBuffer
the image data
data
)

Updates image data specified by image handle.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait