graphics

package
Version: v0.0.3-alpha Latest Latest
Warning

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

Go to latest
Published: Oct 26, 2020 License: MIT Imports: 1 Imported by: 3

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Adapters

type Adapters interface {
	//TextureLoader returns the adapter that is used to load textures
	TextureLoader() TextureLoader
	//TextureCreator returns the adapter that is used to create simple unicolored textures
	TextureCreator() TextureCreator
	//FontLoader returns the adapter that is used to load fonts
	FontLoader() FontLoader
	//WindowAdapter returns the adapter that is used to open and close the game window
	WindowAdapter() WindowAdapter
	//ScreenPresenter returns the adapter that is used to update the screen
	ScreenPresenter() ScreenPresenter
}

Adapters gives access to all graphics adapters

type FontLoader

type FontLoader interface {
	//Loads a font from the filesystem and returns a TextCreator
	Load(fileName string, size int) (TextCreator, error)
}

FontLoader is the adapter that is used to load fonts

type ScreenPresenter

type ScreenPresenter interface {
	//Present updates the screen from the screen buffer
	Present() error
	//Clear deletes the screen buffer
	Clear() error
}

ScreenPresenter is the adapter that is used to update the game screen

type TextCreator

type TextCreator interface {
	//Create returns a drawable text
	Create(text string, color primitives.Color) (TextDrawer, error)
}

TextCreator is the adapter that is returned by FontLoader. It is used to create a text with the loaded font

type TextDrawer

type TextDrawer interface {
	//Draw renders the text in its original size to the defined position
	Draw(position *primitives.Point) error
	//DrawScaled draws the text into the defined destRect
	DrawScaled(destRect *primitives.Rectangle) error
	//DrawF renders the text in its original size to the defined position
	DrawF(position *primitives.PointF) error
	//DrawScaledF draws the text into the defined destRect
	DrawScaledF(destRect *primitives.RectangleF) error
	//Dimensions returns the size of the text
	Dimensions() primitives.Dimensions
}

TextDrawer is the adapter that is used to draw text

type Texture

type Texture interface {
	TextureDrawer
	Dimensions() primitives.Dimensions
}

type TextureCreator

type TextureCreator interface {
	Create(dimensions *primitives.Dimensions, color *primitives.Color) (Texture, error)
}

type TextureDrawer

type TextureDrawer interface {
	//Draw draws the part of the texture, that is defined by source to the location defined by dest
	//Pass source == nil to draw the whole texture
	Draw(source, dest *primitives.Rectangle) error
	//DrawF draws the part of the texture, that is defined by source to the location defined by dest
	//Pass source == nil to draw the whole texture
	DrawF(source *primitives.Rectangle, dest *primitives.RectangleF) error
}

TextureDrawer is the adapter that draws a texture to the screen

type TextureLoader

type TextureLoader interface {
	Load(fileName string) (Texture, error)
}

TextureLoader is the adapter that is used to draw a texture

type WindowAdapter

type WindowAdapter interface {
	//OpenWindow opens a game window
	OpenWindow(windowSettings *WindowSettings) error
	//IsOpen returns true if the window was opened
	IsOpen() bool
	//Size returns the window's dimensions
	Size() primitives.Dimensions
}

WindowAdapter is to be implemented by the graphics adapter

type WindowSettings

type WindowSettings struct {
	//Fullscreen defines if the game window should use the whole screen.
	//The size of the game window is the Resolution, if Fullscreen is false
	Fullscreen bool
	//Resolution defines the resolution of the game window
	Resolution primitives.Dimensions
	//Title is the game's title that is used as the window title
	Title string
}

WindowSettings contains all the settings needed to show the game window

Jump to

Keyboard shortcuts

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