backendbase

package
v0.12.1 Latest Latest
Warning

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

Go to latest
Published: Jun 2, 2020 License: BSD-3-Clause Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var MatIdentity = Mat{
	1, 0,
	0, 1,
	0, 0}

Functions

This section is empty.

Types

type Backend

type Backend interface {
	Size() (int, int)

	LoadImage(img image.Image) (Image, error)
	LoadImagePattern(data ImagePatternData) ImagePattern
	LoadLinearGradient(data Gradient) LinearGradient
	LoadRadialGradient(data Gradient) RadialGradient

	Clear(pts [4]Vec)
	Fill(style *FillStyle, pts []Vec, tf Mat, canOverlap bool)
	DrawImage(dimg Image, sx, sy, sw, sh float64, pts [4]Vec, alpha float64)
	FillImageMask(style *FillStyle, mask *image.Alpha, pts [4]Vec) // pts must have four points

	ClearClip()
	Clip(pts []Vec)

	GetImageData(x, y, w, h int) *image.RGBA
	PutImageData(img *image.RGBA, x, y int)

	CanUseAsImage(b Backend) bool
	AsImage() Image // can return nil if not supported
}

Backend is used by the canvas to actually do the final drawing. This enables the backend to be implemented by various methods (OpenGL, but also other APIs or software)

type FillStyle

type FillStyle struct {
	Color          color.RGBA
	Blur           float64
	LinearGradient LinearGradient
	RadialGradient RadialGradient
	Gradient       struct {
		X0, Y0  float64
		X1, Y1  float64
		RadFrom float64
		RadTo   float64
	}
	ImagePattern ImagePattern
}

FillStyle is the color and other details on how to fill

type Gradient

type Gradient []GradientStop

func (Gradient) ColorAt

func (g Gradient) ColorAt(pos float64) color.RGBA

type GradientStop

type GradientStop struct {
	Pos   float64
	Color color.RGBA
}

type Image

type Image interface {
	Width() int
	Height() int
	Size() (w, h int)
	Delete()
	Replace(src image.Image) error
}

type ImagePattern added in v0.7.1

type ImagePattern interface {
	Delete()
	Replace(data ImagePatternData)
}

type ImagePatternData added in v0.7.1

type ImagePatternData struct {
	Image     Image
	Transform [9]float64
	Repeat    ImagePatternRepeat
}

type ImagePatternRepeat added in v0.8.3

type ImagePatternRepeat uint8
const (
	Repeat ImagePatternRepeat = iota
	RepeatX
	RepeatY
	NoRepeat
)

Image pattern repeat constants

type LinearGradient

type LinearGradient interface {
	Delete()
	Replace(data Gradient)
}

type Mat added in v0.12.0

type Mat [6]float64

func MatRotate added in v0.12.0

func MatRotate(radians float64) Mat

func MatScale added in v0.12.0

func MatScale(v Vec) Mat

func MatTranslate added in v0.12.0

func MatTranslate(v Vec) Mat

func (Mat) Invert added in v0.12.0

func (m Mat) Invert() Mat

func (Mat) Mat2 added in v0.12.0

func (m Mat) Mat2() Mat2

func (Mat) Mul added in v0.12.0

func (m Mat) Mul(m2 Mat) Mat

func (*Mat) String added in v0.12.0

func (m *Mat) String() string

type Mat2 added in v0.12.0

type Mat2 [4]float64

func (*Mat2) String added in v0.12.0

func (m *Mat2) String() string

type RadialGradient

type RadialGradient interface {
	Delete()
	Replace(data Gradient)
}

type Vec added in v0.12.0

type Vec [2]float64

func (Vec) Add added in v0.12.0

func (v Vec) Add(v2 Vec) Vec

func (Vec) Angle added in v0.12.0

func (v Vec) Angle() float64

func (Vec) AngleTo added in v0.12.0

func (v Vec) AngleTo(v2 Vec) float64

func (Vec) Atan2 added in v0.12.0

func (v Vec) Atan2() float64

func (Vec) Div added in v0.12.0

func (v Vec) Div(v2 Vec) Vec

func (Vec) Divf added in v0.12.0

func (v Vec) Divf(f float64) Vec

func (Vec) Dot added in v0.12.0

func (v Vec) Dot(v2 Vec) float64

func (Vec) Len added in v0.12.0

func (v Vec) Len() float64

func (Vec) LenSqr added in v0.12.0

func (v Vec) LenSqr() float64

func (Vec) Mul added in v0.12.0

func (v Vec) Mul(v2 Vec) Vec

func (Vec) MulMat added in v0.12.0

func (v Vec) MulMat(m Mat) Vec

func (Vec) MulMat2 added in v0.12.0

func (v Vec) MulMat2(m Mat2) Vec

func (Vec) Mulf added in v0.12.0

func (v Vec) Mulf(f float64) Vec

func (Vec) Norm added in v0.12.0

func (v Vec) Norm() Vec

func (Vec) String added in v0.12.0

func (v Vec) String() string

func (Vec) Sub added in v0.12.0

func (v Vec) Sub(v2 Vec) Vec

Jump to

Keyboard shortcuts

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