grafio

package
v0.0.0-...-bbac6e9 Latest Latest
Warning

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

Go to latest
Published: Dec 18, 2018 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ColorGreen rgba green color
	ColorGreen = RGBA{R: 34, G: 139, B: 34, A: 10}

	// ColorWhite rgba white color
	ColorWhite = RGBA{R: 255, G: 255, B: 255, A: 255}

	// ColorBlack rgba black color
	ColorBlack = RGBA{R: 0, G: 0, B: 0, A: 0}
)

Functions

This section is empty.

Types

type Drawer

type Drawer interface {
	// Background draws the whole background to the given RGBA color
	Background(rgba RGBA) error

	// Text writes given text with given options to the window
	Text(txt string, opts TextOpts) error

	// ColorRect draw rectangle with the given color
	ColorRect(x, y, w, h int32, rgba RGBA) error

	// TextureRect draw rectangle with the given texture file name
	TextureRect(x, y, w, h int32, texture string) error

	// Present draws everything into the window
	Present(f func() error) error

	// LoadResources loads fonts and textures of the given path
	LoadResources(fontsPath, texturesPath string) (func() error, error)

	// SetMainFont Set default font, if someone will use Text function the Main font will be used
	SetMainFont(fontFileName string) error

	// ScreenHeight returns the height of screen in pixels
	ScreenHeight() int32

	// ScreenWidth returns the width of screen in pixels
	ScreenWidth() int32
}

Drawer an engine who can draw on window

type RGBA

type RGBA struct {
	R, G, B, A uint8
}

RGBA have rgba color values

type RectOpts

type RectOpts struct {
	Texture string
	Color   RGBA
}

RectOpts options of rectangle

type Sdl2Draw

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

Sdl2Draw adapter for sdl2 go bindings

func NewSdl2Draw

func NewSdl2Draw(font string, w, h int32) (sdl2draw *Sdl2Draw, destroy func() error, erro error)

NewSdl2Draw creates new sdl2draw drawer

func (*Sdl2Draw) Background

func (s *Sdl2Draw) Background(rgba RGBA) error

Background draws whole background of sdl2 window to the given rgba color

func (*Sdl2Draw) ColorRect

func (s *Sdl2Draw) ColorRect(x, y, w, h int32, rgba RGBA) error

ColorRect draws into sdl2 window given color rectangle in the given coordinates

func (*Sdl2Draw) LoadResources

func (s *Sdl2Draw) LoadResources(fontsPath, texturesPath string) (func() error, error)

LoadResources load resources of fonts and textures given path

func (*Sdl2Draw) Present

func (s *Sdl2Draw) Present(f func() error) error

Present makes white background of the window calls user's function

func (Sdl2Draw) ScreenHeight

func (s Sdl2Draw) ScreenHeight() int32

ScreenHeight returns the height in pixels of the sdl2 created screen

func (Sdl2Draw) ScreenWidth

func (s Sdl2Draw) ScreenWidth() int32

ScreenWidth returns the width in pixels of the sdl2 created screen

func (*Sdl2Draw) SetMainFont

func (s *Sdl2Draw) SetMainFont(fontFileName string) error

SetMainFont sets the default font for all text

func (*Sdl2Draw) Text

func (s *Sdl2Draw) Text(txt string, opts TextOpts) (erro error)

Text draws given text with options to the sdl2 window

func (*Sdl2Draw) TextureRect

func (s *Sdl2Draw) TextureRect(x, y, w, h int32, texture string) error

TextureRect draws into sdl2 window with given texture rectangle in the given coordinates

type TextAlign

type TextAlign int

TextAlign type of text alignment side

const Right TextAlign = 2

Right align text to stick in the right

type TextOpts

type TextOpts struct {
	Size       int32
	XCof, YCof float32
	Color      RGBA
	Align      TextAlign
}

TextOpts options of text

Jump to

Keyboard shortcuts

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