context

package
v0.4.7 Latest Latest
Warning

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

Go to latest
Published: Apr 22, 2021 License: MIT Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var DefaultPartDefs = PartDefs{
	Scale: mat.V(1, 1),
	Mask:  rgba.White,
}

Functions

This section is empty.

Types

type C

type C []Part

C helps you draw complex objects built from multiple sprites

func (C) Draw

func (c C) Draw(t ggl.Target, matrix mat.Mat, mask mat.RGBA)

Draw draws context to target with applied transform and mask

func (C) Fetch

func (c C) Fetch(t ggl.Target)

func (*C) Init

func (c *C) Init(parts ...PartDefs)

Init Initialized context with given Defaults. This can be called multiple times on same context and it will be restarted. C is mant to be reused to reduce allocations.

func (C) Update

func (c C) Update(matrix mat.Mat, mask mat.RGBA)

Update updates the sprite transform of context

type Part

type Part struct {
	Def           PartDefs
	Spr           ggl.Sprite
	Offset, Scale mat.Vec
	Mask          mat.RGBA
	Rotation      float64
}

Part is a building piece of context, if contains lot of configuration that is combined with Default configuration to make a final transformation and color

func (*Part) TotalMask added in v0.4.6

func (p *Part) TotalMask() mat.RGBA

TotalMask returns total mask of part, taking PartDefs into account

func (*Part) TotalOffset added in v0.4.6

func (p *Part) TotalOffset() mat.Vec

TotalOffset returns total offset of part, taking PartDefs into account

func (*Part) TotalRotation added in v0.4.6

func (p *Part) TotalRotation() float64

TotalRotation returns total rotation of part, taking PartDefs into account

type PartDefs

type PartDefs struct {
	Offset, Pivot, Scale mat.Vec
	Rotation             float64
	Mask                 mat.RGBA
	Region               mat.AABB
}

PartDefs stores the default values for Part

Jump to

Keyboard shortcuts

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