Package draw
import "exp/draw"
Package draw provides basic graphics and drawing primitives, in the style of the Plan 9 graphics library (see http://plan9.bell-labs.com/magic/man2html/2/draw) and the X Render extension.
Package files
draw.go event.gofunc Border
func Border(dst Image, r image.Rectangle, w int, src image.Image, sp image.Point)
Border aligns r.Min in dst with sp in src and then replaces pixels in a w-pixel border around r in dst with the result of the Porter-Duff compositing operation “src over dst.” If w is positive, the border extends w pixels inside r. If w is negative, the border extends w pixels outside r.
func Draw
func Draw(dst Image, r image.Rectangle, src image.Image, sp image.Point)
Draw calls DrawMask with a nil mask and an Over op.
func DrawMask
func DrawMask(dst Image, r image.Rectangle, src image.Image, sp image.Point, mask image.Image, mp image.Point, op Op)
DrawMask aligns r.Min in dst with sp in src and mp in mask and then replaces the rectangle r in dst with the result of a Porter-Duff composition. A nil mask is treated as opaque. The implementation is simple and slow. TODO(nigeltao): Optimize this.
type Context
A Context represents a single graphics window.
type Context interface {
// Screen returns an editable Image of window.
Screen() Image
// FlushImage flushes changes made to Screen() back to screen.
FlushImage()
// KeyboardChan returns a channel carrying keystrokes.
// An event is sent each time a key is pressed or released.
// The value k represents key k being pressed.
// The value -k represents key k being released.
// The specific set of key values is not specified,
// but ordinary character represent themselves.
KeyboardChan() <-chan int
// MouseChan returns a channel carrying mouse events.
// A new event is sent each time the mouse moves or a
// button is pressed or released.
MouseChan() <-chan Mouse
// ResizeChan returns a channel carrying resize events.
// An event is sent each time the window is resized;
// the client should respond by calling Screen() to obtain
// the new screen image.
// The value sent on the channel is always ``true'' and can be ignored.
ResizeChan() <-chan bool
// QuitChan returns a channel carrying quit requests.
// After reading a value from the quit channel, the application
// should exit.
QuitChan() <-chan bool
}
type Image
A draw.Image is an image.Image with a Set method to change a single pixel.
type Image interface {
image.Image
Set(x, y int, c image.Color)
}
type Mouse
A Mouse represents the state of the mouse.
type Mouse struct {
Buttons int // bit mask of buttons: 1<<0 is left, 1<<1 middle, 1<<2 right
image.Point // location of cursor
Nsec int64 // time stamp
}
type Op
A Porter-Duff compositing operator.
type Op int
const (
// Over specifies ``(src in mask) over dst''.
Over Op = iota
// Src specifies ``src in mask''.
Src
)
Bugs
This is a toy library and not ready for production use.
Subdirectories
| Name | Synopsis | |
|---|---|---|
| .. | ||
| x11 | This package implements an X11 backend for the exp/draw package. |
