draws

package
v0.2.1 Latest Latest
Warning

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

Go to latest
Published: Oct 18, 2022 License: Apache-2.0 Imports: 7 Imported by: 1

Documentation

Index

Constants

View Source
const (
	OriginLeft = iota
	OriginCenter
	OriginRight
)
View Source
const (
	OriginTop = iota
	OriginMiddle
	OriginBottom
)
View Source
const (
	AlignLeft = iota
	AlignCenter
	AlignRight
)
View Source
const (
	AlignTop = iota
	AlignMiddle
	AlignBottom
)
View Source
const (
	ModeMin = iota
	ModeMid
	ModeMax
)
View Source
const (
	ButtonModePressed = iota
	ButtonModeClicked // onClick goes called when mouse button is pressed and released.
)

Variables

View Source
var (
	AtMin = ModeXY{ModeMin, ModeMin}
	AtMid = ModeXY{ModeMid, ModeMid}
	AtMax = ModeXY{ModeMax, ModeMax}
)

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 AnimationDrawer

type AnimationDrawer struct {
	Time      int64
	Duration  int64 // float64
	StartTime int64
	// EndTime   int64
	// Cycle   int
	Sprites []Sprite
}

func (AnimationDrawer) Draw

func (d AnimationDrawer) Draw(screen *ebiten.Image, op *ebiten.DrawImageOptions, tx, ty float64)

func (AnimationDrawer) Frame

func (d AnimationDrawer) Frame() int

func (*AnimationDrawer) Update

func (d *AnimationDrawer) Update(time, duration int64, reset bool)
func (d *AnimationDrawer) SetTime(time, duration int64) {
	d.Time = time
	d.StartTime = time
	d.EndTime = time + duration
}

type BaseDrawer

type BaseDrawer struct {
	Countdown    int
	MaxCountdown int // Draw permanently when value is zero.
}

Countdown is for drawing a sprite for a while.

func (BaseDrawer) Age

func (d BaseDrawer) Age() float64

Todo: should I handle when MaxCountdown == 0?

func (*BaseDrawer) Update

func (d *BaseDrawer) Update(reloaded bool)

type Box

type Box struct {
	Inner Subject
	Pad   Point
	Point
	Origin2 ModeXY
	Align   ModeXY
	Outer   Subject
}

Box is wrapped Subject(Sprite, Label) with Position data.

func (Box) Draw

func (b Box) Draw(screen *ebiten.Image, op ebiten.DrawImageOptions, p Point)

Box may be a inner subject. Input point passes external translate values.

func (Box) In

func (b Box) In(p Point) bool

func (Box) InnerMax

func (b Box) InnerMax() Point

func (Box) InnerMin

func (b Box) InnerMin() Point

func (Box) OuterMax

func (b Box) OuterMax() Point

func (Box) OuterMin

func (b Box) OuterMin() Point

func (Box) OuterSize

func (b Box) OuterSize() Point

func (*Box) SetSize

func (b *Box) SetSize(size Point)

type Button

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

func (*Button) Hover

func (b *Button) Hover() bool

func (*Button) Update

func (b *Button) Update()

type Grid

type Grid [][]Box

Grid implements inteface Subject.

func NewGrid

func NewGrid(boxs [][]Box, ws, hs []float64, gap Point) *Grid

func (Grid) Draw

func (g Grid) Draw(screen *ebiten.Image, op ebiten.DrawImageOptions, p Point)

func (*Grid) SetSize

func (g *Grid) SetSize(size Point)

Todo: implement

func (Grid) Size

func (g Grid) Size() (p Point)

type Label

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

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

func NewLabel

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

func (Label) Draw

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

func (*Label) SetSize

func (l *Label) SetSize(size Point)

func (Label) Size

func (l Label) Size() Point

type ModeXY

type ModeXY struct{ X, Y int }

type Origin

type Origin int
const (
	OriginLeftTop      Origin = iota // Default Origin.
	OriginLeftMiddle                 // e.g., Notes in Piano mode.
	OriginLeftBottom                 // e.g., back button.
	OriginCenterTop                  // e.g., drawing field.
	OriginCenterMiddle               // Most of sprite's Origin.
	OriginCenterBottom               // e.g., Meter.
	OriginRightTop                   // e.g., score.
	OriginRightMiddle                // e.g., chart info boxes.
	OriginRightBottom                // e.g., Play button.
)

func (Origin) PositionX

func (origin Origin) PositionX() int

func (Origin) PositionY

func (origin Origin) PositionY() int

type Origin2

type Origin2 struct{ X, Y int }

type Point

type Point struct{ X, Y float64 }

func IntPt

func IntPt(x, y int) Point

func OuterSize

func OuterSize(inner Subject, pad Point) Point
func NewBox(inner Subject, pad Point) Box {
	size := inner.Size()
	size.Add(pad.Mul(Scalar(2)))
	return Box{
		Outer: NewSprite3FromImage(
			ebiten.NewImage(size.XYInt()),
		),
		Inner: inner,
		Pad:   pad,
	}
}

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)

type Rectangle

type Rectangle struct {
	Size_ Point
	Color color.Color
	Outer *Rectangle
}

Todo: nine-patch

func NewRectangle

func NewRectangle(size Point) *Rectangle

func (Rectangle) Draw

func (r Rectangle) Draw(screen *ebiten.Image, op ebiten.DrawImageOptions, p Point)

func (*Rectangle) SetSize

func (r *Rectangle) SetSize(size Point)

func (Rectangle) Size

func (r Rectangle) Size() Point
func NewRectangle(size Point, color color.Color) *Rectangle {
	return &Rectangle{
		Size_: size,
		Color: color,
	}
}

type Sprite

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

Sprite is a image drawn in screen based on its position and scale. DrawImageOptions is not commutative. Do translate at final stage. Todo: embed Text?

func NewSprite

func NewSprite(path string) Sprite

func NewSpriteFromImage

func NewSpriteFromImage(src *ebiten.Image) Sprite

func (Sprite) Draw

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

func (Sprite) Filter

func (s Sprite) Filter() ebiten.Filter

func (Sprite) H

func (s Sprite) H() float64

func (Sprite) In

func (s Sprite) In(x, y float64) bool

func (Sprite) IsValid

func (s Sprite) IsValid() bool

func (Sprite) LeftTopX

func (s Sprite) LeftTopX() float64

func (Sprite) LeftTopY

func (s Sprite) LeftTopY() float64

func (*Sprite) Move

func (s *Sprite) Move(tx, ty float64)

func (Sprite) Origin

func (s Sprite) Origin() Origin

func (*Sprite) SetPosition

func (s *Sprite) SetPosition(x, y float64, origin Origin)

func (*Sprite) SetScale

func (s *Sprite) SetScale(scale float64)

func (*Sprite) SetScaleXY

func (s *Sprite) SetScaleXY(scaleW, scaleH float64, filter ebiten.Filter)

func (Sprite) Size

func (s Sprite) Size() (float64, float64)

func (Sprite) SrcSize

func (s Sprite) SrcSize() (int, int)

func (Sprite) W

func (s Sprite) W() float64

func (s Sprite) Image() *ebiten.Image { return s.i }

func (Sprite) X

func (s Sprite) X() float64

func (Sprite) Y

func (s Sprite) Y() float64

type Sprite3

type Sprite3 struct {
	Scale Point
	// contains filtered or unexported fields
}

Sprite is a scaled image. Sprite3's i is nil if Sprite3 is a placeholder or failed to load an image.

func NewSprite3

func NewSprite3(path string) *Sprite3

func NewSprite3FromImage

func NewSprite3FromImage(i *ebiten.Image) *Sprite3

func (Sprite3) Draw

func (s Sprite3) Draw(screen *ebiten.Image, op ebiten.DrawImageOptions, p Point)

Currently option's Filter is fixed with FilterLinear.

func (*Sprite3) SetSize

func (s *Sprite3) SetSize(size Point)

func (Sprite3) Size

func (s Sprite3) Size() Point
func NewBlankSprite3(size Point) Sprite3 {
	return Sprite3{
		ebiten.NewImage(size.XYInt()),
		Point{1, 1},
	}
}

type Subject

type Subject interface {
	Size() Point
	SetSize(size Point)
	Draw(*ebiten.Image, ebiten.DrawImageOptions, Point)
}

Jump to

Keyboard shortcuts

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