Documentation ¶
Index ¶
- type Animation
- type Canvas
- func (c *Canvas) At(x, y int) color.Color
- func (c *Canvas) Bounds() image.Rectangle
- func (c *Canvas) Clear() error
- func (c *Canvas) Close() error
- func (c *Canvas) ColorModel() color.Model
- func (c *Canvas) IsClosed() bool
- func (c *Canvas) Render() error
- func (c *Canvas) Set(x, y int, color color.Color)
- type Matrix
- type ToolKit
- func (tk *ToolKit) Close() error
- func (tk *ToolKit) DrawCircle(x, y, r int, col color.Color) error
- func (tk *ToolKit) DrawString(message string, indent int, col color.Color, face *basicfont.Face) error
- func (tk *ToolKit) PlayAnimation(a Animation) error
- func (tk *ToolKit) PlayGIF(r io.Reader) (chan bool, error)
- func (tk *ToolKit) PlayImage(i image.Image, delay time.Duration) error
- func (tk *ToolKit) PlayImageUntil(i image.Image, notify <-chan time.Time) error
- func (tk *ToolKit) PlayImages(images []image.Image, delay []time.Duration, loop int) chan bool
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Canvas ¶
type Canvas struct {
// contains filtered or unexported fields
}
Canvas is an image.Image representation of a WS281x matrix, it implements image.Image interface and can be used with draw.Draw for example
func NewCanvas ¶
NewCanvas returns a new Canvas using the given width and height and creates a new WS281x matrix using the given config
func (*Canvas) ColorModel ¶
ColorModel returns the canvas' color model, always color.RGBAModel
type Matrix ¶
type Matrix interface { Geometry() (width, height int) At(position int) color.Color Set(position int, c color.Color) Apply([]color.Color) error SetBrightness(b uint8) error Render() error Close() error }
Matrix is an interface that represent any RGB matrix, very useful for testing
type ToolKit ¶
type ToolKit struct { // Canvas is the Canvas wrapping the Matrix, if you want to instanciate // a ToolKit with a custom Canvas you can use directly the struct, // without calling NewToolKit Canvas *Canvas // Transform function if present is applied just before draw the image to // the Matrix, this is a small example: // tk.Transform = func(img image.Image) *image.NRGBA { // return imaging.Fill(img, 64, 96, imaging.Center, imaging.Lanczos) // } Transform func(img image.Image) *image.NRGBA }
ToolKit is a convinient set of function to operate with a led of Matrix
func NewToolKit ¶
NewToolKit returns a new ToolKit wrapping the given Matrix
func (*ToolKit) DrawCircle ¶
DrawCircle - simple way.
func (*ToolKit) DrawString ¶
func (tk *ToolKit) DrawString(message string, indent int, col color.Color, face *basicfont.Face) error
DrawString - simple way, requires delimiter "\n" for a new line.
func (*ToolKit) PlayAnimation ¶
PlayAnimation play the image during the delay returned by Next, until an err is returned, if io.EOF is returned, PlayAnimation finish without an error
func (*ToolKit) PlayGIF ¶
PlayGIF reads and draw a gif file from r. It use the contained images and delays and loops over it, until a true is sent to the returned chan
func (*ToolKit) PlayImageUntil ¶
PlayImageUntil draws the given image until is notified to stop
func (*ToolKit) PlayImages ¶
PlayImages draws a sequence of images during the given delays, the len of images should be equal to the len of delay. If loop is true the function loops over images until a true is sent to the returned chan