gg

package
v0.0.0-...-dc2a4c0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 8, 2023 License: MIT Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func LoadFontFace

func LoadFontFace(path string, points float64) (font.Face, error)

LoadFontFace is a helper function to load the specified font file with the specified point size. Note that the returned `font.Face` objects are not thread safe and cannot be used in parallel across goroutines. You can usually just use the Context.LoadFontFace function instead of this package-level function.

func SavePNG

func SavePNG(path string, im image.Image) error

Types

type Align

type Align int
const (
	AlignLeft Align = iota
	AlignCenter
	AlignRight
)

type Context

type Context struct {
	// contains filtered or unexported fields
}

func NewContext

func NewContext(width, height int) *Context

NewContext creates a new image.RGBA with the specified width and height and prepares a context for rendering onto that image.

func NewContextForGray

func NewContextForGray(im *image.Gray) *Context

NewContextForRGBA prepares a context for rendering onto the specified image. No copy is made.

func (*Context) Clear

func (dc *Context) Clear()

Clear fills the entire image with the current color.

func (*Context) DrawStringAnchored

func (dc *Context) DrawStringAnchored(s string, x, y, ax, ay float64)

DrawStringAnchored draws the specified text at the specified anchor point. The anchor point is x - w * ax, y - h * ay, where w, h is the size of the text. Use ax=0.5, ay=0.5 to center the text at the specified point.

func (*Context) LoadFontFace

func (dc *Context) LoadFontFace(path string, points float64) error

func (*Context) MeasureString

func (dc *Context) MeasureString(s string) (w, h float64)

MeasureString returns the rendered width and height of the specified text given the current font face.

func (*Context) SavePNG

func (dc *Context) SavePNG(path string) error

SavePNG encodes the image as a PNG and writes it to disk.

func (*Context) SetRGB

func (dc *Context) SetRGB(r float64)

SetRGB sets the current color. r, g, b values should be between 0 and 1, inclusive. Alpha will be set to 1 (fully opaque).

func (*Context) SetRGBA

func (dc *Context) SetRGBA(r float64)

SetRGBA sets the current color. r, g, b, a values should be between 0 and 1, inclusive.

type FillRule

type FillRule int
const (
	FillRuleWinding FillRule = iota
	FillRuleEvenOdd
)

type LineCap

type LineCap int
const (
	LineCapRound LineCap = iota
	LineCapButt
	LineCapSquare
)

type LineJoin

type LineJoin int
const (
	LineJoinRound LineJoin = iota
	LineJoinBevel
)

type Matrix

type Matrix struct {
	XX, YX, XY, YY, X0, Y0 float64
}

func Identity

func Identity() Matrix

func Rotate

func Rotate(angle float64) Matrix

func Scale

func Scale(x, y float64) Matrix

func Shear

func Shear(x, y float64) Matrix

func Translate

func Translate(x, y float64) Matrix

func (Matrix) Multiply

func (a Matrix) Multiply(b Matrix) Matrix

func (Matrix) Rotate

func (a Matrix) Rotate(angle float64) Matrix

func (Matrix) Scale

func (a Matrix) Scale(x, y float64) Matrix

func (Matrix) Shear

func (a Matrix) Shear(x, y float64) Matrix

func (Matrix) TransformPoint

func (a Matrix) TransformPoint(x, y float64) (tx, ty float64)

func (Matrix) TransformVector

func (a Matrix) TransformVector(x, y float64) (tx, ty float64)

func (Matrix) Translate

func (a Matrix) Translate(x, y float64) Matrix

type Pattern

type Pattern interface {
	ColorAt(x, y int) color.Color
}

func NewSolidPattern

func NewSolidPattern(color color.Color) Pattern

func NewSurfacePattern

func NewSurfacePattern(im image.Image, op RepeatOp) Pattern

type Point

type Point struct {
	X, Y float64
}

func (Point) Distance

func (a Point) Distance(b Point) float64

func (Point) Fixed

func (a Point) Fixed() fixed.Point26_6

func (Point) Interpolate

func (a Point) Interpolate(b Point, t float64) Point

type RepeatOp

type RepeatOp int
const (
	RepeatBoth RepeatOp = iota
	RepeatX
	RepeatY
	RepeatNone
)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL