canvas: github.com/BakeRolls/canvas Index | Examples | Files | Directories

package canvas

import "github.com/BakeRolls/canvas"

Package canvas allows drawing an image.Image to a window.

Code:

img := image.NewRGBA(image.Rect(0, 0, 640, 480))

c, err := New(img, 1, "Canvas Title")
if err != nil {
    log.Fatal(err)
}
defer c.Close()

// Update returns true until the window should be closed.
for c.Update() {
    // Modify the image based on its Pix slice or Set.
    c.Draw()
}

Index

Examples

Package Files

canvas.go

type Canvas Uses

type Canvas struct {
    Mu *sync.Mutex
    // contains filtered or unexported fields
}

Canvas to draw an image on.

func New Uses

func New(img image.Image, scale int, title string) (*Canvas, error)

New creates a new canvas.

func (Canvas) Close Uses

func (c Canvas) Close()

Close the window.

func (Canvas) Draw Uses

func (c Canvas) Draw() error

Draw clears and redraws the image.

func (Canvas) Update Uses

func (c Canvas) Update() bool

Update determines if the window shold get closed.

Directories

PathSynopsis
example

Package canvas imports 4 packages (graph) and is imported by 1 packages. Updated 2018-04-23. Refresh now. Tools for package owners.