Documentation ¶
Index ¶
- func AdjustImageForColor(mask image.Image, width int, height int, col color.Color) image.Image
- func Asset(name string) ([]byte, error)
- func AssetDir(name string) ([]string, error)
- func AssetInfo(name string) (os.FileInfo, error)
- func AssetNames() []string
- func CharPositions(family string, size float64, bold bool, italic bool, text string) ([]int, error)
- func CohenSutherland(x1, y1, x2, y2, left, top, right, bottom int) (int, int, int, int, bool)
- func Decode(r io.Reader) (image.Image, error)
- func DecodeAll(r io.Reader) ([]image.Image, error)
- func DecodeConfig(r io.Reader) (image.Config, error)
- func Font(family string, size float64, bold bool, italic bool) (result *truetype.Font, face font.Face, err error)
- func MakeFontFace(f *truetype.Font, size float64) font.Face
- func MeasureText(family string, size float64, bold bool, italic bool, text string, ...) (int, int, error)
- func MeasureTextFreeType(family string, size float64, bold bool, italic bool, text string, ...) (int, int, error)
- func MustAsset(name string) []byte
- func ParseFont(b []byte) (*truetype.Font, error)
- func Pt(x, y int) fixed.Point26_6
- func RestoreAsset(dir, name string) error
- func RestoreAssets(dir, name string) error
- type CanvasDirect
- func (c *CanvasDirect) ClipIn(x, y, width, height int)
- func (c *CanvasDirect) ClipInTranslated(x, y, width, height int)
- func (c *CanvasDirect) ClippedRegion() (int, int, int, int)
- func (c *CanvasDirect) DrawImage(x int, y int, img image.Image)
- func (c *CanvasDirect) DrawLine(x1 int, y1 int, x2 int, y2 int, width int, color color.Color)
- func (c *CanvasDirect) DrawPoint(x int, y int, color color.Color)
- func (c *CanvasDirect) DrawRect(x int, y int, width int, height int, color color.Color, strokeWidth int)
- func (c *CanvasDirect) DrawText(x int, y int, text string, fontFamily string, fontSize float64, ...)
- func (c *CanvasDirect) DrawTextMultiline(x int, y int, width int, height int, hAlign HAlign, vAlign VAlign, text string, ...)
- func (c *CanvasDirect) FillEntire(colr color.Color)
- func (c *CanvasDirect) FillRect(x int, y int, width int, height int, colr color.Color)
- func (c *CanvasDirect) Image() *image.RGBA
- func (c *CanvasDirect) Load()
- func (c *CanvasDirect) MakeScriptLine(x1, y1, x2, y2, width float64) *DrawScript
- func (c *CanvasDirect) MakeScriptLineBresenham(x1 float64, y1 float64, x2 float64, y2 float64) *DrawScript
- func (c *CanvasDirect) MakeScriptLineWu(x1, y1, x2, y2 float64) *DrawScript
- func (c *CanvasDirect) MixPixel(x int, y int, rgba color.Color)
- func (c *CanvasDirect) Save()
- func (c *CanvasDirect) State() CanvasDirectState
- func (c *CanvasDirect) Translate(x, y int)
- func (c *CanvasDirect) TranslatedX() int
- func (c *CanvasDirect) TranslatedY() int
- type CanvasDirectState
- type Context
- func (c *Context) DrawString(s string, p fixed.Point26_6) (fixed.Point26_6, error)
- func (c *Context) PointToFixed(x float64) fixed.Int26_6
- func (c *Context) SetClip(clip image.Rectangle)
- func (c *Context) SetDPI(dpi float64)
- func (c *Context) SetDst(dst draw.Image)
- func (c *Context) SetFont(f *truetype.Font)
- func (c *Context) SetFontSize(fontSize float64)
- func (c *Context) SetHinting(hinting font.Hinting)
- func (c *Context) SetSrc(src image.Image)
- type DrawScript
- type DrawScriptHorLine
- type DrawScriptPoint
- type FontInfo
- type FontMeasureData
- type HAlign
- type VAlign
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AdjustImageForColor ¶
func Asset ¶
Asset loads and returns the asset for the given name. It returns an error if the asset could not be found or could not be loaded.
func AssetDir ¶
AssetDir returns the file names below a certain directory embedded in the file by go-bindata. For example if you run go-bindata on data/... and data contains the following hierarchy:
data/ foo.txt img/ a.png b.png
then AssetDir("data") would return []string{"foo.txt", "img"} AssetDir("data/img") would return []string{"a.png", "b.png"} AssetDir("foo.txt") and AssetDir("notexist") would return an error AssetDir("") will return []string{"data"}.
func AssetInfo ¶
AssetInfo loads and returns the asset info for the given name. It returns an error if the asset could not be found or could not be loaded.
func CharPositions ¶
func CohenSutherland ¶
func MeasureText ¶
func MeasureTextFreeType ¶
func MustAsset ¶
MustAsset is like Asset but panics when Asset would return an error. It simplifies safe initialization of global variables.
func ParseFont ¶
ParseFont just calls the Parse function from the freetype/truetype package. It is provided here so that code that imports this package doesn't need to also include the freetype/truetype package.
func Pt ¶
Pt converts from a co-ordinate pair measured in pixels to a fixed.Point26_6 co-ordinate pair measured in fixed.Int26_6 units.
func RestoreAsset ¶
RestoreAsset restores an asset under the given directory
func RestoreAssets ¶
RestoreAssets restores an asset under the given directory recursively
Types ¶
type CanvasDirect ¶
func NewCanvas ¶
func NewCanvas(width int, height int) *CanvasDirect
func NewCanvasWindow ¶
func NewCanvasWindow(width int, height int) *CanvasDirect
func (*CanvasDirect) ClipIn ¶
func (c *CanvasDirect) ClipIn(x, y, width, height int)
func (*CanvasDirect) ClipInTranslated ¶
func (c *CanvasDirect) ClipInTranslated(x, y, width, height int)
func (*CanvasDirect) ClippedRegion ¶
func (c *CanvasDirect) ClippedRegion() (int, int, int, int)
func (*CanvasDirect) DrawTextMultiline ¶
func (*CanvasDirect) FillEntire ¶
func (c *CanvasDirect) FillEntire(colr color.Color)
func (*CanvasDirect) Image ¶
func (c *CanvasDirect) Image() *image.RGBA
func (*CanvasDirect) Load ¶
func (c *CanvasDirect) Load()
func (*CanvasDirect) MakeScriptLine ¶
func (c *CanvasDirect) MakeScriptLine(x1, y1, x2, y2, width float64) *DrawScript
func (*CanvasDirect) MakeScriptLineBresenham ¶
func (c *CanvasDirect) MakeScriptLineBresenham(x1 float64, y1 float64, x2 float64, y2 float64) *DrawScript
func (*CanvasDirect) MakeScriptLineWu ¶
func (c *CanvasDirect) MakeScriptLineWu(x1, y1, x2, y2 float64) *DrawScript
func (*CanvasDirect) Save ¶
func (c *CanvasDirect) Save()
func (*CanvasDirect) State ¶
func (c *CanvasDirect) State() CanvasDirectState
func (*CanvasDirect) Translate ¶
func (c *CanvasDirect) Translate(x, y int)
func (*CanvasDirect) TranslatedX ¶
func (c *CanvasDirect) TranslatedX() int
func (*CanvasDirect) TranslatedY ¶
func (c *CanvasDirect) TranslatedY() int
type CanvasDirectState ¶
type CanvasDirectState struct { TranslateX int TranslateY int ClipX int ClipY int ClipWidth int ClipHeight int }
func (*CanvasDirectState) String ¶
func (c *CanvasDirectState) String() string
type Context ¶
type Context struct {
// contains filtered or unexported fields
}
A Context holds the state for drawing text in a given font and size.
func FontContext ¶
func (*Context) DrawString ¶
DrawString draws s at p and returns p advanced by the text extent. The text is placed so that the left edge of the em square of the first character of s and the baseline intersect at p. The majority of the affected pixels will be above and to the right of the point, but some may be below or to the left. For example, drawing a string that starts with a 'J' in an italic font may affect pixels below and left of the point.
p is a fixed.Point26_6 and can therefore represent sub-pixel positions.
func (*Context) PointToFixed ¶
PointToFixed converts the given number of points (as in "a 12 point font") into a 26.6 fixed point number of pixels.
func (*Context) SetFontSize ¶
SetFontSize sets the font size in points (as in "a 12 point font").
func (*Context) SetHinting ¶
SetHinting sets the hinting policy.
type DrawScript ¶
func NewDrawScript ¶
func NewDrawScript() *DrawScript
func (*DrawScript) DrawToRGBA ¶
func (c *DrawScript) DrawToRGBA(img *image.RGBA, col color.Color)