backendbase

package
v0.15.0 Latest Latest
Warning

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

Go to latest
Published: Jun 13, 2021 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

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

type ImagePatternData

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

type ImagePatternRepeat

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

type Mat [6]float64

func MatRotate

func MatRotate(radians float64) Mat

func MatScale

func MatScale(v Vec) Mat

func MatTranslate

func MatTranslate(v Vec) Mat

func (Mat) Invert

func (m Mat) Invert() Mat

func (Mat) Mat2

func (m Mat) Mat2() Mat2

func (Mat) Mul

func (m Mat) Mul(m2 Mat) Mat

func (*Mat) String

func (m *Mat) String() string

type Mat2

type Mat2 [4]float64

func (*Mat2) String

func (m *Mat2) String() string

type RadialGradient

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

type Vec

type Vec [2]float64

func (Vec) Add

func (v Vec) Add(v2 Vec) Vec

func (Vec) Angle

func (v Vec) Angle() float64

func (Vec) AngleTo

func (v Vec) AngleTo(v2 Vec) float64

func (Vec) Atan2

func (v Vec) Atan2() float64

func (Vec) Div

func (v Vec) Div(v2 Vec) Vec

func (Vec) Divf

func (v Vec) Divf(f float64) Vec

func (Vec) Dot

func (v Vec) Dot(v2 Vec) float64

func (Vec) Len

func (v Vec) Len() float64

func (Vec) LenSqr

func (v Vec) LenSqr() float64

func (Vec) Mul

func (v Vec) Mul(v2 Vec) Vec

func (Vec) MulMat

func (v Vec) MulMat(m Mat) Vec

func (Vec) MulMat2

func (v Vec) MulMat2(m Mat2) Vec

func (Vec) Mulf

func (v Vec) Mulf(f float64) Vec

func (Vec) Norm

func (v Vec) Norm() Vec

func (Vec) String

func (v Vec) String() string

func (Vec) Sub

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