Charles.Forsyth20060303-partialeea662d19 years agoHistory
389 lines · 9.5 KB · Text
RawDownload
.TH DRAW-DISPLAY 2.SH NAMEDisplay \-connection to draw device.SH SYNOPSIS.EXinclude	"draw.m";draw := load Draw Draw->PATH; Display: adt{    image:       ref Image;    white:       ref Image;    black:       ref Image;    opaque:      ref Image;    transparent: ref Image;     allocate:    fn(dev: string): ref Display;    startrefresh:fn(d: self ref Display);    publicscreen:fn(d: self ref Display, id: int):                 ref Screen;    newimage:    fn(d: self ref Display,                 r: Rect, chans: Chans,                 repl, rgba: int):                 ref Image;    color:       fn(d: self ref Display, rgba: int):                 ref Image;    colormix:    fn(d: self ref Display, one: int, three: int):                 ref Image;    rgb:         fn(d: self ref Display, red, green, blue: int):                 ref Image;    namedimage:  fn(d: self ref Display, name: string):                 ref Image;    open:        fn(d: self ref Display, name: string):                 ref Image;    readimage:   fn(d: self ref Display, fd: ref Sys->FD):                 ref Image;    writeimage:  fn(d: self ref Display, fd: ref Sys->FD,                 i: ref Image): int;    rgb2cmap:    fn(d: self ref Display, red, green, blue: int):                 int;    cmap2rgb:    fn(d: self ref Display, c: int):                 (int, int, int);    cmap2rgba:   fn(d: self ref Display, c: int):                 int;}; Chans: adt{   mk:    fn(s: string): Chans;   text:  fn(c: self Chans): string;   eq:    fn(c: self Chans, d: Chans): int;   depth: fn(c: self Chans): int;};.EE.SH DESCRIPTIONThe.B Displaytype represents a connection to a.IR draw (3)device.This device is the external representation of a physicaldisplay, such as a CRT, and its associated memory.It contains the storage for all images,even invisible ones, so all.B Imageobjects must be allocatedthrough.B Displaymember functions.Graphics operations that use multiple.B Imageobjects may not mix images from different.BR Displays ..PPThe pixel channel structure of an.B Imageis determined when the image is allocated (including the image allocated by the systemto represent a physical display).This structure is described externally by a channel format string,described in.IR colour (6),and internally by a value of the.B Chansadt,which is used when allocating new images in the calls below..B Drawdefines a set of constants of type.B Chansfor common channel types:.BR GREY1 ,.BR GREY2and.BR GREY8for greyscale (depths 1, 2 and 8);.BR CMAP8for 8-bit.IR rgbv (8)colour-mapped images;.BR RGB16for 16-bit.B r5g6b5colour images;.BR RGB24for 24-bit colour;and.BR RGBA32for 24-bit colour with alpha channel..B Chanshas the following operations:.TP 10.BI Chans.mk( s )Return the.B Chansvalue corresponding to the channel format string.I s(see.IR image (6)for the syntax of.IR s )..TP 10.IB c .depth()Return the depth in bits of.IR c .The result is 0 if.I cis invalid; in particular,.BI Chans.mk( s ).depth()is zero if.I sis invalid..TP.IB c .text()Return the format string corresponding to.IR c ..TP.IB c .eq( d )Return true if.I dhas the same channel structure as.IR c ;return false otherwise..PPColours in the calls below are specified as 32-bit integers (`32-bit RGBA format') containingred, green, blue and alpha components as 8-bit values, in orderfrom most to least significant byte.The 8-bit colour component values express illumination, ranging from 0 (no colour)to 255 (saturated).For the alpha component, 0 is fully transparent, and 255 is fully opaque..PP.B Displayitself has the following components:.PP.TP 10.B imageThe visible contents of the display;draw on.B imageto change the display..TP.BR white ", " blackReplicated images of a single pixel,either all ones (white) or all zeroes (black)..TP.BR opaque ", " transparentReplicated images of a single pixel,either all ones (fully opaque) or all zeroes (fully transparent).Used as mattes forbasic graphical operations..TP.BI allocate( dev )Attach to a new display, represented by the.IR draw (3)device mounted in the specified.I devdirectory.If.I devis the empty string,.B /devis used.The return value is.B nilif the allocation fails..TP.IB d .startrefresh()After allocating a.B Displayobject, the application should spawn a process to call.BR startrefresh ;this thread will receive and process window refresh eventsfrom the device..TP.IB d .publicscreen( id )Create a locally addressable pointer to a public.BR Screen ;see \f2display-screen\fP(2)..TP.IB d .newimage( r\fP,\fP\ chans\fP,\fP\ repl\fP,\fP\ rgba )Allocate an off-screen.BR Image .The arguments supply values for the.BR Image 's.BR r ,.BR chans ,and.BR repl ,and an initial pixel value.I rgbain 32-bit RGBA format,used to paint the imagewhen created.It can be.B Draw\->Transparentto create a fully transparent image to draw on to form anarbitrarily-shaped image or matte.If it is.BR Draw\->Nofill ,the image is not initialised.The image's.B clipris initialized to.BR r ..TP.IB d .color( rgba )Creates a single-pixel,replicated off-screen image of the specified colour,expressed in 32-bit RGBA format.The.B Drawmodule defines constants for several dozen colours:.RS.IP.EXOpaque:         con int 16rFFFFFFFF;Transparent:    con int 16r00000000;Black:          con int 16r000000FF;White:          con int 16rFFFFFFFF;Red:            con int 16rFF0000FF;Green:          con int 16r00FF00FF;Blue:           con int 16r0000FFFF;Cyan:           con int 16r00FFFFFF;Magenta:        con int 16rFF00FFFF;Yellow:         con int 16rFFFF00FF;Grey:           con int 16rEEEEEEFF;Paleyellow:     con int 16rFFFFAAFF;Darkyellow:     con int 16rEEEE9EFF;Darkgreen:      con int 16r448844FF;Palegreen:      con int 16rAAFFAAFF;Medgreen:       con int 16r88CC88FF;Darkblue:       con int 16r000055FF;Palebluegreen:  con int 16rAAFFFFFF;Paleblue:       con int 16r0000BBFF;Bluegreen:      con int 16r008888FF;Greygreen:      con int 16r55AAAAFF;Palegreygreen:  con int 16r9EEEEEFF;Yellowgreen:    con int 16r99994CFF;Medblue:        con int 16r000099FF;Greyblue:       con int 16r005DBBFF;Palegreyblue:   con int 16r4993DDFF;Purpleblue:     con int 16r8888CCFF;Notacolor:      con int 16rFFFFFF00;Nofill:         con Notacolor;.EE.PPThe special values.BR Draw\->Opaque(fully opaque)and.BR Draw\->Transparent(fully transparent)are useful as the pixel values for.B Display.newimagewhen forming a matte.The special value.B Draw\->Nofilltells.B Display.newimagenot to paint a new image with any colour, leaving it uninitialised..RE.TP.IB d .colormix( one\fP,\fP\ three )Allocate background colours.On true color displays, it returns a 1×1 replicated image whose pixel is the result of mixing the twocolours in a one to three ratio;both colours are expressed in 32-bit RGBA format.On 8-bit color-mapped displays, it returns a 2×2 replicated imagewith one pixel coloured.I oneand the other threewith.I three(after translation through the colour map).This simulates a wider range of tones than canbe represented by a single pixel value on a colour-mapped display..TP.IB d .rgb( red\fP,\fP\ green\fP,\fP\ blue )Uses the values of red, green, and blue to createa single-pixel replicated image of that colour.The values are intensities that range from 0 (no colour) to 255 (saturated).The alpha component is always 255 (fully opaque)..TP.IB d .namedimage ( name )Returns a reference to the image published as.I nameon display.I dby.B Image.nameimage(see.IR draw-image (2)).This allows unrelated processes to share the image (eg, a window manager and client)..TP.IB d .open( name )Read an imagedescription from the namedfile and return an.B Imageholding the picture.See.IR image (6)for more information about image files..TP.IB d .readimage( fd )Analogous to.BR open ,but from an open file descriptor rather than a named file..TP.IB d .writeimage( fd\fP,\fP\ i )Complement of.BR readimage :write an image file representing.B ito the open file descriptor..TP.IB d .rgb2cmap( red\fP,\fP\ green\fP,\fP\ blue )Return the.I rgbvcolour map index (see.IR colour (6))of the colour that best matchesthe given colour triple.  The values of the components range from0 (no colour) to 255 (saturated)..TP.IB d .cmap2rgb( c )Return the colour triple (red, blue, green) corresponding to colourmap index.IR c ..TP.IB d .cmap2rgba( c )Return the 32-bit RGBA representation of the colour corresponding to colourmap index.IR c .The alpha component is always 255 (fully opaque)..ig.TP.IB d .cursor(\fIi\fP,\ \fIp\fP)Set the current cursor.If.I iis the image of the current display,then the graphics cursor will be setto its default value, otherwise.I imust be an image with ldepth 0and the following rules apply: the size of thecursor will be half the horizontal height of.I i(subject to system-dependent restrictions on cursorsize). The top half and the bottom half of the imageare treated as two independent masks. When thecursor is drawn, pixels congruent with non-zero bitsin the top half are clearedand then pixels congruent with non-zero bits in thebottom half are set..I Pgives the offset added to the mouse position when drawingthe cursor image..TP.IB d .cursorset(\fIp\fP)Set the position of the mouse cursor to.IR p ..SH BUGSThe interface to.B cursordoes not allow the use of colour mouse cursors,even on systems that allow them. The interface is likelyto change in this respect...