package
0.2.0
Repository: https://github.com/sugarme/lab.git
Documentation: pkg.go.dev

# README

Draw

Package draw provides APIs to draw and manipulate images.

Below are some real use cases.

Mask and bounding box

Image Mask

Acknowledgement

Most of the code here are taken and modified from

  1. https://github.com/fogleman/contourmap
  2. https://github.com/llgcode/draw2d

# Functions

Bresenham draws a line between (x0, y0) and (x1, y1).
DrawContour draws the given closed contour at the given sub-pixel offset.
DrawImage draws an image into dest using an affine transformation matrix, an op and a filter.
Extents returns the FontExtents for a font.
Flatten convert curves into straight segments keeping join segments info.
No description provided by the author
FromFloat64s returns a new ContourMap for the provided 2D grid of values.
FromFloat64s returns a new ContourMap for the provided function.
FromImage returns a new ContourMap for the provided image.
No description provided by the author
No description provided by the author
No description provided by the author
LoadFromPngFile Open a png file.
No description provided by the author
NewFolderFontCache creates FolderFontCache.
NewGlyphCache initializes a GlyphCache.
NewGraphicContext creates a new Graphic context from an image.
NewGraphicContextWithPainter creates a new Graphic context from an image and a Painter (see Freetype-go).
NewIdentityMatrix creates an identity transformation matrix.
No description provided by the author
NewMatrixFromRects creates a transformation matrix, combining a scale and a translation, that transform rectangle1 into rectangle2.
NewRotationMatrix creates a rotation transformation matrix.
NewScaleMatrix creates a transformation matrix with a sx, sy scale factor.
* * Create a new Graphic context from an image */.
NewSyncFolderFontCache creates SyncFolderFontCache.
NewTranslationMatrix creates a transformation matrix with a translation tx and ty translation parameter.
PolylineBresenham draws a polyline to an image.
No description provided by the author
SaveToPngFile create and save an image to a file using PNG format.
Changes the font cache backend used by the package.
No description provided by the author
No description provided by the author
SubdivideCubic a Bezier cubic curve in 2 equivalents Bezier cubic curves.
SubdivideQuad a Bezier quad curve in 2 equivalents Bezier quad curves.
TraceArc trace an arc using a Liner.
TraceCubic generate lines subdividing the cubic curve using a Liner flattening_threshold helps determines the flattening expectation of the curve.
TraceQuad generate lines subdividing the curve using a Liner flattening_threshold helps determines the flattening expectation of the curve.

# Constants

ArcToCmp is a ArcTo component in a Path.
BevelJoin represents cut segments joint.
BicubicFilter defines a bicubic filter.
BilinearFilter defines a bilinear filter.
ButtCap defines a squared shape exactly at the end of the line.
CloseCmp is a ArcTo component in a Path.
CubicCurveToCmp is a CubicCurveTo component in a Path.
CurveRecursionLimit represents the maximum recursion that is really necessary to subsivide a curve into straight lines.
FillRuleEvenOdd determines the "insideness" of a point in the shape by drawing a ray from that point to infinity in any direction and counting the number of path segments from the given shape that the ray crosses.
FillRuleWinding determines the "insideness" of a point in the shape by drawing a ray from that point to infinity in any direction and then examining the places where a segment of the shape crosses the ray.
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
HalignCenter Horizontally align to center.
HalignLeft Horizontally align to left.
HalignRight Horizontally align to right.
LinearFilter defines a linear filter.
LineToCmp is a LineTo component in a Path.
MiterJoin represents peaker segments joint.
MoveToCmp is a MoveTo component in a Path.
QuadCurveToCmp is a QuadCurveTo component in a Path.
RoundCap defines a rounded shape at the end of the line.
RoundJoin represents rounded segments joint.
ScalingFill the image is scaled to the smallest scale that allow the image to fully cover a rectangle width x height.
ScalingFit the image is scaled to the largest scale that allow the image to fit within a rectangle width x height.
ScalingHeight the image is scaled so that its height is exactly the given height.
ScalingNone no scaling applied.
ScalingSameArea the image is scaled so that its area is exactly the area of the given rectangle width x height.
ScalingStretch the image is stretched so that its width and height are exactly the given width and height.
ScalingWidth the image is scaled so that its width is exactly the given width.
SquareCap defines a squared shape at the end of the line.
ValignBaseline align text with the baseline of the font.
ValignBottom bottom aligned text.
ValignCenter centered text.
ValignTop top align text.

# Variables

No description provided by the author

# Structs

No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
FolderFontCache can Load font from folder.
No description provided by the author
FontExtents contains font metric information.
FTGraphicContext is the implementation of GraphicContext for a raster image.
No description provided by the author
Glyph represents a rune which has been converted to a Path and width.
GlyphCacheImp manage a map of glyphs without sync mecanism, not thread safe.
ImageScaling style attributes used to display the image.
No description provided by the author
Path stores points.
Point represents a 2D Cartesian point.
No description provided by the author
SolidFillStyle define style attributes for a solid fill style.
No description provided by the author
StrokeStyle keeps stroke style attributes that is used by the Stroke method of a Drawer.
SyncFolderFontCache can Load font from folder.
TextStyle describe text property.
Transformer apply the Matrix transformation tr.

# Interfaces

Flattener receive segment definition.
Types implementing this interface can be passed to SetFontCache to change the way fonts are being stored and retrieved.
GlyphCache manage a cache of glyphs.
GraphicContext describes the interface for the various backends (images, pdf, opengl, ...).
Liner receive segment definition.
Painter implements the freetype raster.Painter and has a SetColor method like the RGBAPainter.
PathBuilder describes the interface for path drawing.

# Type aliases

Contour is a list of Points which define an isoline.
FillRule defines the type for fill rules.
No description provided by the author
No description provided by the author
FontStyle defines bold and italic styles for the font It is possible to combine values for mixed styles, eg.
Function returns a height Z for the specified X, Y point in a 2D grid.
Halign Horizontal Alignment of the text.
ImageFilter defines the type of filter to use.
LineCap is the style of line extremities.
LineJoin is the style of segments joint.
Matrix represents an affine transformation.
PathCmp represents component of a path.
ScalingPolicy is a constant to define how to scale an image.
Valign Vertical Alignment of the text.