Documentation ¶
Overview ¶
Package bento is a game framework for Ebitengine.
Index ¶
- Constants
- Variables
- func Bound(point, size image.Point) image.Rectangle
- func Coordinate(point image.Point) (x, y float64)
- func DPIScale(res int) float64
- func Keypress(keys []ebiten.Key) bool
- func Pad(bound image.Rectangle, pad image.Point) image.Rectangle
- func Point(m *ebiten.GeoM) image.Point
- func Poll[T any](ch <-chan T) (value T, ok bool)
- func Radian(degree float64) float64
- func SecondToTick(seconds float64) int
- func TickToSecond(ticks int) float64
- func Unpad(bound image.Rectangle, pad image.Point) image.Rectangle
- type Align
- type Atlas
- type Delta
- type DeltaAlgorithm
- type Event
- type Font
- func (f *Font) Draw(str string, clr color.Color, img *ebiten.Image, point image.Point)
- func (f *Font) Load(src []byte, opts *opentype.FaceOptions) error
- func (f *Font) Write(str string, clr color.Color, img *ebiten.Image, point image.Point, align Align) image.Rectangle
- func (f *Font) WriteCenter(str string, clr color.Color, img *ebiten.Image) image.Rectangle
- type Layer
- type Scroll
- type Timer
- type Vec
- func (vec *Vec) Arc(center image.Point, radius int, from, to float32)
- func (vec *Vec) Circle(center image.Point, radius int)
- func (vec *Vec) Draw(clr color.Color, img *ebiten.Image, o *ebiten.DrawTrianglesOptions)
- func (vec *Vec) DrawShader(clr color.Color, img *ebiten.Image, shader *ebiten.Shader, ...)
- func (vec *Vec) Line(to image.Point)
- func (vec *Vec) Move(to image.Point)
- func (vec *Vec) Rect(bounds image.Rectangle)
Constants ¶
const ( // Right moves an image to the right of a point. Right Align = 1 << iota // HCenter moves an image to the horizontal center of a point. HCenter // Left moves an image to the left of a point. Left // Top moves an image above a point. Top // VCenter moves an image to the vertical center of a point. VCenter // Bottom moves an image below a point. Bottom // Default is the default alignment of an image (to the right and below). Default = BottomRight TopLeft = Top | Left TopCenter = Top | HCenter TopRight = Top | Right CenterLeft = VCenter | Left Center = VCenter | HCenter CenterRight = VCenter | Right BottomLeft = Bottom | Left BottomCenter = Bottom | Center BottomRight = Bottom | Right )
Variables ¶
var Clock = clock{}
Clock is a monotonically increasing tick counter.
Functions ¶
func Coordinate ¶ added in v0.3.0
Coordinate returns the given point as a float64 pair.
func DPIScale ¶
DPIScale scales the given resolution by the device's scale factor. This allows high-DPI rendering.
func Keypress ¶
func Keypress(keys []ebiten.Key) bool
Keypress checks if at least one of the keys are pressed.
Types ¶
type Align ¶
type Align int
Align specifies the alignment to render an image at a point (x, y). Align must have at most one horizontal (AlignRight, AlignHCenter, AlignLeft) and vertical (AlignTop, AlignVCenter, AlignBottom) flag.
type Atlas ¶ added in v0.5.4
type Atlas struct {
// contains filtered or unexported fields
}
Atlas is a tile-based texture atlas for sprites.
func NewAtlas ¶ added in v0.5.4
NewAtlas creates a new atlas with an image and tile size. The tile size for each axis must satisfy (1 <= size <= image_size).
func (*Atlas) Draw ¶ added in v0.5.4
Draw draws a layer to an image. If img is nil, a new image large enough to display all the tiles is created.
func (*Atlas) Size ¶ added in v0.5.4
Size returns the size of the atlas in tiles. The size should be consider a closed interval, i.e (size.X * size.Y) is the maximum texture index.
type Delta ¶
type Delta struct {
// contains filtered or unexported fields
}
Delta is a change in value per time unit.
func NewDelta ¶
func NewDelta( algo DeltaAlgorithm, delta image.Point, period float64, ) *Delta
NewDelta creates an delta with the total delta, and the period over which to increase the current delta.
type DeltaAlgorithm ¶
type DeltaAlgorithm int
DeltaAlgorithm specifies the algorithm to use when generating deltas.
const ( // Linear specifies a delta is constant. Linear DeltaAlgorithm = iota // Exponential specifies a delta in exponential (e^x) space. Exponential )
type Event ¶ added in v0.5.0
type Event[T any] struct { // contains filtered or unexported fields }
Event notifies one or more callbacks when a event value is sent over the channel.
ch := make(chan string) e := NewEvent(ch) e.Notify(func(s string) { fmt.Println(s) }) e.Listen() ch <- "Hello World!"
type Font ¶
Font is a wrapper around a fontface, used to render text to images.
func (*Font) Draw ¶
Draw renders the text on an image at the point as-is (i.e without any alignment). NOTE: point is the bottom-left point of the text.
func (*Font) Load ¶
func (f *Font) Load(src []byte, opts *opentype.FaceOptions) error
Load loads an OpenType fontface from a source.
type Scroll ¶
type Scroll struct { Font *Font Point image.Point Color color.Color // contains filtered or unexported fields }
Scroll allows several pieces of text to be scrolled across an image. point is the bottom-left point of the scroll.
func (*Scroll) Draw ¶
func (s *Scroll) Draw(img *ebiten.Image)
Draw renders the scroll on a new image.
func (*Scroll) SetSpeed ¶ added in v0.3.0
SetSpeed changes the speed of scrolling text, where n is the number of seconds to wait between scrolling each character.
type Timer ¶ added in v0.3.0
type Timer struct {
// contains filtered or unexported fields
}
Timer is a tick-based scheduler for operations. One tick is equivalent to a single frame, where 1 second is 60 frames.
func NewTimer ¶ added in v0.3.0
NewTimer creates a new timer that triggers every n seconds. If once is true, the timer will only trigger once.
type Vec ¶
Vec is a wrapper around ebiten's vector path for drawing operations.
func (*Vec) Arc ¶
Arc draws a circular arc with a center and radius. from and to are angles in radians.
func (*Vec) DrawShader ¶
func (vec *Vec) DrawShader( clr color.Color, img *ebiten.Image, shader *ebiten.Shader, o *ebiten.DrawTrianglesShaderOptions, )
DrawShader renders the vector's path with a shader to an image.