include "draw.m"; draw := load Draw Draw->PATH; setalpha: fn(rgba: int, alpha: int): int;
When an image is displayed, the value of each pixel determines the colour of the display, according to the interpretation of the image's channels. For instance, on `true colour' displays, the display image might contain red, blue and green colour channels, and each pixel value will have red, blue and green colour components. For displays with only 8 bits per pixel or less, Inferno uses a fixed colour map for each display depth (see colour(6)). Facilities exist in draw-display(2) to convert between (red, green, blue) triplets and colour-mapped pixel values, but the mapping is often done automatically by the graphics operations when images with different channel structures are combined.
Draw uses a standard representation of colour constants in calls to create coloured images or to initialise new images with a given colour. This is referred to as `32-bit RGBA format'. Each constant colour is represented as a 32-bit integer, with 8-bit red, blue and green colour components, and an 8-bit alpha component, in that order from most to least significant byte.
The RGB values in a colour are premultiplied by the alpha value; for example, a 50% red is int 16r7F00007F not int 16rFF00007F. The function Draw->setalpha performs the alpha computation on a given colour rgba in 32-bit RGBA format, ignoring its initial alpha value, and returning the result of multiplying each colour component by the supplied alpha. For example, to make a 50% red color value, one could execute draw->setalpha(Draw->Red, 16r7F).
The pixel structure of an Image is stored as Chans value Image.chans; the image's pixel depth in bits is stored as integer Image.depth.
An image may be marked for replication: when set, the boolean Image.repl causes the image to behave as if replicated across the entire integer plane, thus tiling the destination graphics area with copies of the source image. When replication is turned on, the clipping rectangle limits the extent of the replication and may even usefully be disjoint from Image.r. See draw-image(2) for examples.
The Image member functions provide facilities for drawing text and geometric objects, manipulating windows, and so on.
Objects of type Display, Font, Screen, and Image must be allocated by the member functions; if such objects are created with a regular Limbo definition, they will not behave properly and may generate run-time errors.
There are no ``free'' routines for graphics objects. Instead Limbo's garbage collection frees them automatically. As is generally so within Limbo, one can eliminate references by assigning nil to reference variables, returning from functions whose local variables hold references, etc.
|DRAW-INTRO(2 )||Rev: Thu Feb 15 14:43:26 GMT 2007|