ui

package
v2.3.7 Latest Latest
Warning

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

Go to latest
Published: Jul 15, 2022 License: Apache-2.0 Imports: 29 Imported by: 0

Documentation

Index

Constants

View Source
const DefaultTPS = 60

Variables

View Source
var RegularTermination = errors.New("regular termination")

RegularTermination represents a regular termination. Run can return this error, and if this error is received, the game loop should be terminated as soon as possible.

Functions

func DumpImages

func DumpImages(dir string) error

func GraphicsDriverForTesting

func GraphicsDriverForTesting() graphicsdriver.Graphics

func IsScreenClearedEveryFrame

func IsScreenClearedEveryFrame() bool

func IsScreenFilterEnabled

func IsScreenFilterEnabled() bool

func MaxTPS

func MaxTPS() int

func SetFPSMode

func SetFPSMode(fpsMode FPSModeType)

func SetMaxTPS

func SetMaxTPS(tps int)

func SetPanicOnErrorOnReadingPixelsForTesting

func SetPanicOnErrorOnReadingPixelsForTesting(value bool)

func SetScreenClearedEveryFrame

func SetScreenClearedEveryFrame(cleared bool)

func SetScreenFilterEnabled

func SetScreenFilterEnabled(enabled bool)

Types

type CursorMode

type CursorMode int
const (
	CursorModeVisible CursorMode = iota
	CursorModeHidden
	CursorModeCaptured
)

type CursorShape

type CursorShape int
const (
	CursorShapeDefault CursorShape = iota
	CursorShapeText
	CursorShapeCrosshair
	CursorShapePointer
	CursorShapeEWResize
	CursorShapeNSResize
)

type FPSModeType

type FPSModeType int
const (
	FPSModeVsyncOn FPSModeType = iota
	FPSModeVsyncOffMaximum
	FPSModeVsyncOffMinimum
)

func FPSMode

func FPSMode() FPSModeType

type Game

type Game interface {
	NewOffscreenImage(width, height int) *Image
	Layout(outsideWidth, outsideHeight int) (int, int)
	Update() error
	Draw()
}

type Image

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

func NewImage

func NewImage(width, height int) *Image

func (*Image) At

func (i *Image) At(x, y int) (r, g, b, a byte)

func (*Image) DrawTriangles

func (i *Image) DrawTriangles(srcs [graphics.ShaderImageNum]*Image, vertices []float32, indices []uint16, colorm affine.ColorM, mode graphicsdriver.CompositeMode, filter graphicsdriver.Filter, address graphicsdriver.Address, dstRegion, srcRegion graphicsdriver.Region, subimageOffsets [graphics.ShaderImageNum - 1][2]float32, shader *Shader, uniforms [][]float32, evenOdd bool, canSkipMipmap bool)

func (*Image) DumpScreenshot

func (i *Image) DumpScreenshot(name string, blackbg bool) error

func (*Image) Fill

func (i *Image) Fill(r, g, b, a float32, x, y, width, height int)

func (*Image) MarkDisposed

func (i *Image) MarkDisposed()

func (*Image) ReplacePixels

func (i *Image) ReplacePixels(pix []byte, x, y, width, height int)

type Input

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

func (*Input) AppendInputChars

func (i *Input) AppendInputChars(runes []rune) []rune

func (*Input) AppendTouchIDs

func (i *Input) AppendTouchIDs(touchIDs []TouchID) []TouchID

func (*Input) CursorPosition

func (i *Input) CursorPosition() (x, y int)

func (*Input) IsKeyPressed

func (i *Input) IsKeyPressed(key Key) bool

func (*Input) IsMouseButtonPressed

func (i *Input) IsMouseButtonPressed(button MouseButton) bool

func (*Input) TouchPosition

func (i *Input) TouchPosition(id TouchID) (x, y int)

func (*Input) Wheel

func (i *Input) Wheel() (xoff, yoff float64)

type Key

type Key int
const (
	KeyA Key = iota
	KeyB
	KeyC
	KeyD
	KeyE
	KeyF
	KeyG
	KeyH
	KeyI
	KeyJ
	KeyK
	KeyL
	KeyM
	KeyN
	KeyO
	KeyP
	KeyQ
	KeyR
	KeyS
	KeyT
	KeyU
	KeyV
	KeyW
	KeyX
	KeyY
	KeyZ
	KeyAltLeft
	KeyAltRight
	KeyArrowDown
	KeyArrowLeft
	KeyArrowRight
	KeyArrowUp
	KeyBackquote
	KeyBackslash
	KeyBackspace
	KeyBracketLeft
	KeyBracketRight
	KeyCapsLock
	KeyComma
	KeyContextMenu
	KeyControlLeft
	KeyControlRight
	KeyDelete
	KeyDigit0
	KeyDigit1
	KeyDigit2
	KeyDigit3
	KeyDigit4
	KeyDigit5
	KeyDigit6
	KeyDigit7
	KeyDigit8
	KeyDigit9
	KeyEnd
	KeyEnter
	KeyEqual
	KeyEscape
	KeyF1
	KeyF2
	KeyF3
	KeyF4
	KeyF5
	KeyF6
	KeyF7
	KeyF8
	KeyF9
	KeyF10
	KeyF11
	KeyF12
	KeyHome
	KeyInsert
	KeyMetaLeft
	KeyMetaRight
	KeyMinus
	KeyNumLock
	KeyNumpad0
	KeyNumpad1
	KeyNumpad2
	KeyNumpad3
	KeyNumpad4
	KeyNumpad5
	KeyNumpad6
	KeyNumpad7
	KeyNumpad8
	KeyNumpad9
	KeyNumpadAdd
	KeyNumpadDecimal
	KeyNumpadDivide
	KeyNumpadEnter
	KeyNumpadEqual
	KeyNumpadMultiply
	KeyNumpadSubtract
	KeyPageDown
	KeyPageUp
	KeyPause
	KeyPeriod
	KeyPrintScreen
	KeyQuote
	KeyScrollLock
	KeySemicolon
	KeyShiftLeft
	KeyShiftRight
	KeySlash
	KeySpace
	KeyTab
	KeyReserved0
	KeyReserved1
	KeyReserved2
	KeyReserved3
)

func (Key) String

func (k Key) String() string

type MouseButton

type MouseButton int
const (
	MouseButtonLeft MouseButton = iota
	MouseButtonRight
	MouseButtonMiddle
)

type Shader

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

func NewShader

func NewShader(ir *shaderir.Program) *Shader

func (*Shader) MarkDisposed

func (s *Shader) MarkDisposed()

type TouchID

type TouchID int

type UserInterface

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

func Get

func Get() *UserInterface

func (*UserInterface) CursorMode

func (u *UserInterface) CursorMode() CursorMode

func (*UserInterface) CursorShape

func (u *UserInterface) CursorShape() CursorShape

func (*UserInterface) DeviceScaleFactor

func (u *UserInterface) DeviceScaleFactor() float64

func (*UserInterface) Input

func (u *UserInterface) Input() *Input

func (*UserInterface) IsFocused

func (u *UserInterface) IsFocused() bool

func (*UserInterface) IsFullscreen

func (u *UserInterface) IsFullscreen() bool

func (*UserInterface) IsRunnableOnUnfocused

func (u *UserInterface) IsRunnableOnUnfocused() bool

func (*UserInterface) IsScreenTransparent

func (u *UserInterface) IsScreenTransparent() bool

func (*UserInterface) Run

func (u *UserInterface) Run(game Game) error

func (*UserInterface) ScheduleFrame

func (u *UserInterface) ScheduleFrame()

func (*UserInterface) ScreenSizeInFullscreen

func (u *UserInterface) ScreenSizeInFullscreen() (int, int)

func (*UserInterface) SetCursorMode

func (u *UserInterface) SetCursorMode(mode CursorMode)

func (*UserInterface) SetCursorShape

func (u *UserInterface) SetCursorShape(shape CursorShape)

func (*UserInterface) SetFPSMode

func (u *UserInterface) SetFPSMode(mode FPSModeType)

func (*UserInterface) SetFullscreen

func (u *UserInterface) SetFullscreen(fullscreen bool)

func (*UserInterface) SetInitFocused

func (u *UserInterface) SetInitFocused(focused bool)

func (*UserInterface) SetRunnableOnUnfocused

func (u *UserInterface) SetRunnableOnUnfocused(runnableOnUnfocused bool)

func (*UserInterface) SetScreenTransparent

func (u *UserInterface) SetScreenTransparent(transparent bool)

func (*UserInterface) Window

func (u *UserInterface) Window() *Window

type Window

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

func (*Window) IsBeingClosed

func (w *Window) IsBeingClosed() bool

func (*Window) IsClosingHandled

func (w *Window) IsClosingHandled() bool

func (*Window) IsDecorated

func (w *Window) IsDecorated() bool

func (*Window) IsFloating

func (w *Window) IsFloating() bool

func (*Window) IsMaximized

func (w *Window) IsMaximized() bool

func (*Window) IsMinimized

func (w *Window) IsMinimized() bool

func (*Window) Maximize

func (w *Window) Maximize()

func (*Window) Minimize

func (w *Window) Minimize()

func (*Window) Position

func (w *Window) Position() (int, int)

func (*Window) ResizingMode

func (w *Window) ResizingMode() WindowResizingMode

func (*Window) Restore

func (w *Window) Restore()

func (*Window) SetClosingHandled

func (w *Window) SetClosingHandled(handled bool)

func (*Window) SetDecorated

func (w *Window) SetDecorated(decorated bool)

func (*Window) SetFloating

func (w *Window) SetFloating(floating bool)

func (*Window) SetIcon

func (w *Window) SetIcon(iconImages []image.Image)

func (*Window) SetPosition

func (w *Window) SetPosition(x, y int)

func (*Window) SetResizingMode

func (w *Window) SetResizingMode(mode WindowResizingMode)

func (*Window) SetSize

func (w *Window) SetSize(width, height int)

func (*Window) SetSizeLimits

func (w *Window) SetSizeLimits(minw, minh, maxw, maxh int)

func (*Window) SetTitle

func (w *Window) SetTitle(title string)

func (*Window) Size

func (w *Window) Size() (int, int)

func (*Window) SizeLimits

func (w *Window) SizeLimits() (minw, minh, maxw, maxh int)

type WindowResizingMode

type WindowResizingMode int
const (
	WindowResizingModeDisabled WindowResizingMode = iota
	WindowResizingModeOnlyFullscreenEnabled
	WindowResizingModeEnabled
)

Jump to

Keyboard shortcuts

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