draw \- screen graphics
.BI /dev/draw/ n /data
.BI /dev/draw/ n /colormap
.BI /dev/draw/ n /refresh
ushort BGSHORT(uchar *p)
ulong BGLONG(uchar *p)
void BPSHORT(uchar *p, ushort v)
void BPLONG(uchar *p, ulong v)
device serves a three-level file system
providing an interface to the graphics facilities of the system.
Each client of the device connects by opening
and reading 12 strings, each 11 characters wide followed by a blank:
of the display image (always zero),
of the clipping rectangle.
The channel format string is described in
and the other fields are decimal numbers.
The client can then open the directory
files associated with the connection.
device provides access to
images and font caches
in its private storage,
Each image is identified by a 4-byte integer, its
file yields 12 strings formatted as in
but for the current image rather
than the display image.
The current image may be set by writing a
binary image id to the
A process can write messages to
to allocate and free images, fonts, and subfonts;
read or write portions of the images;
and draw line segments and character
strings in the images.
All graphics requests are clipped to their images.
Some messages return a response to be recovered by
The format of messages written to
followed by binary parameters;
multibyte integers are transmitted with the low order byte first.
macros place correctly formatted two- and four-byte integers into a character
retrieve values from a character buffer.
Points are two four-byte numbers:
Rectangles are four four-byte numbers: min
Images, screens, and fonts have 32-bit identifiers.
In the discussion of the protocol below,
the distinction between identifier and actual image, screen, or font
should be interpreted as
``the object with identifier
The definitions of constants used in the description below can be found in
The following requests are accepted by the
The numbers in brackets give the length in bytes of the parameters.
byte is non-zero, the screen can
be accessed from other processes
Allocate an image with a given
The image will have rectangle
and clipping rectangle
is non-zero, the image's replicate
specifies the method to be used to draw the window
when it is uncovered.
causes the server to maintain a backing store,
does not refresh the image,
causes a message to be sent via
The image format is described by
a binary version of the channel format string.
Specifically, the image format is the catenation of up to four
8-bit numbers, each describing a particular image channel.
Each of these 8-bit numbers contains a channel type in its
high nibble and a bit count in its low nibble.
The channel type is one of
is the catenation of four 8-bit numbers
specifying the red, green, blue, and alpha
channels of the color that the new image should
be initially filled with.
The red channel is in the highest 8 bits, and
the alpha in the lowest.
Note that color is always in this format, independent of
Change the replicate bit and clipping rectangle of the
This overrides whatever settings were specified in
the allocate message.
operator to combine the rectangle
using a rectangle of image
as an alpha mask to further control blending.
The three rectangles are congruent and aligned such that
the upper left corner
is non-zero, enable debugging output.
The meaning of ``debugging output'' is implementation dependent.
Draw an ellipse in image
centered on the point
with horizontal and vertical semiaxes
The ellipse is drawn using the image
The ellipse is drawn with thickness
only the arc of the ellipse from degree angles
For the purposes of drawing the arc,
is treated as a signed 31-bit number
by ignoring its high bit.
Draws an ellipse or arc as the
message, but rather than outlining it, fills
the corresponding sector using the image
field is ignored, but must be non-negative.
Free the resources associated with the image
Free the screen with the specified
Windows on the screen must be freed separately.
character cells, each with
Load a character into the font cache associated with image
The character data is drawn in rectangle
of the font cache image
the congruent rectangle in image
with upper left corner
specifies the width of the character\(emthe spacing from this character to the next\(emwhile
the horizontal distance from the left side
of the character to the left side of the cache image.
The dimensions of the image of the character are defined by
Draw a line of thickness
The line is drawn using the image
translated so that point
fields specify whether the corresponding
line end should be a square, a disc,
is non-zero, associate the image
already corresponds to the
the association is deleted.
Introduce the identifier
to correspond to the image named
so that its upper left corner is at the
Simultaneously change its internal (logical) coordinate system
corresponds to the upper left corner of the window.
Set the compositing operator to
for the next draw operation.
Draw a polygon of thickness
It is conceptually equivalent to a series of
line-drawing messages (see
joining adjacent points in the list of points
is translated so that the point
aligns with the first point
The polygon need not be closed:
specify the line endings for the first and
last point on the polygon.
All interior lines have rounded ends
to make smooth joins.
Draw a polygon as the
fill it rather than outlining it.
The winding rule parameter
resolves ambiguities about what to fill if the polygon is self-intersecting.
a pixel is inside the polygon if the polygon's winding number about the point
a pixel is inside if the winding number is odd.
Complementary values (0 or ~1) cause outside pixels to be filled.
The meaning of other values is undefined.
The polygon is closed with a line if necessary.
Cause the next read of the
file to return the image pixel data corresponding to the
the text string specified by the
starting with the upper left corner at point
The image drawn is taken from image
All drawing is confined to the clipping rectangle
Like the string drawing
command, but fill the background of each character
with pixels from image
is translated so that the point
Attach to the public screen with the specified
It is an error if the screen does not exist, is not public, or does not
have the channel descriptor
for its associated image.
windows to the top (if
is non-zero) or bottom (if
is zero) of the window stack.
The window is specified by the list of
are moved as a group, maintaining their own order within the stack.
Flush changes from a soft screen, if any, to the display buffer.
Replace the rectangle
with the pixel data in
The pixel data must be in the format dictated by
image channel descriptor (see
message uses uncompressed data,
message uses compressed data.
it is an error to include more data than necessary.
returns the system color map used on 8-bit displays.
Each color map entry consists of a single line containing
four space-separated decimal strings.
The first is an index into the map, and the remaining three are
the red, green, and blue values associated with that index.
The color map can be changed by writing entries in the
Note that changing the system color map
does not change the color map used for
images, which is immutable.
As windows owned by the client are uncovered,
if they cannot be refreshed by the server (such as when they have
refresh functions associated with them), a message is made available
file reporting what needs to be repainted by the client.
The message has five decimal integers formatted as in the
message: the image id of the window and the coordinates of the rectangle
that should be refreshed.
these can be detected by a system call error
of the data containing the erroneous message.
The most common error is a failure to allocate
because of insufficient free resources. Most other errors occur
only when the protocol is mishandled by the application.
refresh method is not fully implemented.
files only reference the system color map, and as
such should be called
.BI /dev/draw/ n /colormap\f1.