draws

package
v1.0.3 Latest Latest
Warning

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

Go to latest
Published: Nov 6, 2022 License: Apache-2.0 Imports: 12 Imported by: 1

Documentation

Index

Constants

View Source
const (
	ButtonModePressed = iota
	ButtonModeClicked // onClick goes called when mouse button is pressed and released.
)
View Source
const (
	Left = iota
	Center
	Right
)
View Source
const (
	Top = iota
	Middle
	Bottom
)

Variables

View Source
var (
	LeftTop      = struct{ X, Y int }{Left, Top}
	LeftMiddle   = struct{ X, Y int }{Left, Middle}
	LeftBottom   = struct{ X, Y int }{Left, Bottom}
	CenterTop    = struct{ X, Y int }{Center, Top}
	CenterMiddle = struct{ X, Y int }{Center, Middle}
	CenterBottom = struct{ X, Y int }{Center, Bottom}
	RightTop     = struct{ X, Y int }{Right, Top}
	RightMiddle  = struct{ X, Y int }{Right, Middle}
	RightBottom  = struct{ X, Y int }{Right, Bottom}
)

https://go.dev/play/p/6FsxRuznEtE

Functions

func NewImage

func NewImage(path string) *ebiten.Image

NewImage returns nil when fails to load image from the path.

func NewImageImage

func NewImageImage(path string) image.Image

NewImageImage returns image.Image.

func NewImages added in v0.2.4

func NewImages(path string) (is []*ebiten.Image)

func NewScaledImage

func NewScaledImage(i *ebiten.Image, scale float64) *ebiten.Image

func NewXFlippedImage

func NewXFlippedImage(i *ebiten.Image) *ebiten.Image

func NewYFlippedImage

func NewYFlippedImage(i *ebiten.Image) *ebiten.Image

Types

type Align

type Align struct{ X, Y int }

type Animation added in v0.2.4

type Animation []Sprite

func NewAnimation added in v0.2.4

func NewAnimation(path string) Animation

func NewAnimationFromImages added in v0.2.4

func NewAnimationFromImages(images []*ebiten.Image) (a Animation)

type Box

type Box struct {
	Scale Point
	Point
	Origin Origin
	Filter ebiten.Filter
}

func NewBox added in v0.2.4

func NewBox() Box

func (*Box) ApplyScale added in v0.2.4

func (b *Box) ApplyScale(scale float64)

func (Box) In

func (b Box) In(size, p Point) bool

func (Box) Max added in v0.2.4

func (b Box) Max(size Point) Point

func (Box) Min added in v0.2.4

func (b Box) Min(size Point) (min Point)

func (*Box) Move added in v0.2.4

func (b *Box) Move(x, y float64)

func (*Box) SetPoint added in v0.2.4

func (b *Box) SetPoint(x, y float64, origin Origin)

func (*Box) SetScale added in v0.2.4

func (b *Box) SetScale(scale Point)

func (Box) XY added in v0.2.4

func (b Box) XY(size Point) (float64, float64)

type Button

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

func NewButton added in v0.2.4

func NewButton(s Subject, onClick func(), mode ButtonMode) Button

func (*Button) Hover

func (b *Button) Hover() bool

func (*Button) Update

func (b *Button) Update()

type ButtonMode added in v0.2.4

type ButtonMode int

type Label

type Label struct {
	Text  string
	Face  font.Face
	Color color.Color
	Box
}

Label may have expecting w and h by selecting specific Face.

func NewLabel

func NewLabel(text string, face font.Face) *Label

func (Label) Draw

func (l Label) Draw(screen *ebiten.Image, op ebiten.DrawImageOptions)

func (*Label) SetSize

func (l *Label) SetSize(size Point)

func (Label) Size

func (l Label) Size() Point

func (Label) SrcSize added in v0.2.4

func (l Label) SrcSize() Point

type Origin

type Origin struct{ X, Y int }

type Point

type Point struct{ X, Y float64 }

func IntPt

func IntPt(x, y int) Point

Input integers.

func Pt

func Pt(x, y float64) Point

func Scalar

func Scalar(v float64) Point

func (Point) Add

func (p Point) Add(q Point) Point

func (Point) Div

func (p Point) Div(q Point) Point

func (Point) Mul

func (p Point) Mul(q Point) Point

func (Point) Sub

func (p Point) Sub(q Point) Point

func (Point) XY

func (p Point) XY() (float64, float64)

func (Point) XYInt

func (p Point) XYInt() (int, int)

Output integers.

type Sprite

type Sprite struct {
	Box
	// contains filtered or unexported fields
}

Sprite is an image drawn in a screen based on its position and scale. DrawImageOptions is not commutative. Do Translate at the final stage.

func NewSprite

func NewSprite(path string) Sprite

func NewSpriteFromImage

func NewSpriteFromImage(i *ebiten.Image) Sprite

func (Sprite) Draw

func (s Sprite) Draw(screen *ebiten.Image, op ebiten.DrawImageOptions)

func (Sprite) H

func (s Sprite) H() float64

func (Sprite) In

func (s Sprite) In(p Point) bool

func (Sprite) IsValid

func (s Sprite) IsValid() bool

func (*Sprite) SetScaleToH added in v0.2.4

func (s *Sprite) SetScaleToH(h float64)

func (*Sprite) SetScaleToW added in v0.2.4

func (s *Sprite) SetScaleToW(w float64)

func (*Sprite) SetSize added in v0.2.4

func (s *Sprite) SetSize(w, h float64)

func (Sprite) Size

func (s Sprite) Size() Point

func (Sprite) SrcSize

func (s Sprite) SrcSize() Point

func (Sprite) W

func (s Sprite) W() float64

func (Sprite) XY added in v0.2.4

func (s Sprite) XY() (float64, float64)

type Subject

type Subject interface {
	Size() Point
	// SetSize(w, h float64)
	Draw(*ebiten.Image, ebiten.DrawImageOptions)
	In(p Point) bool
}

type Timer added in v0.2.4

type Timer struct {
	Tick    int
	MaxTick int
	Period  int
}

MaxTick, Period == {+, +}: finite drawing with animation. e.g., Judgment. MaxTick, Period == {+, 0}: finite drawing with no animation. e.g., Combo. MaxTick, Period == {0, +}: infinite drawing with animation. e.g., Dancer. MaxTick, Period == {0, 0}: infinite drawing with no animation. e.g., Stage.

func NewTimer added in v0.2.4

func NewTimer(maxTick, period int) Timer

func (Timer) Age added in v0.2.4

func (t Timer) Age() float64

For visual effects.

func (Timer) Done added in v0.2.4

func (t Timer) Done() bool

func (Timer) Frame added in v0.2.4

func (t Timer) Frame(animation Animation) Sprite

For Animation.

func (Timer) Progress added in v0.2.4

func (t Timer) Progress(start, end float64) float64

func (*Timer) Reset added in v0.2.4

func (t *Timer) Reset()

func (*Timer) Ticker added in v0.2.4

func (t *Timer) Ticker()

Jump to

Keyboard shortcuts

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