framebuf

package
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: Mar 16, 2024 License: MIT Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Colour

func Colour(r, g, b uint8) color.Color

Colour will turn RGB values into a Go-compatible colour

func HexColour

func HexColour(s string) (c color.RGBA)

HexColour will parse a HTML-style hexcode into a Go-compatible colour

Types

type Config

type Config struct {
	// Rotate will rotate the final image by the specified
	// number of degrees before writing to the framebuffer
	// nb: get the best performance by using a multiple of 90
	Rotate int

	// TickFunc is the function you want to (optionally) call every time a frame
	// is rendered
	TickFunc TickFunction
	TickTime time.Duration
}

Config defines any specific configuration for this framebuffer

type Framebuffer

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

Framebuffer is an instance of a particular framebuffer, helpfully wrapping a double-buffering and hashing mechanism to help improve the experience of using a raw framebuffer

func NewFramebuffer

func NewFramebuffer(cfg *Config) (*Framebuffer, error)

NewFramebuffer will create a new Framebuffer with the given configuration

func (*Framebuffer) Bounds

func (fb *Framebuffer) Bounds() image.Rectangle

Bounds returns the size of the framebuffer

func (*Framebuffer) Clear

func (fb *Framebuffer) Clear(c color.Color)

Clear will clear the framebuffer with the specified colour

func (*Framebuffer) Draw

func (fb *Framebuffer) Draw() *gg.Context

Draw will return a context for drawing on the framebuffer

func (*Framebuffer) ForceDraw

func (fb *Framebuffer) ForceDraw()

ForceDraw will force a redraw on the next frame

func (*Framebuffer) Randomize

func (fb *Framebuffer) Randomize() error

Randomize will fill the framebuffer with random data

func (*Framebuffer) Start

func (fb *Framebuffer) Start(fps int) chan bool

Start will run the framebuffer render in the background and will return a chan that can be written to to stop the render loop

type TickFunction

type TickFunction func(*Framebuffer)

TickFunction is a function that is called every tick to build or change the buffered image

Jump to

Keyboard shortcuts

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