draws

package
v0.3.1 Latest Latest
Warning

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

Go to latest
Published: Nov 28, 2022 License: Apache-2.0 Imports: 18 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 (
	DelayedModeExp = iota // aka DelayedModeConverge
	DelayedModeLinear
)
View Source
const (
	Left = iota
	Center
	Right
)
View Source
const (
	Top = iota
	Middle
	Bottom
)
View Source
const TransDuration = 400 // In milliseconds.

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

View Source
var (
	ToTick = times.ToTick
	ToTime = times.ToTime
)
View Source
var DefaultFont *truetype.Font
View Source
var DefaultFontKey = FontKey{"go", "regular"}
View Source
var Faces = make(map[FaceKey]font.Face)
View Source
var Fonts = make(map[FontKey]*truetype.Font)

Functions

func LoadDefaultFace added in v0.3.1

func LoadDefaultFace(size float64) font.Face

func LoadFace added in v0.3.1

func LoadFace(fontKey FontKey, size float64) font.Face

func LoadImageImage added in v0.3.1

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

LoadImageImage returns image.Image.

Types

type Animation added in v0.2.4

type Animation []Sprite

func NewAnimation added in v0.2.4

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

func NewAnimationFromImages added in v0.2.4

func NewAnimationFromImages(images []Image) (a Animation)

func (Animation) IsValid added in v0.3.1

func (a Animation) IsValid() 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) IsValid added in v0.3.1

func (b Blank) IsValid() 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 Delayed added in v0.3.1

type Delayed struct {
	Delayed float64
	Source  float64
	// source       *float64
	Mode     int // Todo: custom type?
	Feedback float64
	// contains filtered or unexported fields
}

func NewDelayed added in v0.3.1

func NewDelayed(tps int) Delayed

func (*Delayed) Update added in v0.3.1

func (d *Delayed) Update(src float64)

type FaceKey added in v0.3.1

type FaceKey struct {
	FontKey
	Size float64
}

type FontKey added in v0.3.1

type FontKey struct {
	Family string
	Face   string
}

Typeface: a style. Type Family: a set of relating styles. Font: a file of Typeface. Font Family: a set of relating fonts. Font Face: a file used for specific style.

type Image added in v0.3.1

type Image struct{ *ebiten.Image }

func LoadImage added in v0.3.1

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

LoadImage returns nil when fails to load image from the path. ebiten.NewImageFromImage will panic when input is nil.

func LoadImages added in v0.3.1

func LoadImages(fsys fs.FS, name string) (is []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 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) IsValid added in v0.3.1

func (i Image) IsValid() bool

func (Image) Size added in v0.3.1

func (i Image) Size() Vector2

type Location added in v0.3.1

type Location = Vector2

Unit of Location is percent.

type Op added in v0.3.1

type Op = ebiten.DrawImageOptions

type Origin

type Origin struct{ X, Y int }

type Paper added in v0.3.1

type Paper struct{}

type Position added in v0.3.1

type Position = Vector2

Unit of Position is pixel.

type Source added in v0.3.1

type Source interface {
	IsValid() bool
	Size() Vector2
	Draw(Image, Op)
}

Image and Text implements Source.

type Sprite

type Sprite struct {
	Source
	Scale  Vector2
	Filter ebiten.Filter
	Position
	Origin       Origin
	AxisReversed [2]bool
}

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(fsys fs.FS, name string) Sprite

func NewSpriteFromSource added in v0.3.1

func NewSpriteFromSource(src Source) Sprite

func (*Sprite) ApplyScale added in v0.3.1

func (s *Sprite) ApplyScale(scale float64)

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, origin Origin)

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

func (Sprite) SrcSize

func (s Sprite) SrcSize() Vector2

func (s *Sprite) SetRelativePosition(outer Sprite, location 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)

func (Text) IsValid added in v0.3.1

func (t Text) IsValid() bool

func (Text) Size added in v0.3.1

func (t Text) Size() Vector2

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