window

package
v0.0.0-...-626b7ce Latest Latest
Warning

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

Go to latest
Published: Oct 16, 2023 License: Unlicense Imports: 15 Imported by: 0

Documentation

Overview

Package window handles window creation, drawing and events. It uses a small subset of the features provided by the raylib library version 4.5.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DrawFPS

func DrawFPS(pt image.Point)

DrawFPS draws the current FPS at the specified point.

Types

type Font

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

A Font provides glyphs (visual characters) and metrics used for text rendering.

func LoadFont

func LoadFont(ttfPath string) (*Font, error)

LoadFont loads the provided TTF font.

Note: a finalizer is registered to unload the font.

type Shader

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

Shader holds a vertex or fragment shader.

func LoadShader

func LoadShader(vsPath, fsPath string) (*Shader, error)

LoadShader loads the given vertex and fragment shader.

func (*Shader) Disable

func (shader *Shader) Disable()

Disable disables drawing of the shader.

func (*Shader) Enable

func (shader *Shader) Enable()

Enable enables drawing of the shader.

type Text

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

Text represent a graphical text entry with a specific font, font size, and colour. It implements the wandi.Image interface.

func NewText

func NewText(args ...interface{}) *Text

NewText returns a new graphical text entry. The initial text, font, font size, and colour of the graphical text entry can be customized through string, *Font, int, and color.Color arguments respectively, depending on the type of the argument.

The default font, font size and colour of the text is default font, 12 and black, respectively.

func (*Text) Height

func (text *Text) Height() int

Height returns the height of the text entry.

func (*Text) SetColor

func (text *Text) SetColor(c color.Color)

SetColor sets the colour of the text.

func (*Text) SetFont

func (text *Text) SetFont(font *Font)

SetFont sets the font of the text.

func (*Text) SetFontSize

func (text *Text) SetFontSize(fontSize int)

SetFontSize sets the font size, in pixels, of the text.

func (*Text) SetText

func (text *Text) SetText(s string)

SetText sets the text of the text entry.

func (*Text) Width

func (text *Text) Width() int

Width returns the width of the text entry.

type Texture

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

Texture represent a read-only texture. It implements the wandi.Image interface.

func LoadTexture

func LoadTexture(path string) (*Texture, error)

LoadTexture loads the provided file and converts it into a read-only texture.

Note: a finalizer is registered to unload the texture.

func LoadTextureFromImage

func LoadTextureFromImage(src image.Image) (*Texture, error)

LoadTextureFromImage reads the provided image and converts it into a read-only texture.

Note: a finalizer is registered to unload the texture.

func (*Texture) Height

func (tex *Texture) Height() int

Height returns the height of the texture.

func (*Texture) Image

func (tex *Texture) Image() image.Image

Image converts the texture to a corresponding Go image.Image.

func (*Texture) Width

func (tex *Texture) Width() int

Width returns the width of the texture.

type Window

type Window struct {
}

A Window represents a graphical window capable of handling draw operations and window events. It implements the wandi.Window interface.

func Open

func Open(width, height int) (*Window, error)

Open opens a new window of the specified dimensions.

Note: the caller is responsible for invoking Close when finished using the window.

func (*Window) Clear

func (win *Window) Clear(c color.Color)

Clear clears the entire window with the given color.

func (*Window) Close

func (*Window) Close()

Close closes the window.

func (*Window) CursorPos

func (*Window) CursorPos() image.Point

CursorPos returns the current cursor position within the given window.

func (*Window) Display

func (*Window) Display()

Display displays what has been rendered so far to the window.

func (*Window) Draw

func (win *Window) Draw(dp image.Point, src wandi.Image) error

Draw draws the entire src image onto the window starting at the destination point dp.

func (*Window) DrawRect

func (win *Window) DrawRect(dp image.Point, src wandi.Image, sr image.Rectangle) error

DrawRect draws a subset of the src image, as defined by the source rectangle sr, onto the window starting at the destination point dp.

func (*Window) Height

func (*Window) Height() int

Height returns the height of the window.

func (*Window) PollEvent

func (*Window) PollEvent() we.Event

PollEvent returns a pending event from the event queue or nil if the queue was empty. Note that more than one event may be present in the event queue.

Note: the event queue is populated once per frame upon call to Window.Display.

func (*Window) SetCursorPos

func (*Window) SetCursorPos(pt image.Point)

SetCursorPos sets the position of the cursor in the given window.

func (*Window) SetTitle

func (*Window) SetTitle(title string)

SetTitle sets the title of the window.

func (*Window) ShowCursor

func (*Window) ShowCursor(visible bool)

ShowCursor displays or hides the mouse cursor depending on the value of visible. It is visible by default.

func (*Window) Width

func (*Window) Width() int

Width returns the width of the window.

Jump to

Keyboard shortcuts

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