module NVG

Constants

ALIGN_BASELINE
ALIGN_BOTTOM
ALIGN_CENTER
ALIGN_LEFT

NVGalign

Horizontal align
ALIGN_MIDDLE
ALIGN_RIGHT
ALIGN_TOP

Vertical align

ANTIALIAS

NVGcreateFlags

ATOP
BEVEL
BUTT

NVGlineCap

CCW

NVGwinding

COPY
CW
DEBUG
DESTINATION_ATOP
DESTINATION_IN
DESTINATION_OUT
DESTINATION_OVER
DST_ALPHA
DST_COLOR
HOLE
IMAGE_FLIPY
IMAGE_GENERATE_MIPMAPS

NVGimageFlags

IMAGE_NEAREST
IMAGE_PREMULTIPLIED
IMAGE_REPEATX
IMAGE_REPEATY
LIGHTER
MITER
ONE
ONE_MINUS_DST_ALPHA
ONE_MINUS_DST_COLOR
ONE_MINUS_SRC_ALPHA
ONE_MINUS_SRC_COLOR
ROUND
SOLID

NVGsolidity

SOURCE_IN
SOURCE_OUT
SOURCE_OVER

NVGcompositeOperation

SQUARE
SRC_ALPHA
SRC_ALPHA_SATURATE
SRC_COLOR
STENCIL_STROKES
XOR
ZERO

NVGblendFactor

Public Class Methods

import_symbols(render_backend) click to toggle source
# File lib/nanovg.rb, line 137
def self.import_symbols(render_backend)
  #
  # Common API
  #
  attach_function :BeginFrame, :nvgBeginFrame, [:pointer, :float, :float, :float], :void
  attach_function :CancelFrame, :nvgCancelFrame, [:pointer], :void
  attach_function :EndFrame, :nvgEndFrame, [:pointer], :void

  attach_function :GlobalCompositeOperation, :nvgGlobalCompositeOperation, [:pointer,  :int32], :void
  attach_function :GlobalCompositeBlendFunc, :nvgGlobalCompositeBlendFunc, [:pointer, :int32, :int32], :void
  attach_function :GlobalCompositeBlendFuncSeparate, :nvgGlobalCompositeBlendFuncSeparate, [:pointer, :int32, :int32, :int32, :int32], :void

  attach_function :RGB, :nvgRGB, [:uint8, :uint8, :uint8], Color.by_value
  attach_function :RGBf, :nvgRGBf, [:float, :float, :float], Color.by_value
  attach_function :RGBA, :nvgRGBA, [:uint8, :uint8, :uint8, :uint8], Color.by_value
  attach_function :RGBAf, :nvgRGBAf, [:float, :float, :float, :float], Color.by_value

  attach_function :LerpRGBA, :nvgLerpRGBA, [Color.by_value, Color.by_value, :float], Color.by_value
  attach_function :TransRGBA, :nvgTransRGBA, [Color.by_value, :uint8], Color.by_value
  attach_function :TransRGBAf, :nvgTransRGBAf, [Color.by_value, :float], Color.by_value
  attach_function :HSL, :nvgHSL, [:float, :float, :float], Color.by_value
  attach_function :HSLA, :nvgHSLA, [:float, :float, :float, :uint8], Color.by_value

  attach_function :Save, :nvgSave, [:pointer], :void
  attach_function :Restore, :nvgRestore, [:pointer], :void
  attach_function :Reset, :nvgReset, [:pointer], :void

  attach_function :ShapeAntiAlias, :nvgShapeAntiAlias, [:pointer, Color.by_value], :void
  attach_function :StrokeColor, :nvgStrokeColor, [:pointer, Color.by_value], :void
  attach_function :StrokePaint, :nvgStrokePaint, [:pointer, Paint.by_value], :void
  attach_function :FillColor, :nvgFillColor, [:pointer, Color.by_value], :void
  attach_function :FillPaint, :nvgFillPaint, [:pointer, Paint.by_value], :void
  attach_function :MiterLimit, :nvgMiterLimit, [:pointer, :float], :void
  attach_function :StrokeWidth, :nvgStrokeWidth, [:pointer, :float], :void
  attach_function :LineCap, :nvgLineCap, [:pointer, :int32], :void
  attach_function :LineJoin, :nvgLineJoin, [:pointer, :int32], :void
  attach_function :GlobalAlpha, :nvgGlobalAlpha, [:pointer, :float], :void

  attach_function :ResetTransform, :nvgResetTransform, [:pointer], :void
  attach_function :Transform, :nvgTransform, [:pointer, :float, :float, :float, :float, :float, :float], :void
  attach_function :Translate, :nvgTranslate, [:pointer, :float, :float], :void
  attach_function :Rotate, :nvgRotate, [:pointer, :float], :void
  attach_function :SkewX, :nvgSkewX, [:pointer, :float], :void
  attach_function :SkewY, :nvgSkewY, [:pointer, :float], :void
  attach_function :Scale, :nvgScale, [:pointer, :float, :float], :void
  attach_function :CurrentTransform, :nvgCurrentTransform, [:pointer, :pointer], :void

  attach_function :TransformIdentity, :nvgTransformIdentity, [:pointer], :void
  attach_function :TransformTranslate, :nvgTransformTranslate, [:pointer, :float, :float], :void
  attach_function :TransformScale, :nvgTransformScale, [:pointer, :float, :float], :void
  attach_function :TransformRotate, :nvgTransformRotate, [:pointer, :float], :void
  attach_function :TransformSkewX, :nvgTransformSkewX, [:pointer, :float], :void
  attach_function :TransformSkewY, :nvgTransformSkewY, [:pointer, :float], :void
  attach_function :TransformMultiply, :nvgTransformMultiply, [:pointer, :pointer], :void
  attach_function :TransformPremultiply, :nvgTransformPremultiply, [:pointer, :pointer], :void
  attach_function :TransformInverse, :nvgTransformInverse, [:pointer, :pointer], :int32
  attach_function :TransformPoint, :nvgTransformPoint, [:pointer, :pointer, :pointer, :float, :float], :void

  attach_function :DegToRad, :nvgDegToRad, [:float], :float
  attach_function :RadToDeg, :nvgRadToDeg, [:float], :float

  attach_function :CreateImage, :nvgCreateImage, [:pointer, :pointer, :int32], :int32
  attach_function :CreateImageMem, :nvgCreateImageMem, [:pointer, :int32, :pointer, :int32], :int32
  attach_function :CreateImageRGBA, :nvgCreateImageRGBA, [:pointer, :int32, :int32, :int32, :pointer], :int32
  attach_function :UpdateImage, :nvgUpdateImage, [:pointer, :int32, :pointer], :void
  attach_function :ImageSize, :nvgImageSize, [:pointer, :int32, :pointer, :pointer], :void
  attach_function :DeleteImage, :nvgDeleteImage, [:pointer, :int32], :void

  attach_function :LinearGradient, :nvgLinearGradient, [:pointer, :float, :float, :float, :float, Color.by_value, Color.by_value], Paint.by_value
  attach_function :BoxGradient, :nvgBoxGradient, [:pointer, :float, :float, :float, :float, :float, :float, Color.by_value, Color.by_value], Paint.by_value
  attach_function :RadialGradient, :nvgRadialGradient, [:pointer, :float, :float, :float, :float, Color.by_value, Color.by_value], Paint.by_value
  attach_function :ImagePattern, :nvgImagePattern, [:pointer, :float, :float, :float, :float, :float, :int32, :float], Paint.by_value

  attach_function :Scissor, :nvgScissor, [:pointer, :float, :float, :float, :float], :void
  attach_function :IntersectScissor, :nvgIntersectScissor, [:pointer, :float, :float, :float, :float], :void
  attach_function :ResetScissor, :nvgResetScissor, [:pointer], :void

  attach_function :BeginPath, :nvgBeginPath, [:pointer], :void
  attach_function :MoveTo, :nvgMoveTo, [:pointer, :float, :float], :void
  attach_function :LineTo, :nvgLineTo, [:pointer, :float, :float], :void
  attach_function :BezierTo, :nvgBezierTo, [:pointer, :float, :float, :float, :float, :float, :float], :void
  attach_function :QuadTo, :nvgQuadTo, [:pointer, :float, :float, :float, :float], :void
  attach_function :ArcTo, :nvgArcTo, [:pointer, :float, :float, :float, :float, :float], :void
  attach_function :ClosePath, :nvgClosePath, [:pointer], :void
  attach_function :PathWinding, :nvgPathWinding, [:pointer, :int32], :void
  attach_function :Arc, :nvgArc, [:pointer, :float, :float, :float, :float, :float, :int32], :void
  attach_function :Rect, :nvgRect, [:pointer, :float, :float, :float, :float], :void
  attach_function :RoundedRect, :nvgRoundedRect, [:pointer, :float, :float, :float, :float, :float], :void
  attach_function :RoundedRectVarying, :nvgRoundedRectVarying, [:pointer, :float, :float, :float, :float, :float, :float, :float, :float], :void
  attach_function :Ellipse, :nvgEllipse, [:pointer, :float, :float, :float, :float], :void
  attach_function :Circle, :nvgCircle, [:pointer, :float, :float, :float], :void
  attach_function :Fill, :nvgFill, [:pointer], :void
  attach_function :Stroke, :nvgStroke, [:pointer], :void

  attach_function :CreateFont, :nvgCreateFont, [:pointer, :pointer, :pointer], :int32
  attach_function :CreateFontMem, :nvgCreateFontMem, [:pointer, :pointer, :pointer, :int32, :int32], :int32
  attach_function :FindFont, :nvgFindFont, [:pointer, :pointer], :int32
  attach_function :AddFallbackFontId, :nvgAddFallbackFontId, [:pointer, :int32, :int32], :int32
  attach_function :AddFallbackFont, :nvgAddFallbackFont, [:pointer, :pointer, :pointer], :int32
  attach_function :FontSize, :nvgFontSize, [:pointer, :float], :void
  attach_function :FontBlur, :nvgFontBlur, [:pointer, :float], :void
  attach_function :TextLetterSpacing, :nvgTextLetterSpacing, [:pointer, :float], :void
  attach_function :TextLineHeight, :nvgTextLineHeight, [:pointer, :float], :void
  attach_function :TextAlign, :nvgTextAlign, [:pointer, :int32], :void
  attach_function :FontFaceId, :nvgFontFaceId, [:pointer, :int32], :void
  attach_function :FontFace, :nvgFontFace, [:pointer, :pointer], :void
  attach_function :Text, :nvgText, [:pointer, :float, :float, :pointer, :pointer], :float
  attach_function :TextBox, :nvgTextBox, [:pointer, :float, :float, :float, :pointer, :pointer], :void
  attach_function :TextBounds, :nvgTextBounds, [:pointer, :float, :float, :pointer, :pointer, :pointer], :float
  attach_function :TextBoxBounds, :nvgTextBoxBounds, [:pointer, :float, :float, :float, :pointer, :pointer, :pointer], :void
  attach_function :TextGlyphPositions, :nvgTextGlyphPositions, [:pointer, :float, :float, :pointer, :pointer, :pointer, :int32], :int32
  attach_function :TextMetrics, :nvgTextMetrics, [:pointer, :pointer, :pointer, :pointer], :void
  attach_function :TextBreakLines, :nvgTextBreakLines, [:pointer, :pointer, :pointer, :float, :pointer, :int32], :int32

  #
  # GL2-specific API (nanovg_gl)
  #
  if render_backend == :gl2
    attach_function :CreateGL2, :nvgCreateGL2, [:int32], :pointer
    attach_function :DeleteGL2, :nvgDeleteGL2, [:pointer], :void
    attach_function :SetupGL2, :nvgSetupGL2, [], :void
  end

  #
  # GL3-specific API (nanovg_gl)
  #
  if render_backend == :gl3
    attach_function :CreateGL3, :nvgCreateGL3, [:int32], :pointer
    attach_function :DeleteGL3, :nvgDeleteGL3, [:pointer], :void
    attach_function :SetupGL3, :nvgSetupGL3, [], :void
  end

  @@nanovg_import_done = true
end
load_lib(libpath = './libnanovg.dylib', render_backend: :gl2) click to toggle source
# File lib/nanovg.rb, line 131
def self.load_lib(libpath = './libnanovg.dylib', render_backend: :gl2)
  ffi_lib_flags :now, :global # to force FFI to access nvgCreateInternal from nvgCreateGL2
  ffi_lib libpath
  import_symbols(render_backend) unless @@nanovg_import_done
end