Documentation ¶
Index ¶
- Constants
- Variables
- func ColorToScale(clr color.Color) (float64, float64, float64, float64)
- func DrawNineSlicing(dst, src *ebiten.Image, sliceKey *SliceKey, width int, height int, ...)
- func DrawNineSlicingProgress(dst, src *ebiten.Image, sliceKey *SliceKey, width int, height int, ...)
- func Index(gid uint32) uint32
- type Animation
- type BoundStringCacheEntry
- type Direction
- type Edge
- type Font
- type GID
- func (g GID) D() bool
- func (g GID) H() bool
- func (g GID) Index() uint32
- func (g GID) Rotation() (rotation int)
- func (g GID) SetD(val bool)
- func (g GID) SetH(val bool)
- func (g GID) SetRotation(rotation int) (err error)
- func (g GID) SetV(val bool)
- func (g GID) SetValue() uint32
- func (g GID) V() bool
- func (g GID) Value() uint32
- type Image
- type Item
- type LerpColor
- func (lc *LerpColor) EndFunc() func()
- func (lc *LerpColor) Init(start time.Time, startColor color.Color, endColor color.Color, ...)
- func (lc *LerpColor) IsDestroyed() bool
- func (lc *LerpColor) IsEnabled() bool
- func (lc *LerpColor) IsEndFuncSet() bool
- func (lc *LerpColor) Lerp() (newColor color.Color)
- func (lc *LerpColor) SetEndFunc(endFunc func())
- func (lc *LerpColor) SetIsDestroyed(isDestroyed bool)
- func (lc *LerpColor) SetIsEnabled(isEnabled bool)
- type LerpPosition
- func (lc *LerpPosition) EndFunc() func()
- func (lc *LerpPosition) Init(start time.Time, ...)
- func (lc *LerpPosition) IsDestroyed() bool
- func (lc *LerpPosition) IsEnabled() bool
- func (lc *LerpPosition) IsEndFuncSet() bool
- func (lc *LerpPosition) Lerp() (x float64, y float64)
- func (lc *LerpPosition) SetEndFunc(endFunc func())
- func (lc *LerpPosition) SetIsDestroyed(isDestroyed bool)
- func (lc *LerpPosition) SetIsEnabled(isEnabled bool)
- type Node
- type Path
- type PriorityQueue
- type Rectangle
- type Slice
- type SliceKey
- type Vector
- func (v *Vector) Add(nv *Vector) *Vector
- func (v *Vector) Angle() float64
- func (v *Vector) Copy() *Vector
- func (v *Vector) Cross(nv *Vector) float64
- func (v *Vector) Dot(nv *Vector) float64
- func (v *Vector) Equal(nv *Vector) bool
- func (v *Vector) Len() float64
- func (v *Vector) Lerp(a *Vector, b *Vector, t float64) *Vector
- func (v *Vector) Map(f func(float64) float64) *Vector
- func (v *Vector) Normal() *Vector
- func (v *Vector) Project(nv *Vector) *Vector
- func (v *Vector) Rotated(angle float64) *Vector
- func (v *Vector) Scaled(s float64) *Vector
- func (v *Vector) ScaledXY(nv *Vector) *Vector
- func (v *Vector) String() string
- func (v *Vector) Sub(nv *Vector) *Vector
- func (v *Vector) Unit() *Vector
- func (v *Vector) XY() (x, y float64)
Constants ¶
const ( // Up is a direction Up = Direction(0) // Right is a direction Right = Direction(1) // Down is a direction Down = Direction(2) // Left is a direction Left = Direction(3) )
Variables ¶
var ( // ErrElementNameInvalid is returned when a element name has invalid characters or too short ErrElementNameInvalid = fmt.Errorf("element name invalid") // ErrElementAlreadyExists is returned when a element already exists ErrElementAlreadyExists = fmt.Errorf("element already exists") // ErrElementNotFound is returned when a element is not loaded into the UI ErrElementNotFound = fmt.Errorf("element not found") // ErrFontNameInvalid is returned when a font name has invalid characters or too short ErrFontNameInvalid = fmt.Errorf("font name invalid") // ErrFontAlreadyExists is returned when a font already exists ErrFontAlreadyExists = fmt.Errorf("font already exists") // ErrFontNotFound is returned when a font was not found ErrFontNotFound = fmt.Errorf("font not found") // ErrFontCannotRemoveDefault is returned when you attempt to delete a font currently set as default ErrFontCannotRemoveDefault = fmt.Errorf("font is default, cannot remove") // ErrImageNameInvalid is returned when a image name has invalid characters or too short ErrImageNameInvalid = fmt.Errorf("image name invalid") // ErrImageAlreadyExists is returned when a image already exists ErrImageAlreadyExists = fmt.Errorf("image already exists") // ErrImageNotFound is returned when a image was not found ErrImageNotFound = fmt.Errorf("image not found") // ErrSceneNameInvalid is returned when a scene name has invalid characters or too short ErrSceneNameInvalid = fmt.Errorf("scene name invalid") // ErrSceneAlreadyExists is returned when a Scene already exists ErrSceneAlreadyExists = fmt.Errorf("scene already exists") // ErrSceneNotFound is returned when a scene is not loaded into the UI ErrSceneNotFound = fmt.Errorf("scene not found") )
var ( // ErrSliceNameInvalid is returned when a slice name has invalid characters or too short ErrSliceNameInvalid = fmt.Errorf("slice name invalid") // ErrSliceAlreadyExists is returned when a slice already exists ErrSliceAlreadyExists = fmt.Errorf("slice already exists") // ErrSliceNotFound is returned when a slice is not loaded into the UI ErrSliceNotFound = fmt.Errorf("slice not found") )
var ( // ErrNoNodesLoaded is returned when a path is called before any nodes are set ErrNoNodesLoaded = fmt.Errorf("no nodes are loaded") // ErrRouteNotFound is returned when all options are exhausted ErrRouteNotFound = fmt.Errorf("route not found") )
var ZV = &Vector{0, 0}
ZV is a zero vector
Functions ¶
func ColorToScale ¶ added in v0.0.11
ColorToScale translates a color to ColorM
func DrawNineSlicing ¶ added in v0.0.11
func DrawNineSlicing(dst, src *ebiten.Image, sliceKey *SliceKey, width int, height int, geoM *ebiten.GeoM, colorM *ebiten.ColorM)
DrawNineSlicing will render slicing data
Types ¶
type Animation ¶ added in v0.0.11
type Animation struct { //Counter tracks what animation frame is currently being played Counter int //Current sprite name being played CurrentName string //Speed to play animation Speed int //If the sheet has multiple sprites, which index of the bundle to use BundleIndex int CellWidth float64 CellHeight float64 Image string Alpha string Clips [][]int BundleCount int Animations map[string][][]float64 }
Animation handles animation details
type BoundStringCacheEntry ¶ added in v0.0.11
type BoundStringCacheEntry struct {
// contains filtered or unexported fields
}
BoundStringCacheEntry is used for font boundings
type Font ¶ added in v0.0.11
type Font struct { Face font.Face Height int Name string Language language.Tag BoundStringCache map[font.Face]map[string]*BoundStringCacheEntry RenderingLineHeight int }
Font contains related data for loading a font file
type GID ¶ added in v0.0.11
type GID struct {
// contains filtered or unexported fields
}
GID represents a global ID, uses rotation padding on the last 3 bytes
func (GID) Rotation ¶ added in v0.0.11
Rotation returns the rotation of the object. Can only be 0, 90, 180, or 270
func (GID) SetRotation ¶ added in v0.0.11
SetRotation sets the rotation of a tile clockwise, supports 0, 90, 180, 270
type Image ¶ added in v0.0.11
type Image struct { Name string EbitenImage *ebiten.Image Slices map[string]*Slice Animation *Animation }
Image is a base type representing a nebiten image with added details on how to render. An image is not rendered, instead placed into a cache
func (*Image) RemoveSlice ¶ added in v0.0.11
RemoveSlice removes 9slicing data from an image
type Item ¶ added in v0.0.9
type Item struct {
// contains filtered or unexported fields
}
Item represents a node item
type LerpColor ¶ added in v0.0.11
type LerpColor struct {
// contains filtered or unexported fields
}
LerpColor handles color lerp interpolations
func (*LerpColor) EndFunc ¶ added in v0.0.11
func (lc *LerpColor) EndFunc() func()
EndFunc returns the end function
func (*LerpColor) Init ¶ added in v0.0.11
func (lc *LerpColor) Init(start time.Time, startColor color.Color, endColor color.Color, duration time.Duration, endFunc func(), isDestroyedAtEnd bool)
Init sets up a new lerp
func (*LerpColor) IsDestroyed ¶ added in v0.0.11
IsDestroyed returns if enabled
func (*LerpColor) IsEndFuncSet ¶ added in v0.0.11
IsEndFuncSet returns true if EndFunc exists
func (*LerpColor) SetEndFunc ¶ added in v0.0.11
func (lc *LerpColor) SetEndFunc(endFunc func())
SetEndFunc sets a function to call on end of lerp
func (*LerpColor) SetIsDestroyed ¶ added in v0.0.11
SetIsDestroyed sets if destroyed on next frame or not
func (*LerpColor) SetIsEnabled ¶ added in v0.0.11
SetIsEnabled sets if enabled or not
type LerpPosition ¶ added in v0.0.11
type LerpPosition struct {
// contains filtered or unexported fields
}
LerpPosition handles vector lerp interpolations
func (*LerpPosition) EndFunc ¶ added in v0.0.11
func (lc *LerpPosition) EndFunc() func()
EndFunc returns the end function
func (*LerpPosition) Init ¶ added in v0.0.11
func (lc *LerpPosition) Init(start time.Time, startPositionX, startPositionY, endPositionX, endPositionY float64, duration time.Duration, isEnabled bool, endFunc func(), isDestroyedAtEnd bool)
Init sets up a new lerp
func (*LerpPosition) IsDestroyed ¶ added in v0.0.11
func (lc *LerpPosition) IsDestroyed() bool
IsDestroyed returns if enabled
func (*LerpPosition) IsEnabled ¶ added in v0.0.11
func (lc *LerpPosition) IsEnabled() bool
IsEnabled returns if enabled
func (*LerpPosition) IsEndFuncSet ¶ added in v0.0.11
func (lc *LerpPosition) IsEndFuncSet() bool
IsEndFuncSet returns true if EndFunc exists
func (*LerpPosition) Lerp ¶ added in v0.0.11
func (lc *LerpPosition) Lerp() (x float64, y float64)
Lerp returns a position
func (*LerpPosition) SetEndFunc ¶ added in v0.0.11
func (lc *LerpPosition) SetEndFunc(endFunc func())
SetEndFunc sets a function to call on end of lerp
func (*LerpPosition) SetIsDestroyed ¶ added in v0.0.11
func (lc *LerpPosition) SetIsDestroyed(isDestroyed bool)
SetIsDestroyed sets if destroyed on next frame or not
func (*LerpPosition) SetIsEnabled ¶ added in v0.0.11
func (lc *LerpPosition) SetIsEnabled(isEnabled bool)
SetIsEnabled sets if enabled or not
type Node ¶ added in v0.0.9
Node represents an element in the grid
type Path ¶ added in v0.0.9
type Path struct {
// contains filtered or unexported fields
}
Path represents a navigation mesh
type PriorityQueue ¶ added in v0.0.9
type PriorityQueue []*Item
PriorityQueue is an array of items
func (PriorityQueue) Len ¶ added in v0.0.9
func (pq PriorityQueue) Len() int
func (PriorityQueue) Less ¶ added in v0.0.9
func (pq PriorityQueue) Less(i, j int) bool
func (*PriorityQueue) Pop ¶ added in v0.0.9
func (pq *PriorityQueue) Pop() interface{}
Pop removes an item from a queue
func (*PriorityQueue) Push ¶ added in v0.0.9
func (pq *PriorityQueue) Push(x interface{})
Push add an item to a queue
func (PriorityQueue) Swap ¶ added in v0.0.9
func (pq PriorityQueue) Swap(i, j int)
type Rectangle ¶
type Rectangle struct {
Min, Max Vector
}
Rectangle is a 2D rectangle aligned with the axes of the coordinate system. It is defined by two points, Min and Max.
The invariant should hold, that Max's components are greater or equal than Min's components respectively.
func RectImageCopy ¶
RectImageCopy converts an image rectangle to model rect
type SliceKey ¶ added in v0.0.11
type SliceKey struct { Frame int Bounds struct { X int Y int W int H int } Center struct { X int Y int W int H int } Pivot struct { X int Y int } }
SliceKey represents each slice's key data
type Vector ¶
type Vector struct {
X, Y float64
}
Vector is a 2D vector type with X and Y coordinates
func NewVectorFromPoint ¶
NewVectorFromPoint converts an image point to a vector
func (*Vector) Angle ¶
Angle returns the angle between the vector u and the x-axis. The result is in range [-Pi, Pi].
func (*Vector) Lerp ¶
Lerp returns a linear interpolation between vector a and b.
This function basically returns a point along the line between a and b and t chooses which one. If t is 0, then a will be returned, if t is 1, b will be returned. Anything between 0 and 1 will return the appropriate point between a and b and so on.
func (*Vector) Map ¶
Map applies the function f to both x and y components of the vector u and returns the modified vector.
u := pixel.V(10.5, -1.5) v := nv.Map(math.Floor) // v is Vector(10, -2), both components of u floored
func (*Vector) Normal ¶
Normal returns a vector normal to nv. Equivalent to nv.Rotated(math.Pi / 2), but faster.
func (*Vector) Project ¶
Project returns a projection (or component) of vector u in the direction of vector v.
Behaviour is undefined if v is a zero vector.