Documentation
¶
Overview ¶
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.
Index ¶
- func Border(dst Image, r Rectangle, w int, src image.Image, sp Point)
- func Draw(dst Image, r Rectangle, src image.Image, sp Point)
- func DrawMask(dst Image, r Rectangle, src image.Image, sp Point, mask image.Image, mp Point, ...)
- type Color
- type Context
- type Image
- type Mouse
- type Op
- type Point
- type Rectangle
- func (r Rectangle) Add(p Point) Rectangle
- func (r Rectangle) Canon() Rectangle
- func (r Rectangle) Clip(r1 Rectangle) Rectangle
- func (r Rectangle) Combine(r1 Rectangle) Rectangle
- func (r Rectangle) Dx() int
- func (r Rectangle) Dy() int
- func (r Rectangle) Empty() bool
- func (r Rectangle) In(r1 Rectangle) bool
- func (r Rectangle) Inset(n int) Rectangle
- func (r Rectangle) Overlaps(r1 Rectangle) bool
- func (r Rectangle) Sub(p Point) Rectangle
- Bugs
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Border ¶
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.
Types ¶
type Color ¶
type Color uint32
A Color represents a color with 8-bit R, G, B, and A values, packed into a uint32—0xRRGGBBAA—so that comparison is defined on colors. Color implements image.Color. Color also implements image.Image: it is a 10⁹x10⁹-pixel image of uniform color.
var ( Opaque Color = 0xFFFFFFFF Transparent Color = 0x00000000 Black Color = 0x000000FF White Color = 0xFFFFFFFF Red Color = 0xFF0000FF Green Color = 0x00FF00FF Blue Color = 0x0000FFFF Cyan Color = 0x00FFFFFF Magenta Color = 0xFF00FFFF Yellow Color = 0xFFFF00FF PaleYellow Color = 0xFFFFAAFF DarkYellow Color = 0xEEEE9EFF DarkGreen Color = 0x448844FF PaleGreen Color = 0xAAFFAAFF MedGreen Color = 0x88CC88FF DarkBlue Color = 0x000055FF PaleBlueGreen Color = 0xAAFFFFFF PaleBlue Color = 0x0000BBFF BlueGreen Color = 0x008888FF GreyGreen Color = 0x55AAAAFF PaleGreyGreen Color = 0x9EEEEEFF YellowGreen Color = 0x99994CFF MedBlue Color = 0x000099FF GreyBlue Color = 0x005DBBFF PaleGreyBlue Color = 0x4993DDFF PurpleBlue Color = 0x8888CCFF )
func (Color) ColorModel ¶
func (c Color) ColorModel() image.ColorModel
type Context ¶
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 }
A Context represents a single graphics window.
type Mouse ¶
type Mouse struct { Buttons int // bit mask of buttons: 1<<0 is left, 1<<1 middle, 1<<2 right Point // location of cursor Nsec int64 // time stamp }
A Mouse represents the state of the mouse.
type Point ¶
type Point struct {
X, Y int
}
A Point is an X, Y coordinate pair.
var ZP Point
ZP is the zero Point.
type Rectangle ¶
type Rectangle struct {
Min, Max Point
}
A Rectangle contains the Points with Min.X <= X < Max.X, Min.Y <= Y < Max.Y.
var ZR Rectangle
ZR is the zero Rectangle.
func (Rectangle) Add ¶
Add returns the rectangle r translated by p: Rpt(r.Min.Add(p), r.Max.Add(p)).
func (Rectangle) Canon ¶
Canon returns a canonical version of r: the returned rectangle has Min.X <= Max.X and Min.Y <= Max.Y.
func (Rectangle) Clip ¶
Clip returns the largest rectangle containing only points shared by r and r1.
func (Rectangle) Combine ¶
Combine returns the smallest rectangle containing all points from r and from r1.
func (Rectangle) Inset ¶
Inset returns the rectangle r inset by n: Rect(r.Min.X+n, r.Min.Y+n, r.Max.X-n, r.Max.Y-n).
Notes ¶
Bugs ¶
This is a toy library and not ready for production use.