gfx

package
v0.0.0-...-f6f1029 Latest Latest
Warning

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

Go to latest
Published: Feb 8, 2024 License: BSD-3-Clause Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Box1

func Box1(x int, y int, width int, height int, renderer *sdl.Renderer, render GuiRenderer)

draw a box that clips everything drawn inside of it by the bounds. the box has a 1px white border around it

func CopyArray

func CopyArray[T any](in []T) []T

func CopyTexture

func CopyTexture(texture *sdl.Texture, renderer *sdl.Renderer, width int, height int, x int, y int) error

func DrawEquilateralTriange

func DrawEquilateralTriange(renderer *sdl.Renderer, x int, y int, size float64, angle float64, color sdl.Color) error

func Glow

func Glow(start sdl.Color, end sdl.Color, speed float32, clock uint64) sdl.Color

smoothly interpolate between two colors. clock should be a monotonically increasing value. * speed governs how fast the change will take place where speed=2 will quickly bounce back and * forth between the two colors and speed>2 will interpolate at a slower pace. * speed is a period such that after 'speed' clocks the color will return to the start color. * thus, at half a period the color will be the end color.

func InterpolateColor

func InterpolateColor(start sdl.Color, end sdl.Color, steps int, step int) sdl.Color

smoothly interpolate from start to end given a maximum of steps. if step > steps, then the color * will just be the end color.

func Reverse

func Reverse[T any](in []T)

func TextWidth

func TextWidth(font *ttf.Font, text string) int

func WriteFont

func WriteFont(font *ttf.Font, renderer *sdl.Renderer, x int, y int, message string, color sdl.Color) error

Types

type Coordinates

type Coordinates struct {
	UpperLeftX int
	UpperLeftY int
	Width      int
	Height     int
}

func (Coordinates) MaxX

func (coords Coordinates) MaxX() int

func (Coordinates) MaxY

func (coords Coordinates) MaxY() int

func (Coordinates) X

func (coords Coordinates) X(x int) int

func (Coordinates) Y

func (coords Coordinates) Y(y int) int

type GuiRenderer

type GuiRenderer func(coords Coordinates)

type PixelFormat

type PixelFormat uint32

func FindPixelFormat

func FindPixelFormat() PixelFormat

determine endianness of the host by comparing the least-significant byte of a 32-bit number * versus a little endian byte array * if the first byte in the byte array is the same as the lowest byte of the 32-bit number * then the host is little endian

type RenderFunction

type RenderFunction func(*sdl.Renderer) error

type RenderInfo

type RenderInfo struct {
	Renderer  *sdl.Renderer
	Font      *ttf.Font
	SmallFont *ttf.Font
	Window    *sdl.Window
}

type RenderLayer

type RenderLayer interface {
	Render(RenderInfo) error
	ZIndex() int // order of the layer
}

type RenderLayerList

type RenderLayerList []RenderLayer

func (RenderLayerList) Len

func (list RenderLayerList) Len() int

func (RenderLayerList) Less

func (list RenderLayerList) Less(a int, b int) bool

func (RenderLayerList) Swap

func (list RenderLayerList) Swap(a int, b int)

type RenderManager

type RenderManager struct {
	Layers RenderLayerList
	/* FIXME: maybe use the actor-style message passing loop instead of a lock */
	Lock sync.Mutex
}

func (*RenderManager) AddLayer

func (manager *RenderManager) AddLayer(layer RenderLayer)

func (*RenderManager) RemoveByIndex

func (manager *RenderManager) RemoveByIndex(index int)

func (*RenderManager) RemoveLayer

func (manager *RenderManager) RemoveLayer(remove RenderLayer)

func (*RenderManager) RenderAll

func (manager *RenderManager) RenderAll(info RenderInfo) error

func (*RenderManager) Replace

func (manager *RenderManager) Replace(index int, layer RenderLayer)

Jump to

Keyboard shortcuts

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