graphics

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Oct 4, 2022 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewFrameClip

func NewFrameClip(
	target *Sprite,
	sheet *SpriteSheet,
	duration float64,
	options ...mathf.TweenOption,
) *mathf.Tween

func SubImageWidthHeight

func SubImageWidthHeight(img *ebiten.Image, x, y, width, height int) *ebiten.Image

Types

type AnimationClip

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

func NewAnimationClip

func NewAnimationClip(ticker *mathf.Ticker, tweens ...*mathf.Tween) *AnimationClip

func (*AnimationClip) Pause

func (ac *AnimationClip) Pause()

func (*AnimationClip) Resume

func (ac *AnimationClip) Resume()

func (*AnimationClip) Start

func (ac *AnimationClip) Start()

type Camera

type Camera interface {
	igloo.Dirtier

	// WorldToScreen will convert a world matrix into a screen matrix for rendering
	WorldToScreen(ebiten.GeoM) ebiten.GeoM

	// ScreenToWorld will convert an X,Y coordinate from the screen to its world position
	ScreenToWorld(screen image.Point) mathf.Vec2

	// IsInView returns whether or not a rectangle is within the cameras view.
	IsInView(bounds mathf.Bounds) bool
}

Camera allows you to move through a large scene without having to modify each individual element. To allow for any type of camera ( or none at all ) instead of defining specifics on how the camera works or behaves in relation to elements we instead define how the elements behave with the camera.

That is, if your element should interact with a possible moving camera have its world position modified to use the screen position from WorldToScreen. If your element should not be affected by a camera, such as a UI element, do not use the world to screen function.

To avoid drawing anything off screen check if it is in view first.

type Drawer

type Drawer interface {
	Draw(dest *ebiten.Image, camera Camera)
}

Drawer is the default drawing method

type Label

type Label struct {
	Transform *mathf.Transform
	Visible   bool
	// contains filtered or unexported fields
}

func NewLabel

func NewLabel(
	font font.Face,
	labelText string,
	color color.Color,
	options ...mathf.TransformOption,
) *Label

func (*Label) Color

func (l *Label) Color() color.Color

func (*Label) Draw

func (l *Label) Draw(dest *ebiten.Image, camera Camera)

func (*Label) Font

func (l *Label) Font() font.Face

func (*Label) SetColor added in v0.3.0

func (l *Label) SetColor(color color.Color)

func (*Label) SetFont

func (l *Label) SetFont(newFont font.Face)

func (*Label) SetText

func (l *Label) SetText(newText string)

func (*Label) Text

func (l *Label) Text() string

type NineSlice

type NineSlice struct {
	Image     *ebiten.Image
	Transform *mathf.Transform
	Visible   bool
	// contains filtered or unexported fields
}

NineSlice represents a renderable slicable element in the world.

func NewNineSlice

func NewNineSlice(
	image *ebiten.Image,
	borders SliceBorders,
	options ...mathf.TransformOption,
) *NineSlice

NewNineSlice will create a nine slice from an image and border values Defaults include: * Width and height of the image * Position at 0,0 * Rotation of 0 * Anchor in the middle center

func (*NineSlice) Draw

func (s *NineSlice) Draw(dest *ebiten.Image, camera Camera)

Draw will render the sprite onto the canvas. If our transform, sprite or camera are dirty then we will update internal values accordingly.

type SliceBorders

type SliceBorders struct {
	// Width of the left column
	Left int
	// Width of the center column
	Center int
	// Width of the right column
	Right int
	// Height of the top row
	Top int
	// Height of the middle row
	Middle int
	// Height of the bottom row
	Bottom int
}

SliceBorders organizes the sizes for our nine slice to generate the internal sprites.

func (*SliceBorders) BottomCenterSprite

func (b *SliceBorders) BottomCenterSprite(img *ebiten.Image) *Sprite

func (*SliceBorders) BottomLeftSprite

func (b *SliceBorders) BottomLeftSprite(img *ebiten.Image) *Sprite

func (*SliceBorders) BottomRightSprite

func (b *SliceBorders) BottomRightSprite(img *ebiten.Image) *Sprite

func (*SliceBorders) MiddleCenterSprite

func (b *SliceBorders) MiddleCenterSprite(img *ebiten.Image) *Sprite

func (*SliceBorders) MiddleLeftSprite

func (b *SliceBorders) MiddleLeftSprite(img *ebiten.Image) *Sprite

func (*SliceBorders) MiddleRightSprite

func (b *SliceBorders) MiddleRightSprite(img *ebiten.Image) *Sprite

func (*SliceBorders) TopCenterSprite

func (b *SliceBorders) TopCenterSprite(img *ebiten.Image) *Sprite

func (*SliceBorders) TopLeftSprite

func (b *SliceBorders) TopLeftSprite(img *ebiten.Image) *Sprite

func (*SliceBorders) TopRightSprite

func (b *SliceBorders) TopRightSprite(img *ebiten.Image) *Sprite

type Sprite

type Sprite struct {
	Image     *ebiten.Image
	Transform *mathf.Transform
	Visible   bool
	// DrawOptions when drawing, note that the GeoM value is controlled
	// by the transform so changing it here will get overridden.
	DrawOptions *ebiten.DrawImageOptions
	// contains filtered or unexported fields
}

Sprite represents a renderable element in the world.

func NewSprite

func NewSprite(image *ebiten.Image, options ...mathf.TransformOption) *Sprite

NewSprite will create a sprite with image and transform options. Will configure transform to use the size of our image as the natural size.

func NewSpriteWithDrawOptions added in v0.3.0

func NewSpriteWithDrawOptions(
	image *ebiten.Image,
	drawOptions ebiten.DrawImageOptions,
	options ...mathf.TransformOption,
) *Sprite

func NewSpriteWithTransform added in v0.3.0

func NewSpriteWithTransform(image *ebiten.Image, transform *mathf.Transform) *Sprite

NewSprite will create a sprite with image and transform. Will configure transform to use the size of our image as the natural size.

func (*Sprite) Draw

func (s *Sprite) Draw(dest *ebiten.Image, camera Camera)

Draw will render the sprite onto the canvas. If our transform, sprite or camera are dirty then we will update internal values accordingly.

type SpriteSheet

type SpriteSheet []*ebiten.Image

SpriteSheet represents a collection of images

func SheetFromGrid

func SheetFromGrid(sheet *ebiten.Image, columns, rows, frames int) *SpriteSheet

func (*SpriteSheet) FrameAt

func (ss *SpriteSheet) FrameAt(percent float64) *ebiten.Image

Jump to

Keyboard shortcuts

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