Set the units and point of origin used when positioning an overlay
Name
ggiOvlSetCoordBase : Set the units and point of origin used when positioning an overlay
Synopsis
#include <ggi/ggi.h> int ggiOvlSetCoordBase(ggiOvl_t ovl, enum ggi_ll_coordbase units, long x, long y, long w, long h);
Description
ggiOvlSetCoordBase sets the units used by future calls to ggiOvl* functions on the provided object ovl, not including the x, y, w, h parameters passed in the current call, which are subject to translation from any coordinate base which was set with a previous call to this function.
The parameter units decides the units that will be passed from this point forward to LibOvl functions such as ggiOvlSetPos and ggiOvlSetSize. It may contain any of the following self-descriptive values: 'LL_COORDBASE_PIXEL', 'LL_COORDBASE_DOT', 'LL_COORDBASE_MILLIMETER', 'LL_COORDBASE_MICROMETER', 'LL_COORDBASE_1_64_INCH'.
These values may be combined with a few bit flags:
- 'LL_COORDBASE_RESET'
causes the parameters in the current call to be interperated as though the resource was newly initialized, e.g. no offsets are applied, and the units are in pixels.
- 'LL_COORDBASE_SUBUNIT'
alters the scale to match any underlying natural unit which the resource has as defined in the LibGAlloc resource properties of ovl's motor resource. This is only useful to deal with some very platform-specific applications.
The parameters x, :p`y` set the origin offset for the object ovl. Coordinates passed to any future calls on ovl will be subject to translation from this point of reference. The parameters w, h are analogous to that for sizing operations; generally you should leave them alone by setting them to 0; most people will never need them.
Return value
ggiOvlSetCoordBase returns 0 on success or a negative error value on failure.
Examples
Center a sprite at 50mm, 50mm and spiral it out from there:
ggiOvlSetCoordBase(GA_COORDBASE_MILLIMETERS, 0, 0, 0, 0); ggiOvlGetSize(sprite, &sx, &sy); ggiOvlSetCoordBase(ovl, GA_COORDBASE_RESET, 50 - sx/2, 50 - sy/2, 0, 0); for (i = 0; i < 500; i++) { /* Note lack of "+ offset" in below. Handy, eh? */ ggiOvlSetPos(ovl, sin(i/100) * i / 10, cos(i/100) * i / 10); }