draws

package
v0.2.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: 0

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 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

type Animation []Sprite

func NewAnimation

func NewAnimation(path string) (a Animation)

type Box

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

func NewBox

func NewBox() Box

func (*Box) ApplyScale

func (b *Box) ApplyScale(scale float64)

func (Box) In

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

func (Box) Max

func (b Box) Max(size Point) Point

func (Box) Min

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

func (*Box) Move

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

func (*Box) SetPoint

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

func (*Box) SetScale

func (b *Box) SetScale(scale Point)

func (Box) XY

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

type Button

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

func NewButton

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

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

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
}

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

func (s *Sprite) SetScaleToH(h float64)

func (*Sprite) SetScaleToW

func (s *Sprite) SetScaleToW(w float64)

func (*Sprite) SetSize

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

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

type Timer struct {
	Countdown    int
	MaxCountdown int
	Duration     int
}

Timer helps drawing a sprite with visual effects.

func NewTimer

func NewTimer(max, duration int) Timer

func (Timer) Age

func (t Timer) Age() float64

func (Timer) Frame

func (t Timer) Frame(sprites []Sprite) Sprite

Works as Animation.

func (Timer) Progress

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

type Timer2

type Timer2 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 NewTimer2

func NewTimer2(tick, period int) Timer2

func (Timer2) Age

func (t Timer2) Age() float64

For visual effects.

func (Timer2) Frame

func (t Timer2) Frame(sprites []Sprite) Sprite

For Animation.

func (*Timer2) Ticker

func (t *Timer2) Ticker()

Jump to

Keyboard shortcuts

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