Header | {z88dk}/include/graphics.h |
---|---|
Source | {z88dk}/libsrc/graphics |
Include | #include <graphics.h> |
Linking | n/a |
Compile | n/a |
Comments | These library functions implement various monochrome graphics functions thought to be easily portable. |
These APIs (along with the monochrome sprites ones) have been developed for as many target platforms as possible to permit the portability of simple graphical applications. For this reason no color extensions are implemented. The developer wishing to create portable applications has to keep in mind the differences between the various screen resolutions.
The most common ones are:
256×192
256×64
128×64
96×64 (considering that some text-only target system can provide a pesudo-graphics resolution of 80×72 those could converge on a minimal of 78×64 to cover as much platform as possible).
A wider resolution is supported too but at the moment not all the functionalities are covered.
Plot a pixel to screen
Reset a pixel on the screen
Invert a pixel on the screen
Get the status of a pixel (this function might not work correctly on all the platforms)
Get horizontal or vertical pixel bar, up to 16 pixel long, for a quick pattern recognition in graphics applications or games. (this function might not work correctly on all the platforms)
Draw a line, given absolute coordinates
Draw a line in XOR mode, given absolute coordinates
Draw a white line (clear a line), given absolute coordinates
Draw a line, starting from the last plotted pixel to the given position
Draw a line in xor mode, starting from the last plotted pixel to the given position
Draw a white line starting from the last plotted pixel to the given position
Draw a line, starting from the last plotted pixel to the given relative position
Draw a line in XOR mode, starting from the last plotted pixel to the given relative position
Draw a white line starting from the last plotted pixel to the given relative position
Draw a box border
Draw a white box border
Invert the given box border. Useful for “select area” functions.
Draw a circle.
Draw a white circle.
Clear the screen and (if necessary for the platform) enter in graphics mode.
Clear the given screen area.
Fill an area starting at the given point. (this function might not work correctly on all the platforms, and uses a lot of stack space)
The “stencil” object is an evolution of a base concept introduced by Rafael de Oliveira Jannone in his gfx library: a convex area is defined by two byte vectors, pointing respectivelty to the leftmost and the rightmost X coordinates. They're stuffed in a single byte vector, long twice the Y axis.
First of all the programmer must initialize the 'stencil', object, then various shapes can be added to form the resulting convex object (note that no 'holes' are allowed on top and lower borders). As soon as the object is finished it can be drawn on the screen with the “stencil_render()” function. The resulting shape covers the previous picture.
Set/Reset the couple of vectors being part of a “stencil”.
Add a single dot to a figure defined inside a stencil object, init the vector pointers.
Trace a relative line into a stencil object (extend shape).
Trace a line into a stencil object up to a given coordinate (extend shape).
Add a side to a figure defined inside a stencil object
Add a circular shape to a figure defined inside a stencil object
Render an area delimited by a stencil object, with the specified dither intensity (0..11)
Get the maximum X coordinate value for the current target.
Get the maximum Y coordinate value for the current target.
The easiest way to import monochrome raster picture is to use the “sprite” object. The 'putsprite' function has been ported to almost all the supported target and permits to keep portable the data itself. The sprite editors let you import an external data file.
The putsprite function is documented in detail in the monochrome sprites section.
'Graphic Profiles' are byte streams containing vector and surface descriptions. Their components are defined in <gfxprofile.h>.
A data converter called 'z80svg' is provided. It converts data from the SVG format to a 'profile' stream. A programmer might prepare his own pictures by just drawing them with InkScape, or directly describing the paths in data structures.
Render a picture defined in a 'profile' byte stream.