draws

package
v0.6.1 Latest Latest
Warning

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

Go to latest
Published: Jul 23, 2023 License: Apache-2.0 Imports: 15 Imported by: 1

Documentation

Index

Constants

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

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 NewImageImageFromFile added in v0.6.0

func NewImageImageFromFile(fsys fs.FS, name string) image.Image

Types

type Anchor added in v0.6.0

type Anchor struct{ X, Y int }

type Animation added in v0.2.4

type Animation []Sprite

func NewAnimation added in v0.2.4

func NewAnimation(srcs any) Animation

func NewAnimationFromFile added in v0.6.0

func NewAnimationFromFile(fsys fs.FS, name string) Animation

func (Animation) IsEmpty added in v0.6.0

func (a Animation) IsEmpty() bool

type Blank added in v0.3.1

type Blank struct{ Size_ Vector2 }

Blank is for wrapping Sprite with specific Outer size.

func (Blank) Draw added in v0.3.1

func (b Blank) Draw(dst Image, op Op)

func (Blank) IsEmpty added in v0.6.0

func (b Blank) IsEmpty() bool

func (Blank) Size added in v0.3.1

func (b Blank) Size() Vector2

type Button

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

func NewButton added in v0.2.4

func NewButton(sprite Sprite, onClick func(), mode ButtonMode) Button

func (*Button) Draw added in v0.3.1

func (b *Button) Draw(dst Image, op Op)

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 Frames added in v0.6.0

type Frames = []Image

func NewFramesFromFilename added in v0.6.0

func NewFramesFromFilename(fsys fs.FS, name string) Frames

Read frames if there is a directory and the directory has entries. Read a single image if there is no directory or the directory has no entries.

type Image added in v0.3.1

type Image struct{ *ebiten.Image }

func NewImage

func NewImage(w, h float64) Image

func NewImageColored added in v0.3.1

func NewImageColored(src Image, color color.Color) Image

func NewImageFromFile added in v0.6.0

func NewImageFromFile(fsys fs.FS, name string) Image

NewImageFromFile returns nil when fails to load file from given path. ebiten.NewImageFromImage will panic when input is nil.

func NewImageFromURL added in v0.6.0

func NewImageFromURL(url string) (Image, error)

func NewImageXFlipped added in v0.3.1

func NewImageXFlipped(src Image) Image

func NewImageYFlipped added in v0.3.1

func NewImageYFlipped(src Image) Image

func (Image) Draw added in v0.3.1

func (i Image) Draw(dst Image, op Op)

func (Image) IsEmpty added in v0.6.0

func (i Image) IsEmpty() bool

func (Image) Size added in v0.3.1

func (i Image) Size() Vector2

type Op added in v0.3.1

type Op struct {
	colorm.DrawImageOptions
	ColorM colorm.ColorM
}

type Op = ebiten.DrawImageOptions

type Position added in v0.3.1

type Position = Vector2

Unit of Position is pixel. cf. Location: unit is percent.

type Source added in v0.3.1

type Source interface {
	Size() Vector2
	Draw(Image, Op)
	IsEmpty() bool // Whether the source is nil.
}

Image, Text, and Blank implement Source.

type Sprite

type Sprite struct {
	Source
	Scale  Vector2
	Filter ebiten.Filter
	Position
	Anchor Anchor
}

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

func NewSprite

func NewSprite(src Source) Sprite

func NewSpriteFromFile added in v0.6.0

func NewSpriteFromFile(fsys fs.FS, name string) Sprite

func NewSpriteFromURL added in v0.6.0

func NewSpriteFromURL(url string) (Sprite, error)

func (Sprite) Draw

func (s Sprite) Draw(dst Image, op Op)

func (Sprite) H

func (s Sprite) H() float64

func (Sprite) In

func (s Sprite) In(p Vector2) bool

func (Sprite) LeftTop added in v0.3.1

func (s Sprite) LeftTop(screenSize Vector2) (v Vector2)

func (*Sprite) Locate added in v0.3.1

func (s *Sprite) Locate(x, y float64, anchor Anchor)

func (Sprite) Max added in v0.2.4

func (s Sprite) Max() Vector2

func (Sprite) Min added in v0.2.4

func (s Sprite) Min() (min Vector2)

func (*Sprite) Move

func (s *Sprite) Move(x, y float64)

func (*Sprite) MultiplyScale added in v0.6.0

func (s *Sprite) MultiplyScale(scale float64)

func (*Sprite) SetSize added in v0.2.4

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

func (Sprite) Size

func (s Sprite) Size() Vector2

func (Sprite) SrcSize

func (s Sprite) SrcSize() Vector2

func (Sprite) W

func (s Sprite) W() float64

type Text added in v0.3.1

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

func NewText added in v0.3.1

func NewText(t string, face font.Face) Text

func (Text) Draw added in v0.3.1

func (t Text) Draw(dst Image, op Op)

issue: ebiten/v2/text.DrawWithOptions does not support ColorM.

func (Text) IsEmpty added in v0.6.0

func (t Text) IsEmpty() bool

func (Text) Size added in v0.3.1

func (t Text) Size() Vector2

Append new line when each function has more than one line and functions are not strictly related.

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

All timer starts at maxTick, hence IsDone() is true at the beginning.

func (Timer) Age added in v0.2.4

func (t Timer) Age() float64

For visual effects.

func (Timer) Frame added in v0.2.4

func (t Timer) Frame(animation Animation) Sprite

For Animation.

func (Timer) IsDone added in v0.3.1

func (t Timer) IsDone() bool

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

type Vector2 added in v0.3.1

type Vector2 struct{ X, Y float64 }

func IntVec2 added in v0.3.1

func IntVec2(x, y int) Vector2

Input integers.

func Scalar

func Scalar(v float64) Vector2

func Vec2 added in v0.3.1

func Vec2(x, y float64) Vector2

func (Vector2) Add added in v0.3.1

func (v Vector2) Add(w Vector2) Vector2

func (Vector2) Div added in v0.3.1

func (v Vector2) Div(w Vector2) Vector2

func (Vector2) Mul added in v0.3.1

func (v Vector2) Mul(w Vector2) Vector2

func (Vector2) Scale added in v0.3.1

func (v Vector2) Scale(scale float64) Vector2

func (Vector2) Sub added in v0.3.1

func (v Vector2) Sub(w Vector2) Vector2

func (Vector2) XY added in v0.3.1

func (v Vector2) XY() (float64, float64)

func (Vector2) XYInt added in v0.3.1

func (v Vector2) XYInt() (int, int)

Output integers.

Jump to

Keyboard shortcuts

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