|
The Glyph()is a container
for color images, whose intended purpose is to act as color icons that can be drawn into display
contexts such as the Requester redraw, ctlinfo() and ctlviewport().
Glyphs can be constructed from a disc file by providing the filename as argument to the Glyph
constructor. Alternately, the name of an embedded binary block can also be specified as the
source of the image data:
...
cursor_img = Glyph(cursorGlyph);
...
@data cursorGlyph 500
000 000 002 000 000 000 000 000 000 000 000 000 012 000 012 000 024 000 080 080
...
A 'nil' is returned if the glyph construction fails for some reason.
The Glyph Object Agent currently exports no public methods. The following public data members
are available:
w the width of the glyph image (read-only)
h the height of the glyph image (read-only)
pixel[col,row] array of pixel color data for the glyph image
(write-only in default mode, read-write in dual-mode)
Once constructed, the glyph can be drawn into display contexts using the new drawglyph()
function. This function takes the Glyph Object Agent, along with the X and Y position
within the context where the glyph should be drawn:
...
// draw the cursor glyph
drawglyph(cursor_img,
cursor_pos.x - integer(cursor_img.w / 2),
cursor_pos.y - integer(cursor_img.h / 2));
...
Two additional arguments, both optional, can be provided to the Glyph() constructor. By default,
Glyphs are generated in a way that allows them to be drawn to the display context with the
utmost speed. What is traded for such drawing speed is the ability to directly access individual
pixels in the image. The second argument you can provide to the Glyph() constructor is a
Boolean flag that tells LScript that you'll need pixel-based access to the image data in the
Glyph (dual-mode). You'll need to specify this mode, for instance, when you plan to overlay the
Glyph onto Image Filter data (Image Filter data is not a valid display context, so the high-speed
form of the Glyph cannot be directly drawn onto it).
The third optional argument is a transparency color mask to be used when drawing the Glyph.
Because the use of such a mask requires per-pixel access to the image data, specifying a
transparency mask automatically enables this mode in the Glyph object.
Because Glyph image data can be of any type supported by any Image Loader plug-in active in
the host application (see notes regarding this in the Behavioral Changes section), you may
need to specify a file-type hint when you embed the image data into your script via a binary
block. By default, LScript will append the extension ".tga" to image data in a binary block
before attempting to process it. Sometimes this will work with non-Targa image data, and
sometimes it won't. Your file-type hint should take the form of the appropriate file
extension, and be appended to the name of the binary block, separated by an underscore
character.
@data cursorGlyph_jpg 500
000 000 002 000 000 000 000 000 000 000 000 000 012 000 012 000 024 000 080 080
080 080 080 080 080 080 080 080 080 080 080 080 080 080 080 080 080 080 080 080
...
085 069 086 073 083 073 079 078 045 088 070 073 076 069 046 000
@end
|