Back to

Package ebitenutil

Latest Go to latest

The latest major version is .

Published: Apr 14, 2018 | License: Apache-2.0 | Module:


Package ebitenutil provides utility functions for Ebiten.


func DebugPrint

func DebugPrint(image *ebiten.Image, str string) error

DebugPrint draws the string str on the image.

DebugPrint always returns nil as of 1.5.0-alpha.

func DrawLine

func DrawLine(dst *ebiten.Image, x1, y1, x2, y2 float64, clr color.Color)

DrawLine draws a line segment on the given destination dst.

DrawLine is intended to be used mainly for debugging or prototyping purpose.

func DrawRect

func DrawRect(dst *ebiten.Image, x, y, width, height float64, clr color.Color)

DrawRect draws a rectangle on the given destination dst.

DrawRect is intended to be used mainly for debugging or prototyping purpose.

func NewImageFromFile

func NewImageFromFile(path string, filter ebiten.Filter) (*ebiten.Image, image.Image, error)

NewImageFromFile loads the file with path and returns ebiten.Image and image.Image.

How to solve path depends on your environment. This varies on your desktop or web browser. Note that this doesn't work on mobiles.

For productions, instead of using this function, it is safer to embed your resources, e.g., with .

func RecordScreenAsGIF

func RecordScreenAsGIF(update func(*ebiten.Image) error, out io.Writer, frameNum int) func(*ebiten.Image) error

RecordScreenAsGIF is deprecated as of version 1.6.0-alpha.

RecordScreenAsGIF returns updating function with recording the screen as an animation GIF image.

This encodes each screen at each frame and may slows the application.

Here is the example to record initial 120 frames of your game:

func update(screen *ebiten.Image) error {
    // ...

func main() {
    out, err := os.Create("output.gif")
    if err != nil {
    defer out.Close()

    update := RecordScreenAsGIF(update, out, 120)
    if err := ebiten.Run(update, 320, 240, 2, "Your game's title"); err != nil {

type ReadSeekCloser

type ReadSeekCloser interface {

ReadSeekCloser is io.ReadSeeker and io.Closer.

func OpenFile

func OpenFile(path string) (ReadSeekCloser, error)

OpenFile opens a file and returns a stream for its data.

The path parts should be separated with slash '/' on any environments.

Note that this doesn't work on mobiles.

Package Files

Documentation was rendered with GOOS=linux and GOARCH=amd64.

Jump to identifier

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to identifier