go: 9fans.net/go/draw Index | Files | Directories

package draw

import "9fans.net/go/draw"

Package draw is a port of Plan 9's libdraw to Go. It connects to the 'devdraw' binary built as part of Plan 9 from User Space (http://swtch.com/plan9port/). All graphics operations are done in the remote server. The functions in this package typically send a message to the server.

For background, see http://plan9.bell-labs.com/magic/man2html/2/graphics and associated pages for documentation. Not everything is implemented.

Notable Changes

The pixel descriptions like "r8g8b8" and their integer equivalents are referred to as chans in Plan 9. To avoid confusion, this package refers to them as type Pix.

Most top-level functions are methods on an appropriate type (Display, Image, Font).

Getwindow, called during resize, is now Display.Attach.

Index

Package Files

alloc.go allocimagemix.go border.go buildfont.go bytesperline.go cloadimage.go color.go computil.go creadimage.go cursor.go debug.go defont.go draw.go drawrepl.go egetrect.go ellipse.go emenuhit.go event.go font.go freesubfont.go getdefont.go getrect.go getsubfont.go icossin.go icossin2.go init.go keyboard.go line.go loadimage.go menuhit.go mkfont.go mouse.go openfont.go pix.go poly.go readimage.go readsubfont.go rectclip.go replclipr.go rgb.go scroll.go snarf.go string.go stringsubfont.go stringwidth.go subfont.go subfontcache.go subfontname.go unloadimage.go window.go writeimage.go writesubfont.go wsys.go

Constants

const (
    /* Porter-Duff compositing operators */
    Clear Op  = 0

    SinD  Op  = 8
    DinS  Op  = 4
    SoutD Op  = 2
    DoutS Op  = 1

    S      = SinD | SoutD
    SoverD = SinD | SoutD | DoutS
    SatopD = SinD | DoutS
    SxorD  = SoutD | DoutS

    D      = DinS | DoutS
    DoverS = DinS | DoutS | SoutD
    DatopS = DinS | SoutD
    DxorS  = DoutS | SoutD /* == SxorD */

    Ncomp = 12
)
const (
    Refbackup = 0
    Refnone   = 1
    Refmesg   = 2
)

Refresh algorithms to execute when a window is resized or uncovered. Refmesg is almost always the correct one to use.

const (
    KeyFn = '\uF000'

    KeyHome      = KeyFn | 0x0D
    KeyUp        = KeyFn | 0x0E
    KeyPageUp    = KeyFn | 0xF
    KeyPrint     = KeyFn | 0x10
    KeyLeft      = KeyFn | 0x11
    KeyRight     = KeyFn | 0x12
    KeyDown      = 0x80
    KeyView      = 0x80
    KeyPageDown  = KeyFn | 0x13
    KeyInsert    = KeyFn | 0x14
    KeyEnd       = KeyFn | 0x18
    KeyAlt       = KeyFn | 0x15
    KeyShift     = KeyFn | 0x16
    KeyCtl       = KeyFn | 0x17
    KeyBackspace = 0x08
    KeyDelete    = 0x7F
    KeyEscape    = 0x1b
    KeyEOF       = 0x04
    KeyCmd       = 0xF100
)
const (
    CRed = iota
    CGreen
    CBlue
    CGrey
    CAlpha
    CMap
    CIgnore
    NChan
)
const DefaultDPI = 133
const ICOSSCALE = 1024

Variables

var (
    Gray1Model  color.Model = color.ModelFunc(gray1Model)
    Gray2Model  color.Model = color.ModelFunc(gray2Model)
    Gray4Model  color.Model = color.ModelFunc(gray4Model)
    CMap8Model  color.Model = color.ModelFunc(cmapModel)
    CRGB15Model color.Model = color.ModelFunc(crgb15Model)
    CRGB16Model color.Model = color.ModelFunc(crgb16Model)
)
var (
    GREY1  Pix = MakePix(CGrey, 1)
    GREY2  Pix = MakePix(CGrey, 2)
    GREY4  Pix = MakePix(CGrey, 4)
    GREY8  Pix = MakePix(CGrey, 8)
    CMAP8  Pix = MakePix(CMap, 8)
    RGB15  Pix = MakePix(CIgnore, 1, CRed, 5, CGreen, 5, CBlue, 5)
    RGB16      = MakePix(CRed, 5, CGreen, 6, CBlue, 5)
    RGB24      = MakePix(CRed, 8, CGreen, 8, CBlue, 8)
    BGR24      = MakePix(CBlue, 8, CGreen, 8, CRed, 8)
    RGBA32     = MakePix(CRed, 8, CGreen, 8, CBlue, 8, CAlpha, 8)
    ARGB32     = MakePix(CAlpha, 8, CRed, 8, CGreen, 8, CBlue, 8) // stupid VGAs
    ABGR32     = MakePix(CAlpha, 8, CBlue, 8, CGreen, 8, CRed, 8)
    XRGB32     = MakePix(CIgnore, 8, CRed, 8, CGreen, 8, CBlue, 8)
    XBGR32     = MakePix(CIgnore, 8, CBlue, 8, CGreen, 8, CRed, 8)
)

func BytesPerLine Uses

func BytesPerLine(r image.Rectangle, depth int) int

BytesPerLine returns the number of 8-bit bytes touched by a scan line of the rectangle of specified depth.

func CombineRect Uses

func CombineRect(r1 *image.Rectangle, r2 image.Rectangle)

CombineRect overwrites *r1 with the smallest rectangle enclosing both *r1 and r2. CombineRect(r1, r2) differs from *r1 = r1.Union(r2) in its handling of zero-width or zero-height rectangles.

func GenDrawOp Uses

func GenDrawOp(dst *Image, r image.Rectangle, src *Image, p0 image.Point, mask *Image, p1 image.Point, op Op)

GenDrawOp copies the source image with upper left corner p1 to the destination rectangle r, through the specified mask using the specified operation. The coordinates are aligned so p1 in src and p0 in mask both correspond to r.min in the destination.

func IntCosSin Uses

func IntCosSin(deg int) (cos, sin int)

IntCosSin returns an approximation of the cosine and sine of the angle. The angle is in degrees and the result values are scaled up by 1024.

func IntCosSin2 Uses

func IntCosSin2(x, y int) (cos, sin int)

IntCosSin returns an approximation of the cosine and sine of the angle represented by (x, y). The result values are scaled up by 1024.

func RectClip Uses

func RectClip(rp *image.Rectangle, b image.Rectangle) bool

RectClip attempts to clip *rp to be within b. If any of *rp overlaps b, RectClip modifies *rp to denote the overlapping portion and returns true. Otherwise, when *rp and b do not overlap, RectClip leaves *rp unmodified and returns false.

func RectInRect Uses

func RectInRect(r, s image.Rectangle) bool

RectInRect reports whether r is entirely contained in s. RectInRect(r, s) differs from r.In(s) in its handling of zero-width or zero-height rectangles.

func RectXRect Uses

func RectXRect(r, s image.Rectangle) bool

RectXRect reports whether r and s cross, meaning they share any point or r is a zero-width or zero-height rectangle inside s. Note that the zero-sized cases make RectXRect(r, s) different from r.Overlaps(s).

func Repl Uses

func Repl(r image.Rectangle, p image.Point) image.Point

Repl return the point corresponding to the image of p that appears inside the base rectangle r, which represents a tiling of the plane.

func ReplXY Uses

func ReplXY(min, max, x int) int

ReplXY returns the position of x inside the interval (min, max). That is, assuming (min, max) specify the base of an infinite tiling of the integer line, return the value of the image of x that appears in the interval.

func WordsPerLine Uses

func WordsPerLine(r image.Rectangle, depth int) int

WordsPerLine returns the number of 32-bit words touched by a scan line of the rectangle of specified depth.

type CMap8 Uses

type CMap8 struct {
    I uint8
}

CMap8 represents an 8-bit color-mapped color with the standard Plan 9 color map.

func (CMap8) RGBA Uses

func (c CMap8) RGBA() (r, g, b, a uint32)

type CRGB15 Uses

type CRGB15 struct {
    // CIgnore, 1, CRed, 5, CGreen, 5, CBlue, 5
    V uint16
}

CRGB15 represents a 15-bit 5-5-5 RGB color.

func (CRGB15) RGBA Uses

func (c CRGB15) RGBA() (r, g, b, a uint32)

type CRGB16 Uses

type CRGB16 struct {
    // CRed, 5, CGreen, 6, CBlue, 5
    V uint16
}

CRGB16 represents a 16-bit 5-6-5 RGB color.

func (CRGB16) RGBA Uses

func (c CRGB16) RGBA() (r, g, b, a uint32)

type Color Uses

type Color uint32

A Color represents an RGBA value, 8 bits per element. Red is the high 8 bits, green the next 8 and so on.

const (
    Opaque        Color = 0xFFFFFFFF
    Transparent   Color = 0x00000000 /* only useful for allocimage memfillcolor */
    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

    Notacolor Color = 0xFFFFFF00
    Nofill    Color = Notacolor
)

type Cursor Uses

type Cursor struct {
    image.Point
    Clr [2 * 16]uint8
    Set [2 * 16]uint8
}

Cursor describes a single cursor.

type Display Uses

type Display struct {
    Image       *Image
    Screen      *Screen
    ScreenImage *Image
    Windows     *Image
    DPI         int

    White       *Image // Pre-allocated color.
    Black       *Image // Pre-allocated color.
    Opaque      *Image // Pre-allocated color.
    Transparent *Image // Pre-allocated color.

    DefaultFont    *Font
    DefaultSubfont *Subfont
    // contains filtered or unexported fields
}

A Display represents a connection to a display.

func Init Uses

func Init(errch chan<- error, fontname, label, winsize string) (*Display, error)

Init starts and connects to a server and returns a Display structure through which all graphics will be mediated. The arguments are an error channel on which to deliver errors (currently unused), the name of the font to use (the empty string may be used to represent the default font), the window label, and the window size as a string in the form XxY, as in "1000x500"; the units are pixels. TODO: Use the error channel.

func (*Display) AllocImage Uses

func (d *Display) AllocImage(r image.Rectangle, pix Pix, repl bool, val Color) (*Image, error)

AllocImage allocates a new Image on display d. The arguments are: - the rectangle representing the size - the pixel descriptor: RGBA32 etc. - whether the image is to be replicated (tiled) - the starting background color for the image

func (*Display) AllocImageMix Uses

func (d *Display) AllocImageMix(color1, color3 Color) *Image

AllocImageMix blends the two colors to create a tiled image representing their combination. For pixel formats of 8 bits or less, it creates a 2x2 pixel texture whose average value is the mix. Otherwise it creates a 1-pixel solid color blended using 50% alpha for each.

func (*Display) AllocSubfont Uses

func (d *Display) AllocSubfont(name string, height, ascent int, info []Fontchar, i *Image) *Subfont

AllocSubfont allocates a subfont on the server. The subfont will have the specified name, total height, ascent (height above the baseline), and character info.

func (*Display) Attach Uses

func (d *Display) Attach(ref int) error

Attach (re-)attaches to a display, typically after a resize, updating the display's associated image, screen, and screen image data structures.

func (*Display) BuildFont Uses

func (d *Display) BuildFont(buf []byte, name string) (*Font, error)

BuildFont builds a font of the given name using the description provided by the buffer, typically read from a font file.

func (*Display) Close Uses

func (d *Display) Close() error

Close closes the Display.

func (*Display) Flush Uses

func (d *Display) Flush() error

Flush flushes pending I/O to the server, making any drawing changes visible.

func (*Display) HiDPI Uses

func (d *Display) HiDPI() bool

func (*Display) InitKeyboard Uses

func (d *Display) InitKeyboard() *Keyboardctl

InitKeyboard connects to the keyboard and returns a Keyboardctl to listen to it.

func (*Display) InitMouse Uses

func (d *Display) InitMouse() *Mousectl

InitMouse connects to the mouse and returns a Mousectl to interact with it.

func (*Display) MoveTo Uses

func (d *Display) MoveTo(pt image.Point) error

MoveTo moves the mouse cursor to the specified location.

func (*Display) OpenFont Uses

func (d *Display) OpenFont(name string) (*Font, error)

OpenFont reads the named file and returns the font it defines. The name may be an absolute path, or identify a file in a standard font directory: /lib/font/bit, /usr/local/plan9, /mnt/font, etc.

func (*Display) ReadImage Uses

func (d *Display) ReadImage(r io.Reader) (*Image, error)

ReadImage reads the image data from the reader and returns the image it describes.

func (*Display) ReadSnarf Uses

func (d *Display) ReadSnarf(buf []byte) (int, int, error)

ReadSnarf reads the snarf buffer into buf, returning the number of bytes read, the total size of the snarf buffer (useful if buf is too short), and any error. No error is returned if there is no problem except for buf being too short.

func (*Display) ReadSubfont Uses

func (d *Display) ReadSubfont(name string, r io.Reader) (*Subfont, error)

ReadSubfont reads the subfont data from the reader and returns the subfont it describes, giving it the specified name.

func (*Display) Scale Uses

func (d *Display) Scale(n int) int

TODO: Document.

func (*Display) ScaleSize Uses

func (d *Display) ScaleSize(n int) int

func (*Display) SetCursor Uses

func (d *Display) SetCursor(c *Cursor) error

SetCursor sets the mouse cursor to the specified cursor image. SetCursor(nil) changes the cursor to the standard system cursor.

func (*Display) SetDebug Uses

func (d *Display) SetDebug(debug bool)

SetDebug enables debugging for the remote devdraw server.

func (*Display) WriteSnarf Uses

func (d *Display) WriteSnarf(data []byte) error

WriteSnarf writes the data to the snarf buffer.

type Font Uses

type Font struct {
    Display *Display
    Name    string // name, typically from file.
    Height  int    // max height of image, interline spacing
    Ascent  int    // top of image to baseline
    Scale   int    // pixel scaling
    // contains filtered or unexported fields
}

A Font represents a font that may be used to draw on the display. A Font is constructed by reading a font file that describes how to create a full font from a collection of subfonts, each of which covers a section of the Unicode code space.

func (*Font) BytesSize Uses

func (f *Font) BytesSize(b []byte) image.Point

ByteSize returns the number of horizontal and vertical pixels that would be occupied by the byte slice if it were drawn using the font.

func (*Font) BytesWidth Uses

func (f *Font) BytesWidth(b []byte) int

ByteWidth returns the number of horizontal pixels that would be occupied by the byte slice if it were drawn using the font.

func (*Font) Free Uses

func (f *Font) Free()

/ Free frees the server resources for the Font. Fonts have a finalizer that calls Free automatically, if necessary, for garbage collected Images, but it is more efficient to be explicit. TODO: Implement the Finalizer!

func (*Font) RunesSize Uses

func (f *Font) RunesSize(r []rune) image.Point

RuneSize returns the number of horizontal and vertical pixels that would be occupied by the rune slice if it were drawn using the font.

func (*Font) RunesWidth Uses

func (f *Font) RunesWidth(r []rune) int

RuneWidth returns the number of horizontal pixels that would be occupied by the rune slice if it were drawn using the font.

func (*Font) StringSize Uses

func (f *Font) StringSize(s string) image.Point

StringSize returns the number of horizontal and vertical pixels that would be occupied by the string if it were drawn using the font.

func (*Font) StringWidth Uses

func (f *Font) StringWidth(s string) int

StringWidth returns the number of horizontal pixels that would be occupied by the string if it were drawn using the font.

type Fontchar Uses

type Fontchar struct {
    X      int   // x position in the image holding the glyphs.
    Top    uint8 // first non-zero scan line.
    Bottom uint8 // last non-zero scan line.
    Left   int8  // offset of baseline.
    Width  uint8 // width of baseline.
}

A Fontchar descibes one character glyph in a font (really a subfont).

type Gray1 Uses

type Gray1 struct {
    White bool
}

Gray1 represents a 1-bit black/white color.

func (Gray1) RGBA Uses

func (c Gray1) RGBA() (r, g, b, a uint32)

type Gray2 Uses

type Gray2 struct {
    Y uint8
}

Gray2 represents a 2-bit grayscale color.

func (Gray2) RGBA Uses

func (c Gray2) RGBA() (r, g, b, a uint32)

type Gray4 Uses

type Gray4 struct {
    Y uint8
}

Gray4 represents a 4-bit grayscale color.

func (Gray4) RGBA Uses

func (c Gray4) RGBA() (r, g, b, a uint32)

type Image Uses

type Image struct {
    Display *Display

    Pix   Pix             // The pixel format for the image.
    Depth int             // The depth of the pixels in bits.
    Repl  bool            // Whether the image is replicated (tiles the rectangle).
    R     image.Rectangle // The extent of the image.
    Clipr image.Rectangle // The clip region.

    Screen *Screen // If non-nil, the associated screen; this is a window.
    // contains filtered or unexported fields
}

An Image represents an image on the server, possibly visible on the display.

func (*Image) AllocScreen Uses

func (i *Image) AllocScreen(fill *Image, public bool) (*Screen, error)

func (*Image) Arc Uses

func (dst *Image) Arc(c image.Point, a, b, thick int, src *Image, sp image.Point, alpha, phi int)

Arc draws, using SoverD, the arc centered at c, with thickness 1+2*thick, using the specified source color. The arc starts at angle alpha and extends counterclockwise by phi; angles are measured in degrees from the x axis.

func (*Image) ArcOp Uses

func (dst *Image) ArcOp(c image.Point, a, b, thick int, src *Image, sp image.Point, alpha, phi int, op Op)

ArcOp draws the arc centered at c, with thickness 1+2*thick, using the specified source color. The arc starts at angle alpha and extends counterclockwise by phi; angles are measured in degrees from the x axis.

func (*Image) At Uses

func (i *Image) At(x, y int) color.Color

At returns the standard Color value for the pixel at (x, y). If the location is outside the clipping rectangle, it returns color.Transparent. This operation does a round trip to the image server and can be expensive.

func (*Image) Border Uses

func (dst *Image) Border(r image.Rectangle, n int, color *Image, sp image.Point)

Border draws a retangular border of size r and width n, with n positive meaning the border is inside r. It uses SoverD.

func (*Image) BorderOp Uses

func (dst *Image) BorderOp(r image.Rectangle, n int, color *Image, sp image.Point, op Op)

BorderOp draws a retangular border of size r and width n, with n positive meaning the border is inside r, drawn with the specified draw op.

func (*Image) Bounds Uses

func (i *Image) Bounds() image.Rectangle

func (*Image) Bytes Uses

func (dst *Image) Bytes(pt image.Point, src *Image, sp image.Point, f *Font, b []byte) image.Point

Bytes draws the byte slice in the specified font, placing the upper left corner at p. It draws the text using src, with sp aligned to pt, using operation SoverD onto dst.

func (*Image) BytesBg Uses

func (dst *Image) BytesBg(pt image.Point, src *Image, sp image.Point, f *Font, b []byte, bg *Image, bgp image.Point) image.Point

BytesBg draws the rune slice in the specified font, placing the upper left corner at p. It first draws the background bg, with bgp aligned to pt, using operation SoverD onto dst. It then draws the text using src, with sp aligned to pt, using operation SoverD onto dst.

func (*Image) BytesBgOp Uses

func (dst *Image) BytesBgOp(pt image.Point, src *Image, sp image.Point, f *Font, b []byte, bg *Image, bgp image.Point, op Op) image.Point

BytesBgOp draws the rune slice in the specified font, placing the upper left corner at p. It first draws the background bg, with bgp aligned to pt, using operation SoverD onto dst. It then draws the text using src, with sp aligned to pt, using operation SoverD onto dst.

func (*Image) BytesOp Uses

func (dst *Image) BytesOp(pt image.Point, src *Image, sp image.Point, f *Font, b []byte, op Op) image.Point

BytesOp draws the byte slice in the specified font, placing the upper left corner at p. It draws the text using src, with sp aligned to pt, using the specified operation onto dst.

func (*Image) Cload Uses

func (dst *Image) Cload(r image.Rectangle, data []byte) (int, error)

Cload is like Load, but uses image-compressed data.

func (*Image) ColorModel Uses

func (i *Image) ColorModel() color.Model

ColorModel returns the standard color model of the Image.

func (*Image) Draw Uses

func (dst *Image) Draw(r image.Rectangle, src, mask *Image, p1 image.Point)

Draw copies the source image with upper left corner p1 to the destination rectangle r, through the specified mask using operation SoverD. The coordinates are aligned so p1 in src and mask both correspond to r.min in the destination.

func (*Image) DrawOp Uses

func (dst *Image) DrawOp(r image.Rectangle, src, mask *Image, p1 image.Point, op Op)

DrawOp copies the source image with upper left corner p1 to the destination rectangle r, through the specified mask using the specified operation. The coordinates are aligned so p1 in src and mask both correspond to r.min in the destination.

func (*Image) Ellipse Uses

func (dst *Image) Ellipse(c image.Point, a, b, thick int, src *Image, sp image.Point)

Ellipse draws, using SoverD, an ellipse with center c and horizontal and vertical semiaxes a and b, and thickness 1+2*thick. The source is aligned so sp corresponds to c.

func (*Image) EllipseOp Uses

func (dst *Image) EllipseOp(c image.Point, a, b, thick int, src *Image, sp image.Point, op Op)

EllipseOp draws an ellipse with center c and horizontal and vertical semiaxes a and b, and thickness 1+2*thick. The source is aligned so sp corresponds to c.

func (*Image) FillArc Uses

func (dst *Image) FillArc(c image.Point, a, b, thick int, src *Image, sp image.Point, alpha, phi int)

FillArc draws and fills, using SoverD, the arc centered at c, with thickness 1+2*thick, using the specified source color. The arc starts at angle alpha and extends counterclockwise by phi; angles are measured in degrees from the x axis.

func (*Image) FillArcOp Uses

func (dst *Image) FillArcOp(c image.Point, a, b, thick int, src *Image, sp image.Point, alpha, phi int, op Op)

FillArcOp draws and fills the arc centered at c, with thickness 1+2*thick, using the specified source color. The arc starts at angle alpha and extends counterclockwise by phi; angles are measured in degrees from the x axis.

func (*Image) FillEllipse Uses

func (dst *Image) FillEllipse(c image.Point, a, b, thick int, src *Image, sp image.Point)

FillEllipse draws and fills, using SoverD, an ellipse with center c and horizontal and vertical semiaxes a and b, and thickness 1+2*thick. The source is aligned so sp corresponds to c.

func (*Image) FillEllipseOp Uses

func (dst *Image) FillEllipseOp(c image.Point, a, b, thick int, src *Image, sp image.Point, op Op)

FillEllipseOp draws and fills ellipse with center c and horizontal and vertical semiaxes a and b, and thickness 1+2*thick. The source is aligned so sp corresponds to c.

func (*Image) FillPoly Uses

func (dst *Image) FillPoly(p []image.Point, end0, end1, radius int, src *Image, sp image.Point)

FillPoly fills the polygon p (which it closes if necessary) in the specified source color. The images are aligned so sp aligns with p[0]. The polygon is drawn using SoverD. The winding parameter resolves ambiguities; see the Plan 9 manual for details.

func (*Image) FillPolyOp Uses

func (dst *Image) FillPolyOp(p []image.Point, end0, end1, radius int, src *Image, sp image.Point, op Op)

FillPolyOp fills the polygon p (which it closesif necessary) in the specified source color. The images are aligned so sp aligns with p[0]. The winding parameter resolves ambiguities; see the Plan 9 manual for details.

func (*Image) Free Uses

func (i *Image) Free() error

Free frees the server resources for the image. Images have a finalizer that calls Free automatically, if necessary, for garbage collected Images, but it is more efficient to be explicit.

func (*Image) GenDraw Uses

func (dst *Image) GenDraw(r image.Rectangle, src *Image, p0 image.Point, mask *Image, p1 image.Point)

GenDraw copies the source image with upper left corner p1 to the destination rectangle r, through the specified mask using operation SoverD. The coordinates are aligned so p1 in src and p0 in mask both correspond to r.min in the destination.

func (*Image) Line Uses

func (dst *Image) Line(p0, p1 image.Point, end0, end1, radius int, src *Image, sp image.Point)

Line draws a line in the source color from p0 to p1, of thickness 1+2*radius, with the specified ends, using SoverD. The source is aligned so sp corresponds to p0. See the Plan 9 documentation for more information.

func (*Image) LineOp Uses

func (dst *Image) LineOp(p0, p1 image.Point, end0, end1, radius int, src *Image, sp image.Point, op Op)

LineOp draws a line in the source color from p0 to p1, of thickness 1+2*radius, with the specified ends. The source is aligned so sp corresponds to p0. See the Plan 9 documentation for more information.

func (*Image) Load Uses

func (dst *Image) Load(r image.Rectangle, data []byte) (int, error)

Load copies the pixel data from the buffer to the specified rectangle of the image. The buffer must be big enough to fill the rectangle.

func (*Image) Poly Uses

func (dst *Image) Poly(p []image.Point, end0, end1, radius int, src *Image, sp image.Point)

Poly draws the open polygon p in the specified source color, with ends as specified. The images are aligned so sp aligns with p[0]. The polygon is drawn using SoverD.

func (*Image) PolyOp Uses

func (dst *Image) PolyOp(p []image.Point, end0, end1, radius int, src *Image, sp image.Point, op Op)

PolyOp draws the open polygon p in the specified source color, with ends as specified. The images are aligned so sp aligns with p[0].

func (*Image) ReplClipr Uses

func (dst *Image) ReplClipr(repl bool, clipr image.Rectangle)

ReplClipr sets the replication boolean and clip rectangle for the specified image.

func (*Image) Runes Uses

func (dst *Image) Runes(pt image.Point, src *Image, sp image.Point, f *Font, r []rune) image.Point

Runes draws the rune slice in the specified font, placing the upper left corner at p. It draws the text using src, with sp aligned to pt, using operation SoverD onto dst.

func (*Image) RunesBg Uses

func (dst *Image) RunesBg(pt image.Point, src *Image, sp image.Point, f *Font, r []rune, bg *Image, bgp image.Point) image.Point

RunesBg draws the rune slice in the specified font, placing the upper left corner at p. It first draws the background bg, with bgp aligned to pt, using operation SoverD onto dst. It then draws the text using src, with sp aligned to pt, using operation SoverD onto dst.

func (*Image) RunesBgOp Uses

func (dst *Image) RunesBgOp(pt image.Point, src *Image, sp image.Point, f *Font, r []rune, bg *Image, bgp image.Point, op Op) image.Point

RunesBgOp draws the rune slice in the specified font, placing the upper left corner at p. It first draws the background bg, with bgp aligned to pt, using operation SoverD onto dst. It then draws the text using src, with sp aligned to pt, using operation SoverD onto dst.

func (*Image) RunesOp Uses

func (dst *Image) RunesOp(pt image.Point, src *Image, sp image.Point, f *Font, r []rune, op Op) image.Point

RunesOp draws the rune slice in the specified font, placing the upper left corner at p. It draws the text using src, with sp aligned to pt, using the specified operation onto dst.

func (*Image) String Uses

func (dst *Image) String(pt image.Point, src *Image, sp image.Point, f *Font, s string) image.Point

String draws the string in the specified font, placing the upper left corner at p. It draws the text using src, with sp aligned to pt, using operation SoverD onto dst.

func (*Image) StringBg Uses

func (dst *Image) StringBg(pt image.Point, src *Image, sp image.Point, f *Font, s string, bg *Image, bgp image.Point) image.Point

StringBg draws the string in the specified font, placing the upper left corner at p. It first draws the background bg, with bgp aligned to pt, using operation SoverD onto dst. It then draws the text using src, with sp aligned to pt, using operation SoverD onto dst.

func (*Image) StringBgOp Uses

func (dst *Image) StringBgOp(pt image.Point, src *Image, sp image.Point, f *Font, s string, bg *Image, bgp image.Point, op Op) image.Point

StringBgOp draws the string in the specified font, placing the upper left corner at p. It first draws the background bg, with bgp aligned to pt, using operation SoverD onto dst. It then draws the text using src, with sp aligned to pt, using operation SoverD onto dst.

func (*Image) StringOp Uses

func (dst *Image) StringOp(pt image.Point, src *Image, sp image.Point, f *Font, s string, op Op) image.Point

StringOp draws the string in the specified font, placing the upper left corner at p. It draws the text using src, with sp aligned to pt, using the specified operation onto dst.

func (*Image) Unload Uses

func (src *Image) Unload(r image.Rectangle, data []byte) (n int, err error)

Unload copies the pixel data from the specified rectangle of the image into the buffer, which must be big enough to hold the result.

type Keyboardctl Uses

type Keyboardctl struct {
    C <-chan rune // Channel on which keyboard characters are delivered.
}

Keyboardctl is the source of keyboard events.

type Mouse Uses

type Mouse struct {
    image.Point        // Location.
    Buttons     int    // Buttons; bit 0 is button 1, bit 1 is button 2, etc.
    Msec        uint32 // Time stamp in milliseconds.
}

Mouse is the structure describing the current state of the mouse.

type Mousectl Uses

type Mousectl struct {
    Mouse                // Store Mouse events here.
    C       <-chan Mouse // Channel of Mouse events.
    Resize  <-chan bool  // Each received value signals a window resize (see the display.Attach method).
    Display *Display     // The associated display.
}

Mousectl holds the interface to receive mouse events. The Mousectl's Mouse is updated after send so it doesn't have the wrong value if the sending goroutine blocks during send. This means that programs should receive into Mousectl.Mouse

if they want full synchrony.

func (*Mousectl) Read Uses

func (mc *Mousectl) Read() Mouse

Read returns the next mouse event.

type Op Uses

type Op int

Op represents a Porter-Duff compositing operator.

type Pix Uses

type Pix uint32

Pix represents a pixel format described simple notation: r8g8b8 for RGB24, m8 for color-mapped 8 bits, etc. The representation is 8 bits per channel, starting at the low end, with each byte represnted as a channel specifier (CRed etc.) in the high 4 bits and the number of pixels in the low 4 bits.

func MakePix Uses

func MakePix(list ...int) Pix

MakePix returns a Pix by placing the successive integers into 4-bit nibbles, low bits first.

func ParsePix Uses

func ParsePix(s string) (Pix, error)

ParsePix is the reverse of String, turning a pixel string such as "r8g8b8" into a Pix value.

func (Pix) Depth Uses

func (p Pix) Depth() int

func (Pix) String Uses

func (p Pix) String() string

String prints the pixel format as a string: "r8g8b8" for example.

type Screen Uses

type Screen struct {
    Display *Display // Display connected to the server.

    Fill *Image // Background image behind the windows.
    // contains filtered or unexported fields
}

A Screen is a collection of windows that are visible on an image.

func (*Screen) Free Uses

func (s *Screen) Free() error

Free frees the server resources associated with the screen.

type Subfont Uses

type Subfont struct {
    Name   string     // Name of the subfont, typically the file from which it was read.
    N      int        // Number of characters in the subfont.
    Height int        // Inter-line spacing.
    Ascent int        // Height above the baseline.
    Info   []Fontchar // Character descriptions.
    Bits   *Image     // Image holding the glyphs.
    // contains filtered or unexported fields
}

A Subfont represents a subfont, mapping a section of the Unicode code space to a set of glyphs.

func (*Subfont) Free Uses

func (f *Subfont) Free()

Free frees the server resources for the Subfont. Subfonts have a finalizer that calls Free automatically, if necessary, for garbage collected Images, but it is more efficient to be explicit. TODO: Implement the finalizer!

func (*Subfont) MakeFont Uses

func (subfont *Subfont) MakeFont(min rune) *Font

MakeFont creates a Font from an existing subfont. The first character of the subfont will be rendered with rune value min.

Directories

PathSynopsis
drawfcall

Package draw imports 17 packages (graph) and is imported by 16 packages. Updated 2018-06-05. Refresh now. Tools for package owners.