ebiten: github.com/hajimehoshi/ebiten/ebitenutil Index | Files | Directories

package ebitenutil

import "github.com/hajimehoshi/ebiten/ebitenutil"

Package ebitenutil provides utility functions for Ebiten.

Index

Package Files

debugprint.go doc.go file_notjs.go gif.go import.go io.go loadimage.go shapes.go url.go

func DebugPrint Uses

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

DebugPrint draws the string str on the image on left top corner.

The available runes are in U+0000 to U+00FF, which is C0 Controls and Basic Latin and C1 Controls and Latin-1 Supplement.

DebugPrint always returns nil as of 1.5.0-alpha.

func DebugPrintAt Uses

func DebugPrintAt(image *ebiten.Image, str string, x, y int)

DebugPrintAt draws the string str on the image at (x, y) position.

The available runes are in U+0000 to U+00FF, which is C0 Controls and Basic Latin and C1 Controls and Latin-1 Supplement.

func DrawLine Uses

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 Uses

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 Uses

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.

Image decoders must be imported when using NewImageFromFile. For example, if you want to load a PNG image, you'd need to add `_ "image/png"` to the import section.

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 NewImageFromFile, it is safer to embed your resources, e.g., with github.com/rakyll/statik .

func NewImageFromURL Uses

func NewImageFromURL(url string) (*ebiten.Image, error)

NewImageFromURL creates a new ebiten.Image from the given URL.

Image decoders must be imported when using NewImageFromURL. For example, if you want to load a PNG image, you'd need to add `_ "image/png"` to the import section.

FilterDefault is used at NewImgeFromImage internally.

func RecordScreenAsGIF Uses

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 {
        log.Fatal(err)
    }
    defer out.Close()

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

type ReadSeekCloser Uses

type ReadSeekCloser interface {
    io.ReadSeeker
    io.Closer
}

ReadSeekCloser is io.ReadSeeker and io.Closer.

func OpenFile Uses

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.

Directories

PathSynopsis
internal/assets

Package ebitenutil imports 14 packages (graph) and is imported by 42 packages. Updated 2019-06-15. Refresh now. Tools for package owners.