Class NanoVG



  • public class NanoVG
    extends java.lang.Object
    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.

    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method and Description
      static void nvgArc(long ctx, float cx, float cy, float r, float a0, float a1, int dir)
      Creates new circle arc shaped sub-path.
      static void nvgArcTo(long ctx, float x1, float y1, float x2, float y2, float radius)
      Adds an arc segment at the corner defined by the last path point, and two specified points.
      static void nvgBeginFrame(long ctx, int windowWidth, int windowHeight, float devicePixelRatio)
      Begins drawing a new frame.
      static void nvgBeginPath(long ctx)
      Clears the current path and sub-paths.
      static void nvgBezierTo(long ctx, float c1x, float c1y, float c2x, float c2y, float x, float y)
      Adds cubic bezier segment from last point in the path via two control points to the specified point.
      static NVGPaint nvgBoxGradient(long ctx, float x, float y, float w, float h, float r, float f, NVGColor icol, NVGColor ocol, NVGPaint __result)
      Creates and returns a box gradient.
      static void nvgCancelFrame(long ctx)
      Cancels drawing the current frame.
      static void nvgCircle(long ctx, float cx, float cy, float r)
      Creates new circle shaped sub-path.
      static void nvgClosePath(long ctx)
      Closes current sub-path with a line segment.
      static int nvgCreateFont(long ctx, java.nio.ByteBuffer name, java.nio.ByteBuffer filename)
      Creates font by loading it from the disk from specified file name.
      static int nvgCreateFont(long ctx, java.lang.CharSequence name, java.lang.CharSequence filename)
      Creates font by loading it from the disk from specified file name.
      static int nvgCreateFontMem(long ctx, java.nio.ByteBuffer name, java.nio.ByteBuffer data, int freeData)
      Creates font by loading it from the specified memory chunk.
      static int nvgCreateFontMem(long ctx, java.lang.CharSequence name, java.nio.ByteBuffer data, int freeData)
      Creates font by loading it from the specified memory chunk.
      static int nvgCreateImage(long ctx, java.nio.ByteBuffer filename, int imageFlags)
      Creates image by loading it from the disk from specified file name.
      static int nvgCreateImage(long ctx, java.lang.CharSequence filename, int imageFlags)
      Creates image by loading it from the disk from specified file name.
      static int nvgCreateImageMem(long ctx, int imageFlags, java.nio.ByteBuffer data)
      Creates image by loading it from the specified chunk of memory.
      static int nvgCreateImageRGBA(long ctx, int w, int h, int imageFlags, java.nio.ByteBuffer data)
      Creates image from specified image data.
      static void nvgCurrentTransform(long ctx, float[] xform)
      Array version of: CurrentTransform
      static void nvgCurrentTransform(long ctx, java.nio.FloatBuffer xform)
      Stores the top part (a-f) of the current transformation matrix in to the specified buffer.
      static float nvgDegToRad(float deg)
      Converts degrees to radians.
      static void nvgDeleteImage(long ctx, int image)
      Deletes created image.
      static void nvgEllipse(long ctx, float cx, float cy, float rx, float ry)
      Creates new ellipse shaped sub-path.
      static void nvgEndFrame(long ctx)
      Ends drawing flushing remaining render state.
      static void nvgFill(long ctx)
      Fills the current path with current fill style.
      static void nvgFillColor(long ctx, NVGColor color)
      Sets current fill style to a solid color.
      static void nvgFillPaint(long ctx, NVGPaint paint)
      Sets current fill style to a paint, which can be a one of the gradients or a pattern.
      static int nvgFindFont(long ctx, java.nio.ByteBuffer name)
      Finds a loaded font of specified name, and returns handle to it, or -1 if the font is not found.
      static int nvgFindFont(long ctx, java.lang.CharSequence name)
      Finds a loaded font of specified name, and returns handle to it, or -1 if the font is not found.
      static void nvgFontBlur(long ctx, float blur)
      Sets the blur of current text style.
      static void nvgFontFace(long ctx, java.nio.ByteBuffer font)
      Sets the font face based on specified name of current text style.
      static void nvgFontFace(long ctx, java.lang.CharSequence font)
      Sets the font face based on specified name of current text style.
      static void nvgFontFaceId(long ctx, int font)
      Sets the font face based on specified id of current text style.
      static void nvgFontSize(long ctx, float size)
      Sets the font size of current text style.
      static void nvgGlobalAlpha(long ctx, float alpha)
      Sets the transparency applied to all rendered shapes.
      static NVGColor nvgHSL(float h, float s, float l, NVGColor __result)
      Returns color value specified by hue, saturation and lightness.
      static NVGColor nvgHSLA(float h, float s, float l, byte a, NVGColor __result)
      Returns color value specified by hue, saturation and lightness and alpha.
      static NVGPaint nvgImagePattern(long ctx, float ox, float oy, float ex, float ey, float angle, int image, float alpha, NVGPaint __result)
      Creates and returns an image patter.
      static void nvgImageSize(long ctx, int image, int[] w, int[] h)
      Array version of: ImageSize
      static void nvgImageSize(long ctx, int image, java.nio.IntBuffer w, java.nio.IntBuffer h)
      Returns the dimensions of a created image.
      static void nvgIntersectScissor(long ctx, float x, float y, float w, float h)
      Intersects current scissor rectangle with the specified rectangle.
      static NVGColor nvgLerpRGBA(NVGColor c0, NVGColor c1, float u, NVGColor __result)
      Linearly interpolates from color c0 to c1, and returns resulting color value.
      static NVGPaint nvgLinearGradient(long ctx, float sx, float sy, float ex, float ey, NVGColor icol, NVGColor ocol, NVGPaint __result)
      Creates and returns a linear gradient.
      static void nvgLineCap(long ctx, int cap)
      Sets how the end of the line (cap) is drawn.
      static void nvgLineJoin(long ctx, int join)
      Sets how sharp path corners are drawn.
      static void nvgLineTo(long ctx, float x, float y)
      Adds line segment from the last point in the path to the specified point.
      static void nvgMiterLimit(long ctx, float limit)
      Sets the miter limit of the stroke style.
      static void nvgMoveTo(long ctx, float x, float y)
      Starts new sub-path with specified point as first point.
      static void nvgPathWinding(long ctx, int dir)
      Sets the current sub-path winding.
      static void nvgQuadTo(long ctx, float cx, float cy, float x, float y)
      Adds quadratic bezier segment from last point in the path via a control point to the specified point.
      static NVGPaint nvgRadialGradient(long ctx, float cx, float cy, float inr, float outr, NVGColor icol, NVGColor ocol, NVGPaint __result)
      Creates and returns a radial gradient.
      static float nvgRadToDeg(float rad)
      Converts radians to degrees.
      static void nvgRect(long ctx, float x, float y, float w, float h)
      Creates new rectangle shaped sub-path.
      static void nvgReset(long ctx)
      Resets current render state to default values.
      static void nvgResetScissor(long ctx)
      Resets and disables scissoring.
      static void nvgResetTransform(long ctx)
      Resets current transform to an identity matrix.
      static void nvgRestore(long ctx)
      Pops and restores current render state.
      static NVGColor nvgRGB(byte r, byte g, byte b, NVGColor __result)
      Returns a color value from red, green, blue values.
      static NVGColor nvgRGBA(byte r, byte g, byte b, byte a, NVGColor __result)
      Returns a color value from red, green, blue and alpha values.
      static NVGColor nvgRGBAf(float r, float g, float b, float a, NVGColor __result)
      Returns a color value from red, green, blue and alpha values.
      static NVGColor nvgRGBf(float r, float g, float b, NVGColor __result)
      Returns a color value from red, green, blue values.
      static void nvgRotate(long ctx, float angle)
      Rotates current coordinate system.
      static void nvgRoundedRect(long ctx, float x, float y, float w, float h, float r)
      Creates new rounded rectangle shaped sub-path.
      static void nvgSave(long ctx)
      Pushes and saves the current render state into a state stack.
      static void nvgScale(long ctx, float x, float y)
      Scales the current coordinate system.
      static void nvgScissor(long ctx, float x, float y, float w, float h)
      Sets the current scissor rectangle.
      static void nvgSkewX(long ctx, float angle)
      Skews the current coordinate system along X axis.
      static void nvgSkewY(long ctx, float angle)
      Skews the current coordinate system along Y axis.
      static void nvgStroke(long ctx)
      Fills the current path with current stroke style.
      static void nvgStrokeColor(long ctx, NVGColor color)
      Sets current stroke style to a solid color.
      static void nvgStrokePaint(long ctx, NVGPaint paint)
      Sets current stroke style to a paint, which can be a one of the gradients or a pattern.
      static void nvgStrokeWidth(long ctx, float size)
      Sets the stroke width of the stroke style.
      static float nvgText(long ctx, float x, float y, java.nio.ByteBuffer string, long end)
      Draws text string at specified location.
      static float nvgText(long ctx, float x, float y, java.lang.CharSequence string, long end)
      Draws text string at specified location.
      static void nvgTextAlign(long ctx, int align)
      Sets the text align of current text style.
      static float nvgTextBounds(long ctx, float x, float y, java.nio.ByteBuffer string, long end, float[] bounds)
      Array version of: TextBounds
      static float nvgTextBounds(long ctx, float x, float y, java.nio.ByteBuffer string, long end, java.nio.FloatBuffer bounds)
      Measures the specified text string.
      static float nvgTextBounds(long ctx, float x, float y, java.lang.CharSequence string, long end, float[] bounds)
      Array version of: TextBounds
      static float nvgTextBounds(long ctx, float x, float y, java.lang.CharSequence string, long end, java.nio.FloatBuffer bounds)
      Measures the specified text string.
      static void nvgTextBox(long ctx, float x, float y, float breakRowWidth, java.nio.ByteBuffer string, long end)
      Draws multi-line text string at specified location wrapped at the specified width.
      static void nvgTextBox(long ctx, float x, float y, float breakRowWidth, java.lang.CharSequence string, long end)
      Draws multi-line text string at specified location wrapped at the specified width.
      static void nvgTextBoxBounds(long ctx, float x, float y, float breakRowWidth, java.nio.ByteBuffer string, long end, float[] bounds)
      Array version of: TextBoxBounds
      static void nvgTextBoxBounds(long ctx, float x, float y, float breakRowWidth, java.nio.ByteBuffer string, long end, java.nio.FloatBuffer bounds)
      Measures the specified multi-text string.
      static void nvgTextBoxBounds(long ctx, float x, float y, float breakRowWidth, java.lang.CharSequence string, long end, float[] bounds)
      Array version of: TextBoxBounds
      static void nvgTextBoxBounds(long ctx, float x, float y, float breakRowWidth, java.lang.CharSequence string, long end, java.nio.FloatBuffer bounds)
      Measures the specified multi-text string.
      static int nvgTextBreakLines(long ctx, java.nio.ByteBuffer string, long end, float breakRowWidth, NVGTextRow.Buffer rows)
      Breaks the specified text into lines.
      static int nvgTextBreakLines(long ctx, java.lang.CharSequence string, long end, float breakRowWidth, NVGTextRow.Buffer rows)
      Breaks the specified text into lines.
      static int nvgTextGlyphPositions(long ctx, float x, float y, java.nio.ByteBuffer string, long end, NVGGlyphPosition.Buffer positions)
      Calculates the glyph x positions of the specified text.
      static int nvgTextGlyphPositions(long ctx, float x, float y, java.lang.CharSequence string, long end, NVGGlyphPosition.Buffer positions)
      Calculates the glyph x positions of the specified text.
      static void nvgTextLetterSpacing(long ctx, float spacing)
      Sets the letter spacing of current text style.
      static void nvgTextLineHeight(long ctx, float lineHeight)
      Sets the proportional line height of current text style.
      static void nvgTextMetrics(long ctx, float[] ascender, float[] descender, float[] lineh)
      Array version of: TextMetrics
      static void nvgTextMetrics(long ctx, java.nio.FloatBuffer ascender, java.nio.FloatBuffer descender, java.nio.FloatBuffer lineh)
      Returns the vertical metrics based on the current text style.
      static void nvgTransform(long ctx, float a, float b, float c, float d, float e, float f)
      Premultiplies current coordinate system by specified matrix.
      static void nvgTransformIdentity(float[] dst)
      Array version of: TransformIdentity
      static void nvgTransformIdentity(java.nio.FloatBuffer dst)
      Sets the transform to identity matrix.
      static int nvgTransformInverse(float[] dst, float[] src)
      Array version of: TransformInverse
      static int nvgTransformInverse(java.nio.FloatBuffer dst, java.nio.FloatBuffer src)
      Sets the destination to inverse of specified transform.
      static void nvgTransformMultiply(float[] dst, float[] src)
      Array version of: TransformMultiply
      static void nvgTransformMultiply(java.nio.FloatBuffer dst, java.nio.FloatBuffer src)
      Sets the transform to the result of multiplication of two transforms, of A = A*B.
      static void nvgTransformPoint(float[] dstx, float[] dsty, float[] xform, float srcx, float srcy)
      Array version of: TransformPoint
      static void nvgTransformPoint(java.nio.FloatBuffer dstx, java.nio.FloatBuffer dsty, java.nio.FloatBuffer xform, float srcx, float srcy)
      Transform a point by given transform.
      static void nvgTransformPremultiply(float[] dst, float[] src)
      Array version of: TransformPremultiply
      static void nvgTransformPremultiply(java.nio.FloatBuffer dst, java.nio.FloatBuffer src)
      Sets the transform to the result of multiplication of two transforms, of A = B*A.
      static void nvgTransformRotate(float[] dst, float a)
      Array version of: TransformRotate
      static void nvgTransformRotate(java.nio.FloatBuffer dst, float a)
      Sets the transform to rotate matrix.
      static void nvgTransformScale(float[] dst, float sx, float sy)
      Array version of: TransformScale
      static void nvgTransformScale(java.nio.FloatBuffer dst, float sx, float sy)
      Sets the transform to scale matrix.
      static void nvgTransformSkewX(float[] dst, float a)
      Array version of: TransformSkewX
      static void nvgTransformSkewX(java.nio.FloatBuffer dst, float a)
      Sets the transform to skew-x matrix.
      static void nvgTransformSkewY(float[] dst, float a)
      Array version of: TransformSkewY
      static void nvgTransformSkewY(java.nio.FloatBuffer dst, float a)
      Sets the transform to skew-y matrix.
      static void nvgTransformTranslate(float[] dst, float tx, float ty)
      Array version of: TransformTranslate
      static void nvgTransformTranslate(java.nio.FloatBuffer dst, float tx, float ty)
      Sets the transform to translation matrix matrix.
      static void nvgTranslate(long ctx, float x, float y)
      Translates current coordinate system.
      static NVGColor nvgTransRGBA(NVGColor c0, byte a, NVGColor __result)
      Sets transparency of a color value.
      static NVGColor nvgTransRGBAf(NVGColor c0, float a, NVGColor __result)
      Sets transparency of a color value.
      static void nvgUpdateImage(long ctx, int image, java.nio.ByteBuffer data)
      Updates image data specified by image handle.
      • Methods inherited from class java.lang.Object

        equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • NVG_ALIGN_LEFT

        public static final int NVG_ALIGN_LEFT
        Default, align text horizontally to left.
        See Also:
        Constant Field Values
      • NVG_ALIGN_CENTER

        public static final int NVG_ALIGN_CENTER
        Align text horizontally to center.
        See Also:
        Constant Field Values
      • NVG_ALIGN_RIGHT

        public static final int NVG_ALIGN_RIGHT
        Align text horizontally to right.
        See Also:
        Constant Field Values
      • NVG_ALIGN_TOP

        public static final int NVG_ALIGN_TOP
        Align text vertically to top.
        See Also:
        Constant Field Values
      • NVG_ALIGN_MIDDLE

        public static final int NVG_ALIGN_MIDDLE
        Align text vertically to middle.
        See Also:
        Constant Field Values
      • NVG_ALIGN_BOTTOM

        public static final int NVG_ALIGN_BOTTOM
        Align text vertically to bottom.
        See Also:
        Constant Field Values
      • NVG_ALIGN_BASELINE

        public static final int NVG_ALIGN_BASELINE
        Default, align text vertically to baseline.
        See Also:
        Constant Field Values
      • NVG_IMAGE_GENERATE_MIPMAPS

        public static final int NVG_IMAGE_GENERATE_MIPMAPS
        Generate mipmaps during creation of the image.
        See Also:
        Constant Field Values
      • NVG_IMAGE_REPEATX

        public static final int NVG_IMAGE_REPEATX
        Repeat image in X direction.
        See Also:
        Constant Field Values
      • NVG_IMAGE_REPEATY

        public static final int NVG_IMAGE_REPEATY
        Repeat image in Y direction.
        See Also:
        Constant Field Values
      • NVG_IMAGE_FLIPY

        public static final int NVG_IMAGE_FLIPY
        Flips (inverses) image in Y direction when rendered.
        See Also:
        Constant Field Values
      • NVG_IMAGE_PREMULTIPLIED

        public static final int NVG_IMAGE_PREMULTIPLIED
        Image data has premultiplied alpha.
        See Also:
        Constant Field Values
    • Method Detail

      • nvgBeginFrame

        public static void nvgBeginFrame(long ctx,
                                         int windowWidth,
                                         int windowHeight,
                                         float devicePixelRatio)
        Begins drawing a new frame.

        Calls to nanovg drawing API should be wrapped in BeginFrame & EndFrame. BeginFrame defines the size of the window to render to in relation currently set viewport (i.e. glViewport on GL backends). Device pixel ration allows to control the rendering on Hi-DPI devices. For example, GLFW returns two dimension for an opened window: window size and frame buffer size. In that case you would set windowWidth/Height to the window size devicePixelRatio to: frameBufferWidth / windowWidth.

        Parameters:
        ctx - the NanoVG context
        windowWidth - the window width
        windowHeight - the window height
        devicePixelRatio - the device pixel ratio
      • nvgCancelFrame

        public static void nvgCancelFrame(long ctx)
        Cancels drawing the current frame.
        Parameters:
        ctx - the NanoVG context
      • nvgEndFrame

        public static void nvgEndFrame(long ctx)
        Ends drawing flushing remaining render state.
        Parameters:
        ctx - the NanoVG context
      • nvgRGB

        public static NVGColor nvgRGB(byte r,
                                      byte g,
                                      byte b,
                                      NVGColor __result)
        Returns a color value from red, green, blue values. Alpha will be set to 255 (1.0f).
        Parameters:
        r - the red value
        g - the green value
        b - the blue value
      • nvgRGBf

        public static NVGColor nvgRGBf(float r,
                                       float g,
                                       float b,
                                       NVGColor __result)
        Returns a color value from red, green, blue values. Alpha will be set to 1.0f.
        Parameters:
        r - the red value
        g - the green value
        b - the blue value
      • nvgRGBA

        public static NVGColor nvgRGBA(byte r,
                                       byte g,
                                       byte b,
                                       byte a,
                                       NVGColor __result)
        Returns a color value from red, green, blue and alpha values.
        Parameters:
        r - the red value
        g - the green value
        b - the blue value
        a - the alpha value
      • nvgRGBAf

        public static NVGColor nvgRGBAf(float r,
                                        float g,
                                        float b,
                                        float a,
                                        NVGColor __result)
        Returns a color value from red, green, blue and alpha values.
        Parameters:
        r - the red value
        g - the green value
        b - the blue value
        a - the alpha value
      • nvgLerpRGBA

        public static NVGColor nvgLerpRGBA(NVGColor c0,
                                           NVGColor c1,
                                           float u,
                                           NVGColor __result)
        Linearly interpolates from color c0 to c1, and returns resulting color value.
        Parameters:
        c0 - the first color
        c1 - the second color
        u - the interpolation factor
      • nvgTransRGBA

        public static NVGColor nvgTransRGBA(NVGColor c0,
                                            byte a,
                                            NVGColor __result)
        Sets transparency of a color value.
        Parameters:
        c0 - the color
        a - the alpha value
      • nvgTransRGBAf

        public static NVGColor nvgTransRGBAf(NVGColor c0,
                                             float a,
                                             NVGColor __result)
        Sets transparency of a color value.
        Parameters:
        c0 - the color
        a - the alpha value
      • nvgHSL

        public static NVGColor nvgHSL(float h,
                                      float s,
                                      float l,
                                      NVGColor __result)
        Returns color value specified by hue, saturation and lightness.

        HSL values are all in range [0..1], alpha will be set to 255.

        Parameters:
        h - the hue value
        s - the saturation value
        l - the lightness value
      • nvgHSLA

        public static NVGColor nvgHSLA(float h,
                                       float s,
                                       float l,
                                       byte a,
                                       NVGColor __result)
        Returns color value specified by hue, saturation and lightness and alpha.

        HSL values are all in range [0..1], alpha in range [0..255]

        Parameters:
        h - the hue value
        s - the saturation value
        l - the lightness value
        a - the alpha value
      • nvgSave

        public static void nvgSave(long ctx)
        Pushes and saves the current render state into a state stack. A matching Restore must be used to restore the state.
        Parameters:
        ctx - the NanoVG context
      • nvgRestore

        public static void nvgRestore(long ctx)
        Pops and restores current render state.
        Parameters:
        ctx - the NanoVG context
      • nvgReset

        public static void nvgReset(long ctx)
        Resets current render state to default values. Does not affect the render state stack.
        Parameters:
        ctx - the NanoVG context
      • nvgStrokeColor

        public static void nvgStrokeColor(long ctx,
                                          NVGColor color)
        Sets current stroke style to a solid color.
        Parameters:
        ctx - the NanoVG context
        color - the color to set
      • nvgStrokePaint

        public static void nvgStrokePaint(long ctx,
                                          NVGPaint paint)
        Sets current stroke style to a paint, which can be a one of the gradients or a pattern.
        Parameters:
        ctx - the NanoVG context
        paint - the paint to set
      • nvgFillColor

        public static void nvgFillColor(long ctx,
                                        NVGColor color)
        Sets current fill style to a solid color.
        Parameters:
        ctx - the NanoVG context
        color - the color to set
      • nvgFillPaint

        public static void nvgFillPaint(long ctx,
                                        NVGPaint paint)
        Sets current fill style to a paint, which can be a one of the gradients or a pattern.
        Parameters:
        ctx - the NanoVG context
        paint - the paint to set
      • nvgMiterLimit

        public static void nvgMiterLimit(long ctx,
                                         float limit)
        Sets the miter limit of the stroke style. Miter limit controls when a sharp corner is beveled.
        Parameters:
        ctx - the NanoVG context
        limit - the miter limit to set
      • nvgStrokeWidth

        public static void nvgStrokeWidth(long ctx,
                                          float size)
        Sets the stroke width of the stroke style.
        Parameters:
        ctx - the NanoVG context
        size - the stroke width to set
      • nvgLineCap

        public static void nvgLineCap(long ctx,
                                      int cap)
        Sets how the end of the line (cap) is drawn.

        The default line cap is BUTT.

        Parameters:
        ctx - the NanoVG context
        cap - the line cap to set. One of:
        BUTTROUNDSQUARE
      • nvgLineJoin

        public static void nvgLineJoin(long ctx,
                                       int join)
        Sets how sharp path corners are drawn.

        The default line join is MITER.

        Parameters:
        ctx - the NanoVG context
        join - the line join to set. One of:
        MITERROUNDBEVEL
      • nvgGlobalAlpha

        public static void nvgGlobalAlpha(long ctx,
                                          float alpha)
        Sets the transparency applied to all rendered shapes.

        Already transparent paths will get proportionally more transparent as well.

        Parameters:
        ctx - the NanoVG context
        alpha - the alpha value to set
      • nvgResetTransform

        public static void nvgResetTransform(long ctx)
        Resets current transform to an identity matrix.
        Parameters:
        ctx - the NanoVG context
      • nvgTransform

        public static void nvgTransform(long ctx,
                                        float a,
                                        float b,
                                        float c,
                                        float d,
                                        float e,
                                        float f)
        Premultiplies current coordinate system by specified matrix. The parameters are interpreted as matrix as follows:
        [a c e]
        [b d f]
        [0 0 1]
        Parameters:
        ctx - the NanoVG context
        a - the a value
        b - the b value
        c - the c value
        d - the d value
        e - the e value
        f - the f value
      • nvgTranslate

        public static void nvgTranslate(long ctx,
                                        float x,
                                        float y)
        Translates current coordinate system.
        Parameters:
        ctx - the NanoVG context
        x - the X axis translation amount
        y - the Y axis translation amount
      • nvgRotate

        public static void nvgRotate(long ctx,
                                     float angle)
        Rotates current coordinate system.
        Parameters:
        ctx - the NanoVG context
        angle - the rotation angle, in radians
      • nvgSkewX

        public static void nvgSkewX(long ctx,
                                    float angle)
        Skews the current coordinate system along X axis.
        Parameters:
        ctx - the NanoVG context
        angle - the skew angle, in radians
      • nvgSkewY

        public static void nvgSkewY(long ctx,
                                    float angle)
        Skews the current coordinate system along Y axis.
        Parameters:
        ctx - the NanoVG context
        angle - the skew angle, in radians
      • nvgScale

        public static void nvgScale(long ctx,
                                    float x,
                                    float y)
        Scales the current coordinate system.
        Parameters:
        ctx - the NanoVG context
        x - the X axis scale factor
        y - the Y axis scale factor
      • nvgCurrentTransform

        public static void nvgCurrentTransform(long ctx,
                                               java.nio.FloatBuffer xform)
        Stores the top part (a-f) of the current transformation matrix in to the specified buffer.
        [a c e]
        [b d f]
        [0 0 1]

        There should be space for 6 floats in the return buffer for the values a-f.

        Parameters:
        ctx - the NanoVG context
        xform - the destination buffer
      • nvgTransformIdentity

        public static void nvgTransformIdentity(java.nio.FloatBuffer dst)
        Sets the transform to identity matrix.
        Parameters:
        dst - the destination buffer
      • nvgTransformTranslate

        public static void nvgTransformTranslate(java.nio.FloatBuffer dst,
                                                 float tx,
                                                 float ty)
        Sets the transform to translation matrix matrix.
        Parameters:
        dst - the destination buffer
        tx - the X axis translation amount
        ty - the Y axis translation amount
      • nvgTransformScale

        public static void nvgTransformScale(java.nio.FloatBuffer dst,
                                             float sx,
                                             float sy)
        Sets the transform to scale matrix.
        Parameters:
        dst - the destination buffer
        sx - the X axis scale factor
        sy - the Y axis scale factor
      • nvgTransformRotate

        public static void nvgTransformRotate(java.nio.FloatBuffer dst,
                                              float a)
        Sets the transform to rotate matrix.
        Parameters:
        dst - the destination buffer
        a - the rotation angle, in radians
      • nvgTransformSkewX

        public static void nvgTransformSkewX(java.nio.FloatBuffer dst,
                                             float a)
        Sets the transform to skew-x matrix.
        Parameters:
        dst - the destination buffer
        a - the skew angle, in radians
      • nvgTransformSkewY

        public static void nvgTransformSkewY(java.nio.FloatBuffer dst,
                                             float a)
        Sets the transform to skew-y matrix.
        Parameters:
        dst - the destination buffer
        a - the skew angle, in radians
      • nvgTransformMultiply

        public static void nvgTransformMultiply(java.nio.FloatBuffer dst,
                                                java.nio.FloatBuffer src)
        Sets the transform to the result of multiplication of two transforms, of A = A*B.
        Parameters:
        dst - the destination buffer
        src - the B transformation matrix
      • nvgTransformPremultiply

        public static void nvgTransformPremultiply(java.nio.FloatBuffer dst,
                                                   java.nio.FloatBuffer src)
        Sets the transform to the result of multiplication of two transforms, of A = B*A.
        Parameters:
        dst - the destination buffer
        src - the B transformation matrix
      • nvgTransformInverse

        public static int nvgTransformInverse(java.nio.FloatBuffer dst,
                                              java.nio.FloatBuffer src)
        Sets the destination to inverse of specified transform.
        Parameters:
        dst - the destination buffer
        src - the transformation matrix to inverse
        Returns:
        1 if the inverse could be calculated, else 0
      • nvgTransformPoint

        public static void nvgTransformPoint(java.nio.FloatBuffer dstx,
                                             java.nio.FloatBuffer dsty,
                                             java.nio.FloatBuffer xform,
                                             float srcx,
                                             float srcy)
        Transform a point by given transform.
        Parameters:
        dstx - returns the transformed X axis coordinate
        dsty - returns the transformed Y axis coordinate
        xform - the transformation matrix
        srcx - the point X axis coordinate
        srcy - the point Y axis coordinate
      • nvgDegToRad

        public static float nvgDegToRad(float deg)
        Converts degrees to radians.
        Parameters:
        deg - the rotation value, in degrees
      • nvgRadToDeg

        public static float nvgRadToDeg(float rad)
        Converts radians to degrees.
        Parameters:
        rad - the rotation value, in radians
      • nvgCreateImage

        public static int nvgCreateImage(long ctx,
                                         java.nio.ByteBuffer filename,
                                         int imageFlags)
        Creates image by loading it from the disk from specified file name.
        Parameters:
        ctx - the NanoVG context
        filename - the image file name
        imageFlags - the image flags. One of:
        IMAGE_GENERATE_MIPMAPSIMAGE_REPEATXIMAGE_REPEATYIMAGE_FLIPYIMAGE_PREMULTIPLIED
        Returns:
        a handle to the image
      • nvgCreateImage

        public static int nvgCreateImage(long ctx,
                                         java.lang.CharSequence filename,
                                         int imageFlags)
        Creates image by loading it from the disk from specified file name.
        Parameters:
        ctx - the NanoVG context
        filename - the image file name
        imageFlags - the image flags. One of:
        IMAGE_GENERATE_MIPMAPSIMAGE_REPEATXIMAGE_REPEATYIMAGE_FLIPYIMAGE_PREMULTIPLIED
        Returns:
        a handle to the image
      • nvgUpdateImage

        public static void nvgUpdateImage(long ctx,
                                          int image,
                                          java.nio.ByteBuffer data)
        Updates image data specified by image handle.
        Parameters:
        ctx - the NanoVG context
        image - the image handle
        data - the image data
      • nvgImageSize

        public static void nvgImageSize(long ctx,
                                        int image,
                                        java.nio.IntBuffer w,
                                        java.nio.IntBuffer h)
        Returns the dimensions of a created image.
        Parameters:
        ctx - the NanoVG context
        image - the image handle
        w - returns the image width
        h - returns the image height
      • nvgDeleteImage

        public static void nvgDeleteImage(long ctx,
                                          int image)
        Deletes created image.
        Parameters:
        ctx - the NanoVG context
        image - the image handle to delete
      • nvgLinearGradient

        public static NVGPaint nvgLinearGradient(long ctx,
                                                 float sx,
                                                 float sy,
                                                 float ex,
                                                 float ey,
                                                 NVGColor icol,
                                                 NVGColor ocol,
                                                 NVGPaint __result)
        Creates and returns a linear gradient.

        The gradient is transformed by the current transform when it is passed to FillPaint or StrokePaint.

        Parameters:
        ctx - the NanoVG context
        sx - the X axis start coordinate
        sy - the Y axis start coordinate
        ex - the X axis end coordinate
        ey - the Y axis end coordinate
        icol - the start color
        ocol - the end color
      • nvgBoxGradient

        public static NVGPaint nvgBoxGradient(long ctx,
                                              float x,
                                              float y,
                                              float w,
                                              float h,
                                              float r,
                                              float f,
                                              NVGColor icol,
                                              NVGColor ocol,
                                              NVGPaint __result)
        Creates and returns a box gradient. Box gradient is a feathered rounded rectangle, it is useful for rendering drop shadows or highlights for boxes.

        The gradient is transformed by the current transform when it is passed to FillPaint or StrokePaint.

        Parameters:
        ctx - the NanoVG context
        x - the rectangle left coordinate
        y - the rectangle top coordinate
        w - the rectangle width
        h - the rectangle height
        r - the corner radius
        f - the feather value. Feather defines how blurry the border of the rectangle is.
        icol - the inner color
        ocol - the outer color
      • nvgRadialGradient

        public static NVGPaint nvgRadialGradient(long ctx,
                                                 float cx,
                                                 float cy,
                                                 float inr,
                                                 float outr,
                                                 NVGColor icol,
                                                 NVGColor ocol,
                                                 NVGPaint __result)
        Creates and returns a radial gradient.

        The gradient is transformed by the current transform when it is passed to FillPaint or StrokePaint.

        Parameters:
        ctx - the NanoVG context
        cx - the X axis center coordinate
        cy - the Y axis center coordinate
        inr - the inner radius
        outr - the outer radius
        icol - the start color
        ocol - the end color
      • nvgImagePattern

        public static NVGPaint nvgImagePattern(long ctx,
                                               float ox,
                                               float oy,
                                               float ex,
                                               float ey,
                                               float angle,
                                               int image,
                                               float alpha,
                                               NVGPaint __result)
        Creates and returns an image patter.

        The gradient is transformed by the current transform when it is passed to FillPaint or StrokePaint.

        Parameters:
        ctx - the NanoVG context
        ox - the image pattern left coordinate
        oy - the image pattern top coordinate
        ex - the image width
        ey - the image height
        angle - the rotation angle around the top-left corner
        image - the image to render
        alpha - the alpha value
      • nvgScissor

        public static void nvgScissor(long ctx,
                                      float x,
                                      float y,
                                      float w,
                                      float h)
        Sets the current scissor rectangle.

        The scissor rectangle is transformed by the current transform.

        Parameters:
        ctx - the NanoVG context
        x - the rectangle X axis coordinate
        y - the rectangle Y axis coordinate
        w - the rectangle width
        h - the rectangle height
      • nvgIntersectScissor

        public static void nvgIntersectScissor(long ctx,
                                               float x,
                                               float y,
                                               float w,
                                               float h)
        Intersects current scissor rectangle with the specified rectangle.

        The scissor rectangle is transformed by the current transform.

        Note: in case the rotation of previous scissor rect differs from the current one, the intersection will be done between the specified rectangle and the previous scissor rectangle transformed in the current transform space. The resulting shape is always rectangle.

        Parameters:
        ctx - the NanoVG context
        x - the rectangle X axis coordinate
        y - the rectangle Y axis coordinate
        w - the rectangle width
        h - the rectangle height
      • nvgResetScissor

        public static void nvgResetScissor(long ctx)
        Resets and disables scissoring.
        Parameters:
        ctx - the NanoVG context
      • nvgBeginPath

        public static void nvgBeginPath(long ctx)
        Clears the current path and sub-paths.
        Parameters:
        ctx - the NanoVG context
      • nvgMoveTo

        public static void nvgMoveTo(long ctx,
                                     float x,
                                     float y)
        Starts new sub-path with specified point as first point.
        Parameters:
        ctx - the NanoVG context
        x - the point X axis coordinate
        y - the point Y axis coordinate
      • nvgLineTo

        public static void nvgLineTo(long ctx,
                                     float x,
                                     float y)
        Adds line segment from the last point in the path to the specified point.
        Parameters:
        ctx - the NanoVG context
        x - the point X axis coordinate
        y - the point Y axis coordinate
      • nvgBezierTo

        public static void nvgBezierTo(long ctx,
                                       float c1x,
                                       float c1y,
                                       float c2x,
                                       float c2y,
                                       float x,
                                       float y)
        Adds cubic bezier segment from last point in the path via two control points to the specified point.
        Parameters:
        ctx - the NanoVG context
        c1x - the first control point X axis coordinate
        c1y - the first control point Y axis coordinate
        c2x - the second control point X axis coordinate
        c2y - the second control point Y axis coordinate
        x - the point X axis coordinate
        y - the point Y axis coordinate
      • nvgQuadTo

        public static void nvgQuadTo(long ctx,
                                     float cx,
                                     float cy,
                                     float x,
                                     float y)
        Adds quadratic bezier segment from last point in the path via a control point to the specified point.
        Parameters:
        ctx - the NanoVG context
        cx - the control point X axis coordinate
        cy - the control point Y axis coordinate
        x - the point X axis coordinate
        y - the point Y axis coordinate
      • nvgArcTo

        public static void nvgArcTo(long ctx,
                                    float x1,
                                    float y1,
                                    float x2,
                                    float y2,
                                    float radius)
        Adds an arc segment at the corner defined by the last path point, and two specified points.
        Parameters:
        ctx - the NanoVG context
        x1 - the first point X axis coordinate
        y1 - the first point Y axis coordinate
        x2 - the second point X axis coordinate
        y2 - the second point Y axis coordinate
        radius - the arc radius, in radians
      • nvgClosePath

        public static void nvgClosePath(long ctx)
        Closes current sub-path with a line segment.
        Parameters:
        ctx - the NanoVG context
      • nvgPathWinding

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

        public static void nvgArc(long ctx,
                                  float cx,
                                  float cy,
                                  float r,
                                  float a0,
                                  float a1,
                                  int dir)
        Creates new circle arc shaped sub-path.
        Parameters:
        ctx - the NanoVG context
        cx - the arc center X axis coordinate
        cy - the arc center Y axis coordinate
        r - the arc radius
        a0 - the arc starting angle, in radians
        a1 - the arc ending angle, in radians
        dir - the arc direction. One of:
        CCWCW
      • nvgRect

        public static void nvgRect(long ctx,
                                   float x,
                                   float y,
                                   float w,
                                   float h)
        Creates new rectangle shaped sub-path.
        Parameters:
        ctx - the NanoVG context
        x - the rectangle X axis coordinate
        y - the rectangle Y axis coordinate
        w - the rectangle width
        h - the rectangle height
      • nvgRoundedRect

        public static void nvgRoundedRect(long ctx,
                                          float x,
                                          float y,
                                          float w,
                                          float h,
                                          float r)
        Creates new rounded rectangle shaped sub-path.
        Parameters:
        ctx - the NanoVG context
        x - the rectangle X axis coordinate
        y - the rectangle Y axis coordinate
        w - the rectangle width
        h - the rectangle height
        r - the corner radius
      • nvgEllipse

        public static void nvgEllipse(long ctx,
                                      float cx,
                                      float cy,
                                      float rx,
                                      float ry)
        Creates new ellipse shaped sub-path.
        Parameters:
        ctx - the NanoVG context
        cx - the ellipse center X axis coordinate
        cy - the ellipse center Y axis coordinate
        rx - the ellipse X axis radius
        ry - the ellipse Y axis radius
      • nvgCircle

        public static void nvgCircle(long ctx,
                                     float cx,
                                     float cy,
                                     float r)
        Creates new circle shaped sub-path.
        Parameters:
        ctx - the NanoVG context
        cx - the circle center X axis coordinate
        cy - the circle center Y axis coordinate
        r - the circle radius
      • nvgFill

        public static void nvgFill(long ctx)
        Fills the current path with current fill style.
        Parameters:
        ctx - the NanoVG context
      • nvgStroke

        public static void nvgStroke(long ctx)
        Fills the current path with current stroke style.
        Parameters:
        ctx - the NanoVG context
      • nvgCreateFont

        public static int nvgCreateFont(long ctx,
                                        java.nio.ByteBuffer name,
                                        java.nio.ByteBuffer filename)
        Creates font by loading it from the disk from specified file name.
        Parameters:
        ctx - the NanoVG context
        name - the font name
        filename - the font file name
        Returns:
        a handle to the font
      • nvgCreateFont

        public static int nvgCreateFont(long ctx,
                                        java.lang.CharSequence name,
                                        java.lang.CharSequence filename)
        Creates font by loading it from the disk from specified file name.
        Parameters:
        ctx - the NanoVG context
        name - the font name
        filename - the font file name
        Returns:
        a handle to the font
      • nvgCreateFontMem

        public static int nvgCreateFontMem(long ctx,
                                           java.nio.ByteBuffer name,
                                           java.nio.ByteBuffer data,
                                           int freeData)
        Creates font by loading it from the specified memory chunk.

        The memory chunk must remain valid for as long as the font is used by NanoVG.

        Parameters:
        ctx - the NanoVG context
        name - the font name
        data - the font data
        freeData - 1 if the font data should be freed automatically, 0 otherwise
      • nvgCreateFontMem

        public static int nvgCreateFontMem(long ctx,
                                           java.lang.CharSequence name,
                                           java.nio.ByteBuffer data,
                                           int freeData)
        Creates font by loading it from the specified memory chunk.

        The memory chunk must remain valid for as long as the font is used by NanoVG.

        Parameters:
        ctx - the NanoVG context
        name - the font name
        data - the font data
        freeData - 1 if the font data should be freed automatically, 0 otherwise
      • nvgFindFont

        public static int nvgFindFont(long ctx,
                                      java.nio.ByteBuffer name)
        Finds a loaded font of specified name, and returns handle to it, or -1 if the font is not found.
        Parameters:
        ctx - the NanoVG context
        name - the font name
      • nvgFindFont

        public static int nvgFindFont(long ctx,
                                      java.lang.CharSequence name)
        Finds a loaded font of specified name, and returns handle to it, or -1 if the font is not found.
        Parameters:
        ctx - the NanoVG context
        name - the font name
      • nvgFontSize

        public static void nvgFontSize(long ctx,
                                       float size)
        Sets the font size of current text style.
        Parameters:
        ctx - the NanoVG context
        size - the font size to set
      • nvgFontBlur

        public static void nvgFontBlur(long ctx,
                                       float blur)
        Sets the blur of current text style.
        Parameters:
        ctx - the NanoVG context
        blur - the blur amount to set
      • nvgTextLetterSpacing

        public static void nvgTextLetterSpacing(long ctx,
                                                float spacing)
        Sets the letter spacing of current text style.
        Parameters:
        ctx - the NanoVG context
        spacing - the letter spacing amount to set
      • nvgTextLineHeight

        public static void nvgTextLineHeight(long ctx,
                                             float lineHeight)
        Sets the proportional line height of current text style. The line height is specified as multiple of font size.
        Parameters:
        ctx - the NanoVG context
        lineHeight - the line height to set
      • nvgFontFaceId

        public static void nvgFontFaceId(long ctx,
                                         int font)
        Sets the font face based on specified id of current text style.
        Parameters:
        ctx - the NanoVG context
        font - the font id
      • nvgFontFace

        public static void nvgFontFace(long ctx,
                                       java.nio.ByteBuffer font)
        Sets the font face based on specified name of current text style.
        Parameters:
        ctx - the NanoVG context
        font - the font name
      • nvgFontFace

        public static void nvgFontFace(long ctx,
                                       java.lang.CharSequence font)
        Sets the font face based on specified name of current text style.
        Parameters:
        ctx - the NanoVG context
        font - the font name
      • nvgText

        public static float nvgText(long ctx,
                                    float x,
                                    float y,
                                    java.nio.ByteBuffer string,
                                    long end)
        Draws text string at specified location. If end is specified only the sub-string up to the end is drawn.
        Parameters:
        ctx - the NanoVG context
        x - the text X axis coordinate
        y - the text Y axis coordinate
        string - the text string to draw
        end - a pointer to the end of the sub-string to draw, or NULL
      • nvgText

        public static float nvgText(long ctx,
                                    float x,
                                    float y,
                                    java.lang.CharSequence string,
                                    long end)
        Draws text string at specified location. If end is specified only the sub-string up to the end is drawn.
        Parameters:
        ctx - the NanoVG context
        x - the text X axis coordinate
        y - the text Y axis coordinate
        string - the text string to draw
        end - a pointer to the end of the sub-string to draw, or NULL
      • nvgTextBox

        public static void nvgTextBox(long ctx,
                                      float x,
                                      float y,
                                      float breakRowWidth,
                                      java.nio.ByteBuffer string,
                                      long end)
        Draws multi-line text string at specified location wrapped at the specified width. If end is specified only the sub-string up to the end is drawn.

        White space is stripped at the beginning of the rows, the text is split at word boundaries or when new-line characters are encountered. Words longer than the max width are slit at nearest character (i.e. no hyphenation).

        Parameters:
        ctx - the NanoVG context
        x - the text box X axis coordinate
        y - the text box Y axis coordinate
        breakRowWidth - the maximum row width
        string - the text string to draw
        end - a pointer to the end of the sub-string to draw, or NULL
      • nvgTextBox

        public static void nvgTextBox(long ctx,
                                      float x,
                                      float y,
                                      float breakRowWidth,
                                      java.lang.CharSequence string,
                                      long end)
        Draws multi-line text string at specified location wrapped at the specified width. If end is specified only the sub-string up to the end is drawn.

        White space is stripped at the beginning of the rows, the text is split at word boundaries or when new-line characters are encountered. Words longer than the max width are slit at nearest character (i.e. no hyphenation).

        Parameters:
        ctx - the NanoVG context
        x - the text box X axis coordinate
        y - the text box Y axis coordinate
        breakRowWidth - the maximum row width
        string - the text string to draw
        end - a pointer to the end of the sub-string to draw, or NULL
      • nvgTextBounds

        public static float nvgTextBounds(long ctx,
                                          float x,
                                          float y,
                                          java.nio.ByteBuffer string,
                                          long end,
                                          java.nio.FloatBuffer bounds)
        Measures the specified text string.

        Parameter bounds should be a pointer to float[4], if the bounding box of the text should be returned. The bounds value are [xmin,ymin, xmax,ymax].

        Measured values are returned in local coordinate space.

        Parameters:
        ctx - the NanoVG context
        x - the text X axis coordinate
        y - the text Y axis coordinate
        string - the text string to measure
        end - a pointer to the end of the sub-string to measure, or NULL
        bounds - returns the bounding box of the text
        Returns:
        the horizontal advance of the measured text (i.e. where the next character should drawn)
      • nvgTextBounds

        public static float nvgTextBounds(long ctx,
                                          float x,
                                          float y,
                                          java.lang.CharSequence string,
                                          long end,
                                          java.nio.FloatBuffer bounds)
        Measures the specified text string.

        Parameter bounds should be a pointer to float[4], if the bounding box of the text should be returned. The bounds value are [xmin,ymin, xmax,ymax].

        Measured values are returned in local coordinate space.

        Parameters:
        ctx - the NanoVG context
        x - the text X axis coordinate
        y - the text Y axis coordinate
        string - the text string to measure
        end - a pointer to the end of the sub-string to measure, or NULL
        bounds - returns the bounding box of the text
        Returns:
        the horizontal advance of the measured text (i.e. where the next character should drawn)
      • nvgTextBoxBounds

        public static void nvgTextBoxBounds(long ctx,
                                            float x,
                                            float y,
                                            float breakRowWidth,
                                            java.nio.ByteBuffer string,
                                            long end,
                                            java.nio.FloatBuffer bounds)
        Measures the specified multi-text string.

        Parameter bounds should be a pointer to float[4], if the bounding box of the text should be returned. The bounds value are [xmin,ymin, xmax,ymax].

        Measured values are returned in local coordinate space.

        Parameters:
        ctx - the NanoVG context
        x - the text box X axis coordinate
        y - the text box Y axis coordinate
        breakRowWidth - the maximum row width
        string - the text string to measure
        end - a pointer to the end of the sub-string to measure, or NULL
        bounds - returns the bounding box of the text box
      • nvgTextBoxBounds

        public static void nvgTextBoxBounds(long ctx,
                                            float x,
                                            float y,
                                            float breakRowWidth,
                                            java.lang.CharSequence string,
                                            long end,
                                            java.nio.FloatBuffer bounds)
        Measures the specified multi-text string.

        Parameter bounds should be a pointer to float[4], if the bounding box of the text should be returned. The bounds value are [xmin,ymin, xmax,ymax].

        Measured values are returned in local coordinate space.

        Parameters:
        ctx - the NanoVG context
        x - the text box X axis coordinate
        y - the text box Y axis coordinate
        breakRowWidth - the maximum row width
        string - the text string to measure
        end - a pointer to the end of the sub-string to measure, or NULL
        bounds - returns the bounding box of the text box
      • nvgTextGlyphPositions

        public static int nvgTextGlyphPositions(long ctx,
                                                float x,
                                                float y,
                                                java.nio.ByteBuffer string,
                                                long end,
                                                NVGGlyphPosition.Buffer positions)
        Calculates the glyph x positions of the specified text. If end is specified only the sub-string will be used.

        Measured values are returned in local coordinate space.

        Parameters:
        ctx - the NanoVG context
        x - the text X axis coordinate
        y - the text Y axis coordinate
        string - the text string to measure
        end - a pointer to the end of the sub-string to measure, or NULL
        positions - returns the glyph x positions
      • nvgTextGlyphPositions

        public static int nvgTextGlyphPositions(long ctx,
                                                float x,
                                                float y,
                                                java.lang.CharSequence string,
                                                long end,
                                                NVGGlyphPosition.Buffer positions)
        Calculates the glyph x positions of the specified text. If end is specified only the sub-string will be used.

        Measured values are returned in local coordinate space.

        Parameters:
        ctx - the NanoVG context
        x - the text X axis coordinate
        y - the text Y axis coordinate
        string - the text string to measure
        end - a pointer to the end of the sub-string to measure, or NULL
        positions - returns the glyph x positions
      • nvgTextMetrics

        public static void nvgTextMetrics(long ctx,
                                          java.nio.FloatBuffer ascender,
                                          java.nio.FloatBuffer descender,
                                          java.nio.FloatBuffer lineh)
        Returns the vertical metrics based on the current text style.

        Measured values are returned in local coordinate space.

        Parameters:
        ctx - the NanoVG context
        ascender - the line ascend
        descender - the line descend
        lineh - the line height
      • nvgTextBreakLines

        public static int nvgTextBreakLines(long ctx,
                                            java.nio.ByteBuffer string,
                                            long end,
                                            float breakRowWidth,
                                            NVGTextRow.Buffer rows)
        Breaks the specified text into lines. If end is specified only the sub-string will be used.

        White space is stripped at the beginning of the rows, the text is split at word boundaries or when new-line characters are encountered. Words longer than the max width are slit at nearest character (i.e. no hyphenation).

        Parameters:
        ctx - the NanoVG context
        string - the text string to measure
        end - a pointer to the end of the sub-string to measure, or NULL
        breakRowWidth - the maximum row width
        rows - returns the text rows
      • nvgTextBreakLines

        public static int nvgTextBreakLines(long ctx,
                                            java.lang.CharSequence string,
                                            long end,
                                            float breakRowWidth,
                                            NVGTextRow.Buffer rows)
        Breaks the specified text into lines. If end is specified only the sub-string will be used.

        White space is stripped at the beginning of the rows, the text is split at word boundaries or when new-line characters are encountered. Words longer than the max width are slit at nearest character (i.e. no hyphenation).

        Parameters:
        ctx - the NanoVG context
        string - the text string to measure
        end - a pointer to the end of the sub-string to measure, or NULL
        breakRowWidth - the maximum row width
        rows - returns the text rows
      • nvgCurrentTransform

        public static void nvgCurrentTransform(long ctx,
                                               float[] xform)
        Array version of: CurrentTransform
      • nvgTransformIdentity

        public static void nvgTransformIdentity(float[] dst)
        Array version of: TransformIdentity
      • nvgTransformTranslate

        public static void nvgTransformTranslate(float[] dst,
                                                 float tx,
                                                 float ty)
        Array version of: TransformTranslate
      • nvgTransformScale

        public static void nvgTransformScale(float[] dst,
                                             float sx,
                                             float sy)
        Array version of: TransformScale
      • nvgTransformRotate

        public static void nvgTransformRotate(float[] dst,
                                              float a)
        Array version of: TransformRotate
      • nvgTransformSkewX

        public static void nvgTransformSkewX(float[] dst,
                                             float a)
        Array version of: TransformSkewX
      • nvgTransformSkewY

        public static void nvgTransformSkewY(float[] dst,
                                             float a)
        Array version of: TransformSkewY
      • nvgTransformMultiply

        public static void nvgTransformMultiply(float[] dst,
                                                float[] src)
        Array version of: TransformMultiply
      • nvgTransformPremultiply

        public static void nvgTransformPremultiply(float[] dst,
                                                   float[] src)
        Array version of: TransformPremultiply
      • nvgTransformInverse

        public static int nvgTransformInverse(float[] dst,
                                              float[] src)
        Array version of: TransformInverse
      • nvgTransformPoint

        public static void nvgTransformPoint(float[] dstx,
                                             float[] dsty,
                                             float[] xform,
                                             float srcx,
                                             float srcy)
        Array version of: TransformPoint
      • nvgImageSize

        public static void nvgImageSize(long ctx,
                                        int image,
                                        int[] w,
                                        int[] h)
        Array version of: ImageSize
      • nvgTextBounds

        public static float nvgTextBounds(long ctx,
                                          float x,
                                          float y,
                                          java.nio.ByteBuffer string,
                                          long end,
                                          float[] bounds)
        Array version of: TextBounds
      • nvgTextBounds

        public static float nvgTextBounds(long ctx,
                                          float x,
                                          float y,
                                          java.lang.CharSequence string,
                                          long end,
                                          float[] bounds)
        Array version of: TextBounds
      • nvgTextBoxBounds

        public static void nvgTextBoxBounds(long ctx,
                                            float x,
                                            float y,
                                            float breakRowWidth,
                                            java.nio.ByteBuffer string,
                                            long end,
                                            float[] bounds)
        Array version of: TextBoxBounds
      • nvgTextBoxBounds

        public static void nvgTextBoxBounds(long ctx,
                                            float x,
                                            float y,
                                            float breakRowWidth,
                                            java.lang.CharSequence string,
                                            long end,
                                            float[] bounds)
        Array version of: TextBoxBounds
      • nvgTextMetrics

        public static void nvgTextMetrics(long ctx,
                                          float[] ascender,
                                          float[] descender,
                                          float[] lineh)
        Array version of: TextMetrics