Documentation ¶
Index ¶
- Constants
- func DegToRad(deg float32) float32
- func GetBoundRenderbuffer() gl.Renderbuffer
- func NvgluBindFramebuffer(fb *FrameBuffer)
- func NvgluDeleteFramebuffer(fb *FrameBuffer)
- func RadToDeg(rad float32) float32
- type Align
- type Color
- func HSL(h, s, l float32) Color
- func HSLA(h, s, l float32, a uint8) Color
- func LerpRGBA(c0, c1 Color, u float32) Color
- func MONO(i, alpha uint8) Color
- func MONOf(i, alpha float32) Color
- func RGB(r, g, b uint8) Color
- func RGBA(r, g, b, a uint8) Color
- func RGBAf(r, g, b, a float32) Color
- func RGBf(r, g, b float32) Color
- type Context
- func (c *Context) Arc(cx, cy, r, a0, a1 float32, dir Direction)
- func (c *Context) ArcTo(x1, y1, x2, y2, radius float32)
- func (c *Context) BeginFrame(windowWidth, windowHeight int, devicePixelRatio float32)
- func (c *Context) BeginFrameWithSameStates(windowWidth, windowHeight int, devicePixelRatio float32)
- func (c *Context) BeginPath()
- func (c *Context) BezierTo(c1x, c1y, c2x, c2y, x, y float32)
- func (c *Context) Block(block func())
- func (c *Context) BoundedCircle(x, y, radius, left, right, top, bottom float32)
- func (c *Context) CancelFrame()
- func (c *Context) Circle(cx, cy, r float32)
- func (c *Context) ClosePath()
- func (c *Context) CreateFont(name, filePath string) int
- func (c *Context) CreateFontFromMemory(name string, data []byte, freeData uint8) int
- func (c *Context) CreateFramebuffer(w, h int, imageFlags ImageFlags) *FrameBuffer
- func (c *Context) CreateImage(filePath string, flags ImageFlags) int
- func (c *Context) CreateImageFromGoImage(imageFlag ImageFlags, img image.Image) int
- func (c *Context) CreateImageFromMemory(flags ImageFlags, data []byte) int
- func (c *Context) CreateImageRGBA(w, h int, imageFlags ImageFlags, data []byte) int
- func (c *Context) CurrentTransform() TransformMatrix
- func (c *Context) DebugDumpPathCache()
- func (c *Context) Delete()
- func (c *Context) DeleteImage(img int)
- func (c *Context) Ellipse(cx, cy, rx, ry float32)
- func (c *Context) EndFrame()
- func (c *Context) Fill()
- func (c *Context) FindFont(name string) int
- func (c *Context) FontBlur() float32
- func (c *Context) FontFace() string
- func (c *Context) FontFaceID() int
- func (c *Context) FontSize() float32
- func (c *Context) GlobalAlpha() float32
- func (c *Context) ImageSize(img int) (int, int, error)
- func (c *Context) IntersectScissor(x, y, w, h float32)
- func (c *Context) LineCap() LineCap
- func (c *Context) LineJoin() LineCap
- func (c *Context) LineTo(x, y float32)
- func (c *Context) MiterLimit() float32
- func (c *Context) MoveTo(x, y float32)
- func (c *Context) PathWinding(winding Winding)
- func (c *Context) Polyline(points []FPoint, isClose bool)
- func (c *Context) QuadTo(cx, cy, x, y float32)
- func (c *Context) Rect(x, y, w, h float32)
- func (c *Context) Reset()
- func (c *Context) ResetScissor()
- func (c *Context) ResetTransform()
- func (c *Context) Restore()
- func (c *Context) Rotate(angle float32)
- func (c *Context) RoundedRect(x, y, w, h, r float32)
- func (c *Context) Save()
- func (c *Context) Scale(x, y float32)
- func (c *Context) Scissor(x, y, w, h float32)
- func (c *Context) SectorSegment(x, y, radiusOuter, radiusInner, startAngle, sweepAngle float32)
- func (c *Context) SetFillColor(color Color)
- func (c *Context) SetFillPaint(paint Paint)
- func (c *Context) SetFontBlur(blur float32)
- func (c *Context) SetFontFace(font string)
- func (c *Context) SetFontFaceID(font int)
- func (c *Context) SetFontSize(size float32)
- func (c *Context) SetGlobalAlpha(alpha float32)
- func (c *Context) SetLineCap(cap LineCap)
- func (c *Context) SetLineJoin(joint LineCap)
- func (c *Context) SetMiterLimit(limit float32)
- func (c *Context) SetStrokeColor(color Color)
- func (c *Context) SetStrokePaint(paint Paint)
- func (c *Context) SetStrokeWidth(width float32)
- func (c *Context) SetTextAlign(align Align)
- func (c *Context) SetTextLetterSpacing(spacing float32)
- func (c *Context) SetTextLineHeight(lineHeight float32)
- func (c *Context) SetTransform(t TransformMatrix)
- func (cx *Context) SetTransformByValue(a, b, c, d, e, f float32)
- func (c *Context) SkewX(angle float32)
- func (c *Context) SkewY(angle float32)
- func (c *Context) Stroke()
- func (c *Context) StrokeWidth() float32
- func (c *Context) Text(x, y float32, str string) float32
- func (c *Context) TextAlign() Align
- func (c *Context) TextBounds(x, y float32, str string) (float32, []float32)
- func (c *Context) TextBox(x, y, breakRowWidth float32, str string)
- func (c *Context) TextBoxBounds(x, y, breakRowWidth float32, str string) [4]float32
- func (c *Context) TextBreakLines(str string, breakRowWidth float32) []TextRow
- func (c *Context) TextBreakLinesRune(runes []rune, breakRowWidth float32) []TextRow
- func (c *Context) TextGlyphPositions(x, y float32, str string) []GlyphPosition
- func (c *Context) TextGlyphPositionsRune(x, y float32, runes []rune) []GlyphPosition
- func (c *Context) TextLetterSpacing() float32
- func (c *Context) TextLineHeight() float32
- func (c *Context) TextMetrics() (float32, float32, float32)
- func (c *Context) TextRune(x, y float32, runes []rune) float32
- func (c *Context) Translate(x, y float32)
- func (c *Context) UpdateImage(img int, data []byte) error
- type CreateFlags
- type Direction
- type FPoint
- type Float
- type FrameBuffer
- type GLint
- type GLuint
- type GlyphPosition
- type ImageFlags
- type LineCap
- type Paint
- type TextRow
- type TransformMatrix
- func (t TransformMatrix) Inverse() TransformMatrix
- func (t TransformMatrix) Multiply(s TransformMatrix) TransformMatrix
- func (t TransformMatrix) PreMultiply(s TransformMatrix) TransformMatrix
- func (t TransformMatrix) ToMat3x4() []float32
- func (t TransformMatrix) TransformPoint(sx, sy float32) (dx, dy float32)
- type Winding
Constants ¶
const ( // Kappa90 is length proportional to radius of a cubic bezier handle for 90deg arcs.) Kappa90 float32 = 0.5522847493 // PI of float32 PI float32 = 3.14159265358979323846264338327 )
Variables ¶
This section is empty.
Functions ¶
func GetBoundRenderbuffer ¶
func GetBoundRenderbuffer() gl.Renderbuffer
func NvgluBindFramebuffer ¶
func NvgluBindFramebuffer(fb *FrameBuffer)
func NvgluDeleteFramebuffer ¶
func NvgluDeleteFramebuffer(fb *FrameBuffer)
Types ¶
type Align ¶
type Align int
Align is used for text location
const ( // AlignLeft (default) is used for horizontal align. Align text horizontally to left. AlignLeft Align = 1 << 0 // AlignCenter is used for horizontal align. Align text horizontally to center. AlignCenter Align = 1 << 1 // AlignRight is used for horizontal align. Align text horizontally to right. AlignRight Align = 1 << 2 // AlignTop is used for vertical align. Align text vertically to top. AlignTop Align = 1 << 3 // AlignMiddle is used for vertical align. Align text vertically to middle. AlignMiddle Align = 1 << 4 // AlignBottom is used for vertical align. Align text vertically to bottom. AlignBottom Align = 1 << 5 // AlignBaseline (default) is used for vertical align. Align text vertically to baseline. AlignBaseline Align = 1 << 6 )
type Color ¶
type Color struct {
R, G, B, A float32
}
Color utils
Colors in NanoVGo are stored as unsigned ints in ABGR format.
func HSL ¶
HSL returns color value specified by hue, saturation and lightness. HSL values are all in range [0..1], alpha will be set to 255.
func HSLA ¶
HSLA returns color value specified by hue, saturation and lightness and alpha. HSL values are all in range [0..1], alpha in range [0..255]
func LerpRGBA ¶
LerpRGBA linearly interpolates from color c0 to c1, and returns resulting color value.
func (Color) PreMultiply ¶
PreMultiply preset alpha to each color.
func (Color) TransRGBAf ¶
TransRGBAf sets transparency of a color value.
type Context ¶
type Context struct {
// contains filtered or unexported fields
}
Context is an entry point object to use NanoVGo API and created by NewContext() function.
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. The parameter imageFlags is combination of flags defined in ImageFlags.
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:
vg.TextBounds(x, y, "Text me up.", bounds) vg.BeginPath() vg.RoundedRect(bounds[0],bounds[1], bounds[2]-bounds[0], bounds[3]-bounds[1]) vg.Fill()
Note: currently only solid color fill is supported for text.
func NewContext ¶
func NewContext(flags CreateFlags) (*Context, error)
NewContext makes new NanoVGo context that is entry point of this API
func (*Context) Arc ¶
Arc 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 (CounterClockwise, or Clockwise). Angles are specified in radians.
func (*Context) ArcTo ¶
ArcTo adds an arc segment at the corner defined by the last path point, and two specified points.
func (*Context) BeginFrame ¶
BeginFrame begins drawing a new frame Calls to NanoVGo drawing API should be wrapped in Context.BeginFrame() & Context.EndFrame() Context.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.
func (*Context) BeginFrameWithSameStates ¶
Same as normal begin frame but without reset of states stack. Usefull for some tricks with rendering multiple fbo in one common coordinate system
func (*Context) BeginPath ¶
func (c *Context) BeginPath()
BeginPath clears the current path and sub-paths.
func (*Context) BezierTo ¶
BezierTo adds cubic bezier segment from last point in the path via two control points to the specified point.
func (*Context) BoundedCircle ¶
Create bounded circle in (x,y) with radius and sides shifts.
func (*Context) CancelFrame ¶
func (c *Context) CancelFrame()
CancelFrame cancels drawing the current frame.
func (*Context) ClosePath ¶
func (c *Context) ClosePath()
ClosePath closes current sub-path with a line segment.
func (*Context) CreateFont ¶
CreateFont creates font by loading it from the disk from specified file name. Returns handle to the font.
func (*Context) CreateFontFromMemory ¶
CreateFontFromMemory creates image by loading it from the specified memory chunk. Returns handle to the font.
func (*Context) CreateFramebuffer ¶
func (c *Context) CreateFramebuffer(w, h int, imageFlags ImageFlags) *FrameBuffer
func (*Context) CreateImage ¶
func (c *Context) CreateImage(filePath string, flags ImageFlags) int
CreateImage creates image by loading it from the disk from specified file name. Returns handle to the image.
func (*Context) CreateImageFromGoImage ¶
func (c *Context) CreateImageFromGoImage(imageFlag ImageFlags, img image.Image) int
CreateImageFromGoImage creates image by loading it from the specified image.Image object. Returns handle to the image.
func (*Context) CreateImageFromMemory ¶
func (c *Context) CreateImageFromMemory(flags ImageFlags, data []byte) int
CreateImageFromMemory creates image by loading it from the specified chunk of memory. Returns handle to the image.
func (*Context) CreateImageRGBA ¶
func (c *Context) CreateImageRGBA(w, h int, imageFlags ImageFlags, data []byte) int
CreateImageRGBA creates image from specified image data. Returns handle to the image.
func (*Context) CurrentTransform ¶
func (c *Context) CurrentTransform() TransformMatrix
CurrentTransform returns the top part (a-f) of the current transformation matrix.
[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.
func (*Context) DebugDumpPathCache ¶
func (c *Context) DebugDumpPathCache()
DebugDumpPathCache prints cached path information to console
func (*Context) Delete ¶
func (c *Context) Delete()
Delete is called when tearing down NanoVGo context
func (*Context) DeleteImage ¶
DeleteImage deletes created image.
func (*Context) EndFrame ¶
func (c *Context) EndFrame()
EndFrame ends drawing flushing remaining render state.
func (*Context) Fill ¶
func (c *Context) Fill()
Fill fills the current path with current fill style.
func (*Context) FindFont ¶
FindFont finds a loaded font of specified name, and returns handle to it, or -1 if the font is not found.
func (*Context) FontFaceID ¶
FontFaceID gets the font face id of current text style.
func (*Context) GlobalAlpha ¶
GlobalAlpha gets the transparency applied to all rendered shapes.
func (*Context) IntersectScissor ¶
IntersectScissor calculates 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.
func (*Context) LineTo ¶
LineTo adds line segment from the last point in the path to the specified point.
func (*Context) MiterLimit ¶
MiterLimit gets the miter limit of the stroke style.
func (*Context) PathWinding ¶
PathWinding sets the current sub-path winding, see Winding.
func (*Context) QuadTo ¶
QuadTo adds quadratic bezier segment from last point in the path via a control point to the specified point.
func (*Context) Reset ¶
func (c *Context) Reset()
Reset resets current render state to default values. Does not affect the render state stack.
func (*Context) ResetScissor ¶
func (c *Context) ResetScissor()
ResetScissor resets and disables scissoring.
func (*Context) ResetTransform ¶
func (c *Context) ResetTransform()
ResetTransform resets current transform to a identity matrix.
func (*Context) Restore ¶
func (c *Context) Restore()
Restore pops and restores current render state.
func (*Context) RoundedRect ¶
RoundedRect creates new rounded rectangle shaped sub-path.
func (*Context) Save ¶
func (c *Context) Save()
Save pushes and saves the current render state into a state stack. A matching Restore() must be used to restore the state.
func (*Context) Scissor ¶
Scissor sets the current scissor rectangle. The scissor rectangle is transformed by the current transform.
func (*Context) SectorSegment ¶
SectorSegment create new segment of sector. The arc center is at (x,y), the inner arc radius is radiusInner, and outer radius is radiusOuter. The sector drawing from startAngle to (startAngle + sweepAngle) Angles are specified in radians.
func (*Context) SetFillColor ¶
SetFillColor sets current fill style to a solid color.
func (*Context) SetFillPaint ¶
SetFillPaint sets current fill style to a paint, which can be a one of the gradients or a pattern.
func (*Context) SetFontBlur ¶
SetFontBlur sets the font blur of current text style.
func (*Context) SetFontFace ¶
SetFontFace sets the font face based on specified name of current text style.
func (*Context) SetFontFaceID ¶
SetFontFaceID sets the font face based on specified id of current text style.
func (*Context) SetFontSize ¶
SetFontSize sets the font size of current text style.
func (*Context) SetGlobalAlpha ¶
SetGlobalAlpha sets the transparency applied to all rendered shapes. Already transparent paths will get proportionally more transparent as well.
func (*Context) SetLineCap ¶
SetLineCap sets how the end of the line (cap) is drawn, Can be one of: Butt (default), Round, Squre.
func (*Context) SetLineJoin ¶
SetLineJoin sets how sharp path corners are drawn. Can be one of Miter (default), Round, Bevel.
func (*Context) SetMiterLimit ¶
SetMiterLimit sets the miter limit of the stroke style. Miter limit controls when a sharp corner is beveled.
func (*Context) SetStrokeColor ¶
SetStrokeColor sets current stroke style to a solid color.
func (*Context) SetStrokePaint ¶
SetStrokePaint sets current stroke style to a paint, which can be a one of the gradients or a pattern.
func (*Context) SetStrokeWidth ¶
SetStrokeWidth sets the stroke width of the stroke style.
func (*Context) SetTextAlign ¶
SetTextAlign sets the text align of current text style.
func (*Context) SetTextLetterSpacing ¶
SetTextLetterSpacing sets the letter spacing of current text style.
func (*Context) SetTextLineHeight ¶
SetTextLineHeight sets the line height of current text style.
func (*Context) SetTransform ¶
func (c *Context) SetTransform(t TransformMatrix)
SetTransform premultiplies current coordinate system by specified matrix.
func (*Context) SetTransformByValue ¶
SetTransformByValue premultiplies current coordinate system by specified matrix. The parameters are interpreted as matrix as follows:
[a c e] [b d f] [0 0 1]
func (*Context) SkewX ¶
SkewX skews the current coordinate system along X axis. Angle is specified in radians.
func (*Context) SkewY ¶
SkewY skews the current coordinate system along Y axis. Angle is specified in radians.
func (*Context) Stroke ¶
func (c *Context) Stroke()
Stroke draws the current path with current stroke style.
func (*Context) StrokeWidth ¶
StrokeWidth gets the stroke width of the stroke style.
func (*Context) Text ¶
Text draws text string at specified location. If end is specified only the sub-string up to the end is drawn.
func (*Context) TextBounds ¶
TextBounds 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.
func (*Context) TextBox ¶
TextBox 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). Draws text string at specified location. If end is specified only the sub-string up to the end is drawn.
func (*Context) TextBoxBounds ¶
TextBoxBounds 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.
func (*Context) TextBreakLines ¶
TextBreakLines 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).
func (*Context) TextBreakLinesRune ¶
TextBreakLinesRune is an alternate version of TextBreakLines that accepts rune slice
func (*Context) TextGlyphPositions ¶
func (c *Context) TextGlyphPositions(x, y float32, str string) []GlyphPosition
TextGlyphPositions 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.
func (*Context) TextGlyphPositionsRune ¶
func (c *Context) TextGlyphPositionsRune(x, y float32, runes []rune) []GlyphPosition
TextGlyphPositionsRune is an alternate version of TextGlyphPositions that accepts rune slice
func (*Context) TextLetterSpacing ¶
TextLetterSpacing gets the letter spacing of current text style.
func (*Context) TextLineHeight ¶
TextLineHeight gets the line height of current text style.
func (*Context) TextMetrics ¶
TextMetrics returns the vertical metrics based on the current text style. Measured values are returned in local coordinate space.
type CreateFlags ¶
type CreateFlags int
CreateFlags is used when NewContext() to create NanoVGo context.
const ( // AntiAlias sets NanoVGo to use AA AntiAlias CreateFlags = 1 << 0 // StencilStrokes sets NanoVGo to use stencil buffer to draw strokes StencilStrokes CreateFlags = 1 << 1 // Debug shows OpenGL errors to console Debug CreateFlags = 1 << 2 )
type FrameBuffer ¶
type FrameBuffer struct {
// contains filtered or unexported fields
}
func (*FrameBuffer) Image ¶
func (fb *FrameBuffer) Image() int
type GlyphPosition ¶
type GlyphPosition struct { Index int // Position of the glyph in the input string. Runes []rune X float32 // The x-coordinate of the logical glyph position. MinX, MaxX float32 // The bounds of the glyph shape. }
GlyphPosition keeps glyph location information
type ImageFlags ¶
type ImageFlags int
ImageFlags is used for setting image object
const ( // ImageGenerateMipmaps generates mipmaps during creation of the image. ImageGenerateMipmaps ImageFlags = 1 << 0 // ImageRepeatX repeats image in X direction. ImageRepeatX ImageFlags = 1 << 1 // ImageRepeatY repeats image in X direction. ImageRepeatY ImageFlags = 1 << 2 // ImageFlippy flips (inverses) image in Y direction when rendered. ImageFlippy ImageFlags = 1 << 3 // ImagePreMultiplied specifies image data has premultiplied alpha. ImagePreMultiplied ImageFlags = 1 << 4 )
const ( // ImageNoDelete don't delete from memory when removing image ImageNoDelete ImageFlags = 1 << 16 )
type Paint ¶
type Paint struct {
// contains filtered or unexported fields
}
Paint structure represent paint information including gradient and image painting. Context.SetFillPaint() and Context.SetStrokePaint() accept this instance.
func BoxGradient ¶
BoxGradient 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 Context.FillPaint() or Context.StrokePaint().
func ImagePattern ¶
ImagePattern creates and returns an image patter. 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 Context.FillPaint() or Context.StrokePaint().
func LinearGradient ¶
LinearGradient 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 Context.FillPaint() or Context.StrokePaint().
func RadialGradient ¶
RadialGradient 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 Context.FillPaint() or Context.StrokePaint().
type TextRow ¶
type TextRow struct { Runes []rune // The input string. StartIndex int // Index to the input text where the row starts. EndIndex int // Index to the input text where the row ends (one past the last character). NextIndex int // Index to the beginning of the next row. Width float32 // Logical width of the row. MinX, MaxX float32 // Actual bounds of the row. Logical with and bounds can differ because of kerning and some parts over extending. }
TextRow keeps row geometry information
type TransformMatrix ¶
type TransformMatrix [6]float32
TransformMatrix is a 2x3 matrix is represented as float[6].
func IdentityMatrix ¶
func IdentityMatrix() TransformMatrix
IdentityMatrix makes the transform to identity matrix.
func RotateMatrix ¶
func RotateMatrix(a float32) TransformMatrix
RotateMatrix makes the transform to rotate matrix. Angle is specified in radians.
func ScaleMatrix ¶
func ScaleMatrix(sx, sy float32) TransformMatrix
ScaleMatrix makes the transform to scale matrix.
func SkewXMatrix ¶
func SkewXMatrix(a float32) TransformMatrix
SkewXMatrix makes the transform to skew-x matrix. Angle is specified in radians.
func SkewYMatrix ¶
func SkewYMatrix(a float32) TransformMatrix
SkewYMatrix makes the transform to skew-y matrix. Angle is specified in radians.
func TranslateMatrix ¶
func TranslateMatrix(tx, ty float32) TransformMatrix
TranslateMatrix makes the transform to translation matrix matrix.
func (TransformMatrix) Inverse ¶
func (t TransformMatrix) Inverse() TransformMatrix
Inverse makes the destination to inverse of specified transform. Returns 1 if the inverse could be calculated, else 0.
func (TransformMatrix) Multiply ¶
func (t TransformMatrix) Multiply(s TransformMatrix) TransformMatrix
Multiply makes the transform to the result of multiplication of two transforms, of A = A*B.
func (TransformMatrix) PreMultiply ¶
func (t TransformMatrix) PreMultiply(s TransformMatrix) TransformMatrix
PreMultiply makes the transform to the result of multiplication of two transforms, of A = B*A.
func (TransformMatrix) ToMat3x4 ¶
func (t TransformMatrix) ToMat3x4() []float32
ToMat3x4 makes 3x4 matrix.
func (TransformMatrix) TransformPoint ¶
func (t TransformMatrix) TransformPoint(sx, sy float32) (dx, dy float32)
TransformPoint transforms a point by given TransformMatrix.
Source Files ¶
Directories ¶
Path | Synopsis |
---|---|
truetype
This library processes TrueType files: - parse files - extract glyph metrics - extract glyph shapes - render glyphs to one-channel bitmaps with antialiasing (box filter)
|
This library processes TrueType files: - parse files - extract glyph metrics - extract glyph shapes - render glyphs to one-channel bitmaps with antialiasing (box filter) |