ebiten

package module
v1.6.4 Latest Latest
Warning

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

Go to latest
Published: Apr 14, 2018 License: Apache-2.0 Imports: 16 Imported by: 0

README

Ebiten (海老天)

Build Status GoDoc Go Report Card

A dead simple 2D game library in Go

Note: Gamepad and keyboard are not available on Android/iOS.

Features

  • 2D Graphics (Geometry/Color matrix transformation, Various composition modes, Offscreen rendering, Fullscreen, Text rendering)
  • Input (Mouse, Keyboard, Gamepads, Touches)
  • Audio (MP3, Ogg/Vorbis, WAV, PCM, Syncing with game progress)

Web Site

https://hajimehoshi.github.io/ebiten/

Community

Slack

#ebiten channel in Gophers Slack

License

Ebiten is licensed under Apache license version 2.0. See LICENSE file.

Documentation

Overview

Package ebiten provides graphics and input API to develop a 2D game.

You can start the game by calling the function Run.

func update(screen *ebiten.Image) error {
    // Define your game.
}

func main() {
    ebiten.Run(update, 320, 240, 2, "Your game's title")
}

Index

Constants

View Source
const (
	// Regular alpha blending
	// c_out = c_src + c_dst × (1 - α_src)
	CompositeModeSourceOver CompositeMode = CompositeMode(opengl.CompositeModeSourceOver)

	// c_out = 0
	CompositeModeClear = CompositeMode(opengl.CompositeModeClear)

	// c_out = c_src
	CompositeModeCopy = CompositeMode(opengl.CompositeModeCopy)

	// c_out = c_dst
	CompositeModeDestination = CompositeMode(opengl.CompositeModeDestination)

	// c_out = c_src × (1 - α_dst) + c_dst
	CompositeModeDestinationOver = CompositeMode(opengl.CompositeModeDestinationOver)

	// c_out = c_src × α_dst
	CompositeModeSourceIn = CompositeMode(opengl.CompositeModeSourceIn)

	// c_out = c_dst × α_src
	CompositeModeDestinationIn = CompositeMode(opengl.CompositeModeDestinationIn)

	// c_out = c_src × (1 - α_dst)
	CompositeModeSourceOut = CompositeMode(opengl.CompositeModeSourceOut)

	// c_out = c_dst × (1 - α_src)
	CompositeModeDestinationOut = CompositeMode(opengl.CompositeModeDestinationOut)

	// c_out = c_src × α_dst + c_dst × (1 - α_src)
	CompositeModeSourceAtop = CompositeMode(opengl.CompositeModeSourceAtop)

	// c_out = c_src × (1 - α_dst) + c_dst × α_src
	CompositeModeDestinationAtop = CompositeMode(opengl.CompositeModeDestinationAtop)

	// c_out = c_src × (1 - α_dst) + c_dst × (1 - α_src)
	CompositeModeXor = CompositeMode(opengl.CompositeModeXor)

	// Sum of source and destination (a.k.a. 'plus' or 'additive')
	// c_out = c_src + c_dst
	CompositeModeLighter = CompositeMode(opengl.CompositeModeLighter)
)

This name convention follows CSS compositing: https://drafts.fxtf.org/compositing-2/.

In the comments, c_src, c_dst and c_out represent alpha-premultiplied RGB values of source, destination and output respectively. α_src and α_dst represent alpha values of source and destination respectively.

View Source
const ColorMDim = affine.ColorMDim

ColorMDim is a dimension of a ColorM.

View Source
const FPS = clock.FPS

FPS represents how many times game updating happens in a second (60).

View Source
const GeoMDim = affine.GeoMDim

GeoMDim is a dimension of a GeoM.

View Source
const MaxImageSize = restorable.MaxImageSize

MaxImageSize represents the maximum width/height of an image.

Variables

This section is empty.

Functions

func CurrentFPS added in v1.2.0

func CurrentFPS() float64

CurrentFPS returns the current number of frames per second of rendering.

The returned value represents how many times rendering happens in a second and NOT how many times logical game updating (a passed function to Run) happens. Note that logical game updating is assured to happen 60 times in a second.

This function is concurrent-safe.

func CursorPosition

func CursorPosition() (x, y int)

CursorPosition returns a position of a mouse cursor.

This function is concurrent-safe.

func DeviceScaleFactor added in v1.6.1

func DeviceScaleFactor() float64

DeviceScaleFactor returns a device scale factor value.

DeviceScaleFactor returns a meaningful value on high-DPI display environment, otherwise DeviceScaleFactor returns 1.

This function is concurrent-safe.

func GamepadAxis added in v1.2.0

func GamepadAxis(id int, axis int) float64

GamepadAxis returns the float value [-1.0 - 1.0] of the given gamepad (id)'s axis (axis).

This function is concurrent-safe.

This function always returns 0 on mobiles.

func GamepadAxisNum added in v1.2.0

func GamepadAxisNum(id int) int

GamepadAxisNum returns the number of axes of the gamepad (id).

This function is concurrent-safe.

This function always returns 0 on mobiles.

func GamepadButtonNum added in v1.2.0

func GamepadButtonNum(id int) int

GamepadButtonNum returns the number of the buttons of the given gamepad (id).

This function is concurrent-safe.

This function always returns 0 on mobiles.

func GamepadIDs added in v1.6.1

func GamepadIDs() []int

GamepadIDs returns a slice indicating available gamepad IDs.

This function is concurrent-safe.

This function always returns an empty slice on mobiles.

func InputChars added in v1.6.1

func InputChars() []rune

InputChars return "printable" runes read from the keyboard at the time update is called.

InputChars represents the environment's locale-dependent translation of keyboard input to Unicode characters.

IsKeyPressed is based on a mapping of device (US keyboard) codes to input device keys. "Control" and modifier keys should be handled with IsKeyPressed.

This function is concurrent-safe.

func IsCursorVisible added in v1.6.1

func IsCursorVisible() bool

IsCursorVisible returns a boolean value indicating whether the cursor is visible or not.

IsCursorVisible always returns false on mobiles.

This function is concurrent-safe.

func IsFullscreen added in v1.6.1

func IsFullscreen() bool

IsFullscreen returns a boolean value indicating whether the current mode is fullscreen or not.

IsFullscreen always returns false on mobiles.

This function is concurrent-safe.

func IsGamepadButtonPressed added in v1.2.0

func IsGamepadButtonPressed(id int, button GamepadButton) bool

IsGamepadButtonPressed returns the boolean indicating the given button of the gamepad (id) is pressed or not.

This function is concurrent-safe.

The button states vary depending on environments. There can be differences even between Chrome and Firefox. Don't assume that returned values are always same when same buttons are pressed.

This function always returns false on mobiles.

func IsKeyPressed

func IsKeyPressed(key Key) bool

IsKeyPressed returns a boolean indicating whether key is pressed.

This function is concurrent-safe.

func IsMouseButtonPressed

func IsMouseButtonPressed(mouseButton MouseButton) bool

IsMouseButtonPressed returns a boolean indicating whether mouseButton is pressed.

This function is concurrent-safe.

Note that touch events not longer affect this function's result as of 1.4.0-alpha. Use Touches instead.

func IsRunnableInBackground added in v1.6.1

func IsRunnableInBackground() bool

IsRunnableInBackground returns a boolean value indicating whether the game runs even in background.

This function is concurrent-safe.

func IsRunningSlowly added in v1.4.0

func IsRunningSlowly() bool

IsRunningSlowly returns true if the game is running too slowly to keep 60 FPS of rendering. The game screen is not updated when IsRunningSlowly is true. It is recommended to skip heavy processing, especially drawing screen, when IsRunningSlowly is true.

The typical code with IsRunningSlowly is this:

func update(screen *ebiten.Image) error {

    // Update the state.

    // When IsRunningSlowly is true, the rendered result is not adopted.
    // Skip rendering then.
    if ebiten.IsRunningSlowly() {
        return nil
    }

    // Draw something to the screen.

    return nil
}

This function is concurrent-safe.

func Run

func Run(f func(*Image) error, width, height int, scale float64, title string) error

Run runs the game. f is a function which is called at every frame. The argument (*Image) is the render target that represents the screen. The screen size is based on the given values (width and height).

A window size is based on the given values (width, height and scale). scale is used to enlarge the screen. Note that the actual screen is multiplied not only by the given scale but also by the device scale on high-DPI display. If you pass inverse of the device scale, you can disable this automatical device scaling as a result. You can get the device scale by DeviceScaleFactor function.

Run must be called from the OS main thread. Note that Ebiten bounds the main goroutine to the main OS thread by runtime.LockOSThread.

The given function f is guaranteed to be called 60 times a second even if a rendering frame is skipped. f is not called when the window is in background by default. This setting is configurable with SetRunnableInBackground.

The given scale is ignored on fullscreen mode.

Run returns error when 1) OpenGL error happens, 2) audio error happens or 3) f returns error. In the case of 3), Run returns the same error.

The size unit is device-independent pixel.

Don't call Run twice or more in one process.

func RunWithoutMainLoop added in v1.4.0

func RunWithoutMainLoop(f func(*Image) error, width, height int, scale float64, title string) <-chan error

RunWithoutMainLoop runs the game, but don't call the loop on the main (UI) thread. Different from Run, this function returns immediately.

Typically, Ebiten users don't have to call this directly. Instead, functions in github.com/hajimehoshi/ebiten/mobile module call this.

func ScreenScale added in v1.4.0

func ScreenScale() float64

ScreenScale returns the current screen scale.

If Run is not called, this returns 0.

This function is concurrent-safe.

func SetCursorVisibility added in v1.5.0

func SetCursorVisibility(visible bool)

SetCursorVisibility is deprecated as of 1.6.0-alpha. Use SetCursorVisible instead.

func SetCursorVisible added in v1.6.1

func SetCursorVisible(visible bool)

SetCursorVisible changes the state of cursor visiblity.

SetCursorVisible does nothing on mobiles.

This function is concurrent-safe.

func SetFullscreen added in v1.6.1

func SetFullscreen(fullscreen bool)

SetFullscreen changes the current mode to fullscreen or not.

On fullscreen mode, the game screen is automatically enlarged to fit with the monitor. The current scale value is ignored.

On desktops, Ebiten uses 'windowed' fullscreen mode, which doesn't change your monitor's resolution.

On browsers, the game screen is resized to fit with the body element (client) size. Additionally, the game screen is automatically resized when the body element is resized.

SetFullscreen does nothing on mobiles.

This function is concurrent-safe.

func SetRunnableInBackground added in v1.6.1

func SetRunnableInBackground(runnableInBackground bool)

SetRunnableInBackground sets the state if the game runs even in background.

If the given value is true, the game runs in background e.g. when losing focus. The initial state is false.

Known issue: On browsers, even if the state is on, the game doesn't run in background tabs. This is because browsers throttles background tabs not to often update.

SetRunnableInBackground does nothing on mobiles so far.

This function is concurrent-safe.

func SetScreenScale added in v1.2.0

func SetScreenScale(scale float64)

SetScreenScale changes the scale of the screen.

Note that the actual screen is multiplied not only by the given scale but also by the device scale on high-DPI display. If you pass inverse of the device scale, you can disable this automatical device scaling as a result. You can get the device scale by DeviceScaleFactor function.

This function is concurrent-safe.

func SetScreenSize added in v1.2.0

func SetScreenSize(width, height int)

SetScreenSize changes the (logical) size of the screen. This doesn't affect the current scale of the screen.

Unit is device-independent pixel.

This function is concurrent-safe.

func SetWindowIcon added in v1.6.1

func SetWindowIcon(iconImages []image.Image)

SetWindowIcon sets the icon of the game window.

If len(iconImages) is 0, SetWindowIcon reverts the icon to the default one.

For desktops, see the document of glfwSetWindowIcon of GLFW 3.2:

This function sets the icon of the specified window.
If passed an array of candidate images, those of or closest to the sizes
desired by the system are selected.
If no images are specified, the window reverts to its default icon.

The desired image sizes varies depending on platform and system settings.
The selected images will be rescaled as needed.
Good sizes include 16x16, 32x32 and 48x48.

As macOS windows don't have icons, SetWindowIcon doesn't work on macOS.

SetWindowIcon doesn't work on browsers or mobiles.

This function is concurrent-safe.

Types

type ColorM

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

A ColorM represents a matrix to transform coloring when rendering an image.

A ColorM is applied to the straight alpha color while an Image's pixels' format is alpha premultiplied. Before applying a matrix, a color is un-multiplied, and after applying the matrix, the color is multiplied again.

The initial value is identity.

func Monochrome

func Monochrome() ColorM

Monochrome is deprecated as of 1.6.0-alpha. Use ChangeHSV(0, 0, 1) instead.

func RotateHue

func RotateHue(theta float64) ColorM

RotateHue is deprecated as of 1.2.0-alpha. Use RotateHue member function instead.

func ScaleColor

func ScaleColor(r, g, b, a float64) ColorM

ScaleColor is deprecated as of 1.2.0-alpha. Use Scale instead.

func TranslateColor

func TranslateColor(r, g, b, a float64) ColorM

TranslateColor is deprecated as of 1.2.0-alpha. Use Translate instead.

func (*ColorM) Add

func (c *ColorM) Add(other ColorM)

Add is deprecated as of 1.5.0-alpha. Note that this doesn't make sense as an operation for affine matrices.

func (*ColorM) Apply added in v1.6.1

func (c *ColorM) Apply(clr color.Color) color.Color

Apply pre-multiplies a vector (r, g, b, a, 1) by the matrix where r, g, b, and a are clr's values in straight-alpha format. In other words, Apply calculates ColorM * (r, g, b, a, 1)^T.

func (*ColorM) ChangeHSV added in v1.4.0

func (c *ColorM) ChangeHSV(hueTheta float64, saturationScale float64, valueScale float64)

ChangeHSV changes HSV (Hue-Saturation-Value) values. hueTheta is a radian value to ratate hue. saturationScale is a value to scale saturation. valueScale is a value to scale value (a.k.a. brightness).

This conversion uses RGB to/from YCrCb conversion.

func (*ColorM) Concat

func (c *ColorM) Concat(other ColorM)

Concat multiplies a color matrix with the other color matrix. This is same as muptiplying the matrix other and the matrix c in this order.

func (*ColorM) Element

func (c *ColorM) Element(i, j int) float64

Element returns a value of a matrix at (i, j).

func (*ColorM) Reset added in v1.5.0

func (c *ColorM) Reset()

Reset resets the ColorM as identity.

func (*ColorM) RotateHue added in v1.2.0

func (c *ColorM) RotateHue(theta float64)

RotateHue rotates the hue. theta represents rotating angle in radian.

func (*ColorM) Scale added in v1.1.0

func (c *ColorM) Scale(r, g, b, a float64)

Scale scales the matrix by (r, g, b, a).

func (*ColorM) SetElement

func (c *ColorM) SetElement(i, j int, element float64)

SetElement sets an element at (i, j).

func (*ColorM) Translate added in v1.1.0

func (c *ColorM) Translate(r, g, b, a float64)

Translate translates the matrix by (r, g, b, a).

type CompositeMode added in v1.4.0

type CompositeMode int

CompositeMode represents Porter-Duff composition mode.

type DrawImageOptions

type DrawImageOptions struct {
	// SourceRect is the region of the source image to draw.
	// If SourceRect is nil, whole image is used.
	//
	// It is assured that texels out of the SourceRect are never used.
	SourceRect *image.Rectangle

	// GeoM is a geometry matrix to draw.
	// The default (zero) value is identify, which draws the image at (0, 0).
	GeoM GeoM

	// ColorM is a color matrix to draw.
	// The default (zero) value is identity, which doesn't change any color.
	ColorM ColorM

	// CompositeMode is a composite mode to draw.
	// The default (zero) value is regular alpha blending.
	CompositeMode CompositeMode

	// Deprecated (as of 1.5.0-alpha): Use SourceRect instead.
	ImageParts ImageParts

	// Deprecated (as of 1.1.0-alpha): Use SourceRect instead.
	Parts []ImagePart
}

A DrawImageOptions represents options to render an image on an image.

type Filter

type Filter int

Filter represents the type of filter to be used when an image is maginified or minified.

const (
	// FilterNearest represents nearest (crisp-edged) filter
	FilterNearest Filter = Filter(graphics.FilterNearest)

	// FilterLinear represents linear filter
	FilterLinear Filter = Filter(graphics.FilterLinear)
)

type GamepadButton added in v1.2.0

type GamepadButton int

A GamepadButton represents a gamepad button.

const (
	GamepadButton0   GamepadButton = GamepadButton(ui.GamepadButton0)
	GamepadButton1   GamepadButton = GamepadButton(ui.GamepadButton1)
	GamepadButton2   GamepadButton = GamepadButton(ui.GamepadButton2)
	GamepadButton3   GamepadButton = GamepadButton(ui.GamepadButton3)
	GamepadButton4   GamepadButton = GamepadButton(ui.GamepadButton4)
	GamepadButton5   GamepadButton = GamepadButton(ui.GamepadButton5)
	GamepadButton6   GamepadButton = GamepadButton(ui.GamepadButton6)
	GamepadButton7   GamepadButton = GamepadButton(ui.GamepadButton7)
	GamepadButton8   GamepadButton = GamepadButton(ui.GamepadButton8)
	GamepadButton9   GamepadButton = GamepadButton(ui.GamepadButton9)
	GamepadButton10  GamepadButton = GamepadButton(ui.GamepadButton10)
	GamepadButton11  GamepadButton = GamepadButton(ui.GamepadButton11)
	GamepadButton12  GamepadButton = GamepadButton(ui.GamepadButton12)
	GamepadButton13  GamepadButton = GamepadButton(ui.GamepadButton13)
	GamepadButton14  GamepadButton = GamepadButton(ui.GamepadButton14)
	GamepadButton15  GamepadButton = GamepadButton(ui.GamepadButton15)
	GamepadButton16  GamepadButton = GamepadButton(ui.GamepadButton16)
	GamepadButton17  GamepadButton = GamepadButton(ui.GamepadButton17)
	GamepadButton18  GamepadButton = GamepadButton(ui.GamepadButton18)
	GamepadButton19  GamepadButton = GamepadButton(ui.GamepadButton19)
	GamepadButton20  GamepadButton = GamepadButton(ui.GamepadButton20)
	GamepadButton21  GamepadButton = GamepadButton(ui.GamepadButton21)
	GamepadButton22  GamepadButton = GamepadButton(ui.GamepadButton22)
	GamepadButton23  GamepadButton = GamepadButton(ui.GamepadButton23)
	GamepadButton24  GamepadButton = GamepadButton(ui.GamepadButton24)
	GamepadButton25  GamepadButton = GamepadButton(ui.GamepadButton25)
	GamepadButton26  GamepadButton = GamepadButton(ui.GamepadButton26)
	GamepadButton27  GamepadButton = GamepadButton(ui.GamepadButton27)
	GamepadButton28  GamepadButton = GamepadButton(ui.GamepadButton28)
	GamepadButton29  GamepadButton = GamepadButton(ui.GamepadButton29)
	GamepadButton30  GamepadButton = GamepadButton(ui.GamepadButton30)
	GamepadButton31  GamepadButton = GamepadButton(ui.GamepadButton31)
	GamepadButtonMax GamepadButton = GamepadButton31
)

GamepadButtons

type GeoM

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

A GeoM represents a matrix to transform geometry when rendering an image.

The initial value is identity.

func RotateGeo

func RotateGeo(theta float64) GeoM

RotateGeo is deprecated as of 1.2.0-alpha. Use Rotate instead.

func ScaleGeo

func ScaleGeo(x, y float64) GeoM

ScaleGeo is deprecated as of 1.2.0-alpha. Use Scale instead.

func TranslateGeo

func TranslateGeo(tx, ty float64) GeoM

TranslateGeo is deprecated as of 1.2.0-alpha. Use Translate instead.

func (*GeoM) Add

func (g *GeoM) Add(other GeoM)

Add is deprecated as of 1.5.0-alpha. Note that this doesn't make sense as an operation for affine matrices.

func (*GeoM) Apply added in v1.6.1

func (g *GeoM) Apply(x, y float64) (x2, y2 float64)

Apply pre-multiplies a vector (x, y, 1) by the matrix. In other words, Apply calculates GeoM * (x, y, 1)^T. The return value is x and y values of the result vector.

func (*GeoM) Concat

func (g *GeoM) Concat(other GeoM)

Concat multiplies a geometry matrix with the other geometry matrix. This is same as muptiplying the matrix other and the matrix g in this order.

func (*GeoM) Element

func (g *GeoM) Element(i, j int) float64

Element returns a value of a matrix at (i, j).

func (*GeoM) Reset added in v1.5.0

func (g *GeoM) Reset()

Reset resets the GeoM as identity.

func (*GeoM) Rotate added in v1.1.0

func (g *GeoM) Rotate(theta float64)

Rotate rotates the matrix by theta. The unit is radian.

func (*GeoM) Scale added in v1.1.0

func (g *GeoM) Scale(x, y float64)

Scale scales the matrix by (x, y).

func (*GeoM) SetElement

func (g *GeoM) SetElement(i, j int, element float64)

SetElement sets an element at (i, j).

func (*GeoM) Translate added in v1.1.0

func (g *GeoM) Translate(tx, ty float64)

Translate translates the matrix by (tx, ty).

type Image

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

Image represents a rectangle set of pixels. The pixel format is alpha-premultiplied RGBA. Image implements image.Image.

Functions of Image never returns error as of 1.5.0-alpha, and error values are always nil.

func NewImage

func NewImage(width, height int, filter Filter) (*Image, error)

NewImage returns an empty image.

If width or height is less than 1 or more than MaxImageSize, NewImage panics.

Error returned by NewImage is always nil as of 1.5.0-alpha.

func NewImageFromImage

func NewImageFromImage(source image.Image, filter Filter) (*Image, error)

NewImageFromImage creates a new image with the given image (source).

If source's width or height is less than 1 or more than MaxImageSize, NewImageFromImage panics.

Error returned by NewImageFromImage is always nil as of 1.5.0-alpha.

func (*Image) At

func (i *Image) At(x, y int) color.Color

At returns the color of the image at (x, y).

At loads pixels from GPU to system memory if necessary, which means that At can be slow.

At always returns a transparent color if the image is disposed.

At can't be called before the main loop (ebiten.Run) starts (as of version 1.4.0-alpha).

func (*Image) Bounds

func (i *Image) Bounds() image.Rectangle

Bounds returns the bounds of the image.

func (*Image) Clear

func (i *Image) Clear() error

Clear resets the pixels of the image into 0.

When the image is disposed, Clear does nothing.

Clear always returns nil as of 1.5.0-alpha.

func (*Image) ColorModel

func (i *Image) ColorModel() color.Model

ColorModel returns the color model of the image.

func (*Image) Dispose added in v1.2.0

func (i *Image) Dispose() error

Dispose disposes the image data. After disposing, most of image functions do nothing and returns meaningless values.

Dispose is useful to save memory.

When the image is disposed, Dipose does nothing.

Dipose always return nil as of 1.5.0-alpha.

func (*Image) DrawImage

func (i *Image) DrawImage(img *Image, options *DrawImageOptions) error

DrawImage draws the given image on the image i.

DrawImage accepts the options. For details, see the document of DrawImageOptions.

DrawImage determinines the part to draw, then DrawImage applies the geometry matrix and the color matrix.

For drawing, the pixels of the argument image at the time of this call is adopted. Even if the argument image is mutated after this call, the drawing result is never affected.

When the i is disposed, DrawImage does nothing.

When the given image is as same as i, DrawImage panics.

DrawImage works more efficiently as batches when the successive calls of DrawImages satisfies the below conditions:

  • All render targets are same (A in A.DrawImage(B, op))
  • All render sources are same (B in A.DrawImage(B, op))
  • All ColorM values are same
  • All CompositeMode values are same

For more performance tips, see https://github.com/hajimehoshi/ebiten/wiki/Performance-Tips.

DrawImage always returns nil as of 1.5.0-alpha.

func (*Image) Fill

func (i *Image) Fill(clr color.Color) error

Fill fills the image with a solid color.

When the image is disposed, Fill does nothing.

Fill always returns nil as of 1.5.0-alpha.

func (*Image) ReplacePixels added in v1.2.0

func (i *Image) ReplacePixels(p []byte) error

ReplacePixels replaces the pixels of the image with p.

The given p must represent RGBA pre-multiplied alpha values. len(p) must equal to 4 * (image width) * (image height).

ReplacePixels may be slow (as for implementation, this calls glTexSubImage2D).

When len(p) is not appropriate, ReplacePixels panics.

When the image is disposed, ReplacePixels does nothing.

ReplacePixels always returns nil as of 1.5.0-alpha.

func (*Image) Size

func (i *Image) Size() (width, height int)

Size returns the size of the image.

type ImagePart

type ImagePart struct {
	Dst image.Rectangle
	Src image.Rectangle
}

An ImagePart is deprecated (as of 1.1.0-alpha): Use SourceRect instead.

type ImageParts added in v1.1.0

type ImageParts interface {
	Len() int
	Dst(i int) (x0, y0, x1, y1 int)
	Src(i int) (x0, y0, x1, y1 int)
}

An ImageParts is deprecated (as of 1.5.0-alpha): Use SourceRect instead.

type Key

type Key int

A Key represents a keyboard key. These keys represent pysical keys of US keyboard. For example, KeyQ represents Q key on US keyboards and ' (quote) key on Dvorak keyboards.

const (
	Key0            Key = Key(ui.Key0)
	Key1            Key = Key(ui.Key1)
	Key2            Key = Key(ui.Key2)
	Key3            Key = Key(ui.Key3)
	Key4            Key = Key(ui.Key4)
	Key5            Key = Key(ui.Key5)
	Key6            Key = Key(ui.Key6)
	Key7            Key = Key(ui.Key7)
	Key8            Key = Key(ui.Key8)
	Key9            Key = Key(ui.Key9)
	KeyA            Key = Key(ui.KeyA)
	KeyB            Key = Key(ui.KeyB)
	KeyC            Key = Key(ui.KeyC)
	KeyD            Key = Key(ui.KeyD)
	KeyE            Key = Key(ui.KeyE)
	KeyF            Key = Key(ui.KeyF)
	KeyG            Key = Key(ui.KeyG)
	KeyH            Key = Key(ui.KeyH)
	KeyI            Key = Key(ui.KeyI)
	KeyJ            Key = Key(ui.KeyJ)
	KeyK            Key = Key(ui.KeyK)
	KeyL            Key = Key(ui.KeyL)
	KeyM            Key = Key(ui.KeyM)
	KeyN            Key = Key(ui.KeyN)
	KeyO            Key = Key(ui.KeyO)
	KeyP            Key = Key(ui.KeyP)
	KeyQ            Key = Key(ui.KeyQ)
	KeyR            Key = Key(ui.KeyR)
	KeyS            Key = Key(ui.KeyS)
	KeyT            Key = Key(ui.KeyT)
	KeyU            Key = Key(ui.KeyU)
	KeyV            Key = Key(ui.KeyV)
	KeyW            Key = Key(ui.KeyW)
	KeyX            Key = Key(ui.KeyX)
	KeyY            Key = Key(ui.KeyY)
	KeyZ            Key = Key(ui.KeyZ)
	KeyAlt          Key = Key(ui.KeyAlt)
	KeyApostrophe   Key = Key(ui.KeyApostrophe)
	KeyBackslash    Key = Key(ui.KeyBackslash)
	KeyBackspace    Key = Key(ui.KeyBackspace)
	KeyCapsLock     Key = Key(ui.KeyCapsLock)
	KeyComma        Key = Key(ui.KeyComma)
	KeyControl      Key = Key(ui.KeyControl)
	KeyDelete       Key = Key(ui.KeyDelete)
	KeyDown         Key = Key(ui.KeyDown)
	KeyEnd          Key = Key(ui.KeyEnd)
	KeyEnter        Key = Key(ui.KeyEnter)
	KeyEqual        Key = Key(ui.KeyEqual)
	KeyEscape       Key = Key(ui.KeyEscape)
	KeyF1           Key = Key(ui.KeyF1)
	KeyF2           Key = Key(ui.KeyF2)
	KeyF3           Key = Key(ui.KeyF3)
	KeyF4           Key = Key(ui.KeyF4)
	KeyF5           Key = Key(ui.KeyF5)
	KeyF6           Key = Key(ui.KeyF6)
	KeyF7           Key = Key(ui.KeyF7)
	KeyF8           Key = Key(ui.KeyF8)
	KeyF9           Key = Key(ui.KeyF9)
	KeyF10          Key = Key(ui.KeyF10)
	KeyF11          Key = Key(ui.KeyF11)
	KeyF12          Key = Key(ui.KeyF12)
	KeyGraveAccent  Key = Key(ui.KeyGraveAccent)
	KeyHome         Key = Key(ui.KeyHome)
	KeyInsert       Key = Key(ui.KeyInsert)
	KeyLeft         Key = Key(ui.KeyLeft)
	KeyLeftBracket  Key = Key(ui.KeyLeftBracket)
	KeyMinus        Key = Key(ui.KeyMinus)
	KeyPageDown     Key = Key(ui.KeyPageDown)
	KeyPageUp       Key = Key(ui.KeyPageUp)
	KeyPeriod       Key = Key(ui.KeyPeriod)
	KeyRight        Key = Key(ui.KeyRight)
	KeyRightBracket Key = Key(ui.KeyRightBracket)
	KeySemicolon    Key = Key(ui.KeySemicolon)
	KeyShift        Key = Key(ui.KeyShift)
	KeySlash        Key = Key(ui.KeySlash)
	KeySpace        Key = Key(ui.KeySpace)
	KeyTab          Key = Key(ui.KeyTab)
	KeyUp           Key = Key(ui.KeyUp)
	KeyMax          Key = KeyUp
)

Keys

type MouseButton

type MouseButton int

A MouseButton represents a mouse button.

const (
	MouseButtonLeft   MouseButton = MouseButton(ui.MouseButtonLeft)
	MouseButtonRight  MouseButton = MouseButton(ui.MouseButtonRight)
	MouseButtonMiddle MouseButton = MouseButton(ui.MouseButtonMiddle)
)

MouseButtons

type Touch added in v1.4.0

type Touch interface {
	// ID returns an identifier for one stroke.
	ID() int

	// Position returns the position of the touch.
	Position() (x, y int)
}

Touch represents a touch state.

func Touches added in v1.4.0

func Touches() []Touch

Touches returns the current touch states.

Touches always returns nil on desktops.

Directories

Path Synopsis
Package audio provides audio players.
Package audio provides audio players.
mp3
Package mp3 provides MP3 decoder.
Package mp3 provides MP3 decoder.
vorbis
Package vorbis provides Ogg/Vorbis decoder.
Package vorbis provides Ogg/Vorbis decoder.
wav
Package wav provides WAV (RIFF) decoder.
Package wav provides WAV (RIFF) decoder.
Package ebitenutil provides utility functions for Ebiten.
Package ebitenutil provides utility functions for Ebiten.
examples
clock
Package clock manages game timers.
Package clock manages game timers.
graphics
Package graphics represents a low layer for graphics using OpenGL.
Package graphics represents a low layer for graphics using OpenGL.
restorable
Package restorable offers an Image struct that stores image commands and restores its pixel data from the commands when context lost happens.
Package restorable offers an Image struct that stores image commands and restores its pixel data from the commands when context lost happens.
ui
web
Package mobile provides functions for mobile platforms (Android and iOS).
Package mobile provides functions for mobile platforms (Android and iOS).
Package text offers functions to draw texts on an Ebiten's image.
Package text offers functions to draw texts on an Ebiten's image.

Jump to

Keyboard shortcuts

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