Collection Info

View Source
Collection
vendor
Path
nanovg
Entries
146

Source Files

Constants

9

Types

28

Procedures

107

AddFallbackFontId #

Source
AddFallbackFontId :: proc(ctx: ^Context, base_font, fallback_font: int) -> bool {…}

Adds a fallback font by handle.

Arc #

Source
Arc :: proc(
	ctx:               ^Context, 
	cx, cy, r, a0, a1: f32, 
	dir:               Winding, 
) {…}

Creates new circle arc shaped sub-path. The arc center is at cx,cy, the arc radius is r, and the arc is drawn from angle a0 to a1, and swept in direction dir (NVG_CCW, or NVG_CW). Angles are specified in radians.

ArcTo #

Source
ArcTo :: proc(
	ctx:    ^Context, 
	x1, y1: f32, 
	x2, y2: f32, 
	radius: f32, 
) {…}

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

BeginFrame #

Source
BeginFrame :: proc(ctx: ^Context, windowWidth: f32, windowHeight: f32, devicePixelRatio: f32) {…}

Begin drawing a new frame Calls to nanovg drawing API should be wrapped in nvgBeginFrame() & nvgEndFrame() nvgBeginFrame() 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.

BezierTo #

Source
BezierTo :: proc(
	ctx:      ^Context, 
	c1x, c1y: f32, 
	c2x, c2y: f32, 
	x, y:     f32, 
) {…}

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

BoxGradient #

Source
BoxGradient :: proc(
	x, y: f32, 
	w, h: f32, 
	r:    f32, 
	f:    f32, 
	icol: [4]f32, 
	ocol: [4]f32, 
) -> (p: Paint) {…}

Creates and returns a radial gradient. Parameters (cx,cy) specify the center, inr and outr specify the inner and outer radius of the gradient, icol specifies the start color and ocol the end color. The gradient is transformed by the current transform when it is passed to nvgFillPaint() or nvgStrokePaint().

CreateFont #

Source
CreateFont :: proc(ctx: ^Context, name, filename: string) -> int {…}

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

CreateFontMem #

Source
CreateFontMem :: proc(ctx: ^Context, name: string, slice: []u8, free_loaded_data: bool) -> int {…}

Creates font by loading it from the specified memory chunk. Returns handle to the font.

CreateImageMem #

Source
CreateImageMem :: proc(ctx: ^Context, data: []u8, imageFlags: bit_set[ImageFlag]) -> int {…}

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

CreateImagePath #

Source
CreateImagePath :: proc(ctx: ^Context, filename: cstring, imageFlags: bit_set[ImageFlag]) -> int {…}

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

CreateImageRGBA #

Source
CreateImageRGBA :: proc(ctx: ^Context, w, h: int, imageFlags: bit_set[ImageFlag], data: []u8) -> int {…}

Creates image from specified image data. Returns handle to the image.

CurrentTransform #

Source
CurrentTransform :: proc(ctx: ^Context, xform: ^[6]f32) {…}

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.

FillPaint #

Source
FillPaint :: proc(ctx: ^Context, paint: Paint) {…}

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

FindFont #

Source
FindFont :: proc(ctx: ^Context, name: string) -> int {…}

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

FontFace #

Source
FontFace :: proc(ctx: ^Context, font: string) {…}

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

FontFaceId #

Source
FontFaceId :: proc(ctx: ^Context, font: int) {…}

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

GlobalAlpha #

Source
GlobalAlpha :: proc(ctx: ^Context, alpha: f32) {…}

Sets the transparency applied to all rendered shapes. Already transparent paths will get proportionally more transparent as well.

GlobalCompositeBlendFunc #

Source
GlobalCompositeBlendFunc :: proc(ctx: ^Context, sfactor, dfactor: BlendFactor) {…}

Sets the composite operation with custom pixel arithmetic. The parameters should be one of NVGblendFactor.

GlobalCompositeBlendFuncSeparate #

Source
GlobalCompositeBlendFuncSeparate :: proc(ctx: ^Context, srcRGB: BlendFactor, dstRGB: BlendFactor, srcAlpha: BlendFactor, dstAlpha: BlendFactor) {…}

Sets the composite operation with custom pixel arithmetic for RGB and alpha components separately. The parameters should be one of NVGblendFactor.

GlobalCompositeOperation #

Source
GlobalCompositeOperation :: proc(ctx: ^Context, op: CompositeOperation) {…}

Sets the composite operation. The op parameter should be one of NVGcompositeOperation.

HSL #

Source
HSL :: proc(h, s, l: f32) -> [4]f32 {…}

Returns color value specified by hue, saturation and lightness. HSL values are all in range [0..1], alpha will be set to 255.

HSLA #

Source
HSLA :: proc(hue, saturation, lightness: f32, a: u8) -> (col: [4]f32) {…}

Returns color value specified by hue, saturation and lightness and alpha. HSL values are all in range [0..1], alpha in range [0..255]

ImagePattern #

Source
ImagePattern :: proc(
	cx, cy: f32, 
	w, h:   f32, 
	angle:  f32, 
	image:  int, 
	alpha:  f32, 
) -> (p: Paint) {…}

Creates and returns an image pattern. Parameters (ox,oy) specify the left-top location of the image pattern, (ex,ey) the size of one image, angle rotation around the top-left corner, image is handle to the image to render. The gradient is transformed by the current transform when it is passed to nvgFillPaint() or nvgStrokePaint().

IntersectScissor #

Source
IntersectScissor :: proc(ctx: ^Context, x, y, w, h: f32) {…}

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.

LerpRGBA #

Source
LerpRGBA :: proc(c0, c1: [4]f32, u: f32) -> (cint: [4]f32) {…}

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

LinearGradient #

Source
LinearGradient :: proc(
	sx, sy: f32, 
	ex, ey: f32, 
	icol:   [4]f32, 
	ocol:   [4]f32, 
) -> (p: Paint) {…}

Creates and returns a linear gradient. Parameters (sx,sy)-(ex,ey) specify the start and end coordinates of the linear gradient, icol specifies the start color and ocol the end color. The gradient is transformed by the current transform when it is passed to nvgFillPaint() or nvgStrokePaint().

LineCap #

Source
LineCap :: proc(ctx: ^Context, cap: LineCapType) {…}

Sets how the end of the line (cap) is drawn, Can be one of: NVG_BUTT (default), NVG_ROUND, NVG_SQUARE.

LineJoin #

Source
LineJoin :: proc(ctx: ^Context, join: LineCapType) {…}

Sets how sharp path corners are drawn. Can be one of NVG_MITER (default), NVG_ROUND, NVG_BEVEL.

LineTo #

Source
LineTo :: proc(ctx: ^Context, x, y: f32) {…}

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

MiterLimit #

Source
MiterLimit :: proc(ctx: ^Context, limit: f32) {…}

Sets the miter limit of the stroke style. Miter limit controls when a sharp corner is beveled.

MoveTo #

Source
MoveTo :: proc(ctx: ^Context, x, y: f32) {…}

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

PathWinding #

Source
PathWinding :: proc(ctx: ^Context, direction: Winding) {…}

Sets the current sub-path winding, see NVGwinding and NVGsolidity.

QuadTo #

Source
QuadTo :: proc(ctx: ^Context, cx, cy, x, y: f32) {…}

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

RadialGradient #

Source
RadialGradient :: proc(
	cx, cy: f32, 
	inr:    f32, 
	outr:   f32, 
	icol:   [4]f32, 
	ocol:   [4]f32, 
) -> (p: Paint) {…}

Creates and returns a box gradient. Box gradient is a feathered rounded rectangle, it is useful for rendering drop shadows or highlights for boxes. Parameters (x,y) define the top-left corner of the rectangle, (w,h) define the size of the rectangle, r defines the corner radius, and f feather. Feather defines how blurry the border of the rectangle is. Parameter icol specifies the inner color and ocol the outer color of the gradient. The gradient is transformed by the current transform when it is passed to nvgFillPaint() or nvgStrokePaint().

Reset #

Source
Reset :: proc(ctx: ^Context) {…}

Resets current render state to default values. Does not affect the render state stack.

ResetFallbackFontsId #

Source
ResetFallbackFontsId :: proc(ctx: ^Context, base_font: int) {…}

Resets fallback fonts by handle.

ResetTransform #

Source
ResetTransform :: proc(ctx: ^Context) {…}

Resets current transform to a identity matrix.

RGB #

Source
RGB :: proc(r, g, b: u8) -> [4]f32 {…}

Returns a color value from red, green, blue values. Alpha will be set to 255 (1.0f).

RGBA #

Source
RGBA :: proc(r, g, b, a: u8) -> (res: [4]f32) {…}

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

Rotate #

Source
Rotate :: proc(ctx: ^Context, angle: f32) {…}

Rotates current coordinate system. Angle is specified in radians.

RoundedRect #

Source
RoundedRect :: proc(
	ctx:                ^Context, 
	x, y, w, h, radius: f32, 
) {…}

Creates new rounded rectangle shaped sub-path.

RoundedRectVarying #

Source
RoundedRectVarying :: proc(
	ctx:                 ^Context, 
	x, y:                f32, 
	w, h:                f32, 
	radius_top_left:     f32, 
	radius_top_right:    f32, 
	radius_bottom_right: f32, 
	radius_bottom_left:  f32, 
) {…}

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

Save #

Source
Save :: proc(ctx: ^Context) {…}

Pushes and saves the current render state into a state stack. A matching nvgRestore() must be used to restore the state.

Scissor #

Source
Scissor :: proc(ctx: ^Context, x, y: f32, width, height: f32) {…}

Sets the current scissor rectangle. The scissor rectangle is transformed by the current transform.

ShapeAntiAlias #

Source
ShapeAntiAlias :: proc(ctx: ^Context, enabled: bool) {…}

Sets whether to draw antialias for nvgStroke() and nvgFill(). It's enabled by default.

SkewX #

Source
SkewX :: proc(ctx: ^Context, angle: f32) {…}

Skews the current coordinate system along X axis. Angle is specified in radians.

SkewY #

Source
SkewY :: proc(ctx: ^Context, angle: f32) {…}

Skews the current coordinate system along Y axis. Angle is specified in radians.

StrokeColor #

Source
StrokeColor :: proc(ctx: ^Context, color: [4]f32) {…}

Sets current stroke style to a solid color.

StrokePaint #

Source
StrokePaint :: proc(ctx: ^Context, paint: Paint) {…}

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

Text #

Source
Text :: proc(ctx: ^Context, x, y: f32, text: string) -> f32 {…}

Draws text string at specified location. If end is specified only the sub-string up to the end is drawn.

TextBounds #

Source
TextBounds :: proc(ctx: ^Context, x, y: f32, input: string, bounds: ^[4]f32 = nil) -> (advance: f32) {…}

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] Returns the horizontal advance of the measured text (i.e. where the next character should drawn). Measured values are returned in local coordinate space.

TextBox #

Source
TextBox :: proc(ctx: ^Context, x, y: f32, break_row_width: f32, input: string) {…}

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).

TextBoxBounds #

Source
TextBoxBounds :: proc(
	ctx:           ^Context, 
	x, y:          f32, 
	breakRowWidth: f32, 
	input:         string, 
	bounds:        ^[4]f32, 
) {…}

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.

TextBreakLines #

Source
TextBreakLines :: proc(ctx: ^Context, text: ^string, break_row_width: f32, rows: ^[]Text_Row) -> (nrows: int, last: string, ok: bool) {…}

NOTE text break lines works relative to the string in byte indexes now, instead of on pointers Breaks the specified text into lines 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).

TextGlyphPositions #

Source
TextGlyphPositions :: proc(ctx: ^Context, x, y: f32, text: string, positions: ^[]Glyph_Position) -> int {…}

Calculates the glyph x positions of the specified text. Measured values are returned in local coordinate space.

TextLetterSpacing #

Source
TextLetterSpacing :: proc(ctx: ^Context, spacing: f32) {…}

Sets the letter spacing of current text style.

TextLineHeight #

Source
TextLineHeight :: proc(ctx: ^Context, lineHeight: f32) {…}

Sets the proportional line height of current text style. The line height is specified as multiple of font size.

TextMetrics #

Source
TextMetrics :: proc(ctx: ^Context) -> (ascender, descender, lineHeight: f32) {…}

Returns the vertical metrics based on the current text style. Measured values are returned in local coordinate space.

TransformIdentity #

Source
TransformIdentity :: proc(t: ^[6]f32) {…}

Sets the transform to identity matrix.

TransformInverse #

Source
TransformInverse :: proc(inv: ^[6]f32, t: [6]f32) -> bool {…}

Sets the destination to inverse of specified transform. Returns true if the inverse could be calculated, else false.

TransformMultiply #

Source
TransformMultiply :: proc(t: ^[6]f32, s: [6]f32) {…}

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

TransformPremultiply #

Source
TransformPremultiply :: proc(t: ^[6]f32, s: [6]f32) {…}

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

TransformRotate #

Source
TransformRotate :: proc(t: ^[6]f32, a: f32) {…}

Sets the transform to rotate matrix. Angle is specified in radians.

TransformScale #

Source
TransformScale :: proc(t: ^[6]f32, sx, sy: f32) {…}

Sets the transform to scale matrix.

TransformSkewX #

Source
TransformSkewX :: proc(t: ^[6]f32, a: f32) {…}

Sets the transform to skew-x matrix. Angle is specified in radians.

TransformSkewY #

Source
TransformSkewY :: proc(t: ^[6]f32, a: f32) {…}

Sets the transform to skew-y matrix. Angle is specified in radians.

TransformTranslate #

Source
TransformTranslate :: proc(t: ^[6]f32, tx, ty: f32) {…}

Sets the transform to translation matrix matrix.

UpdateImage #

Source
UpdateImage :: proc(ctx: ^Context, image: int, data: []u8) {…}

Updates image data specified by image handle.

Procedure Groups

1

Variables

1

OP_STATE_TABLE #

Source
OP_STATE_TABLE: [CompositeOperation][2]BlendFactor = [CompositeOperation][2]BlendFactor{.SOURCE_OVER = {.ONE, .ONE_MINUS_SRC_ALPHA}, .SOURCE_IN = {.DST_ALPHA, .ZERO}, .SOURCE_OUT = {.ONE_MINUS_DST_ALPHA, .ZERO}, .ATOP = {.DST_ALPHA, .ONE_MINUS_SRC_ALPHA}, .DESTINATION_OVER = {.ONE_MINUS_DST_ALPHA, .ONE}, .DESTINATION_IN = {.ZERO, .SRC_ALPHA}, .DESTINATION_OUT = {.ZERO, .ONE_MINUS_SRC_ALPHA}, .DESTINATION_ATOP = {.ONE_MINUS_DST_ALPHA, .SRC_ALPHA}, .LIGHTER = {.ONE, .ONE}, .COPY = {.ONE, .ZERO}, .XOR = {.ONE_MINUS_DST_ALPHA, .ONE_MINUS_SRC_ALPHA}}

state table instead of if else chains