Next Previous Contents

3. Manipulation of the graphics context

3.1 Clipping

void ggiSetClip(ggi_visual_t vis, int x1, int y1, int x2, int y2);

Set the clipping rectangle to the intersection of ((x1,y1),(x2,y2)) and the current clipping rectangle. A pixel (x,y) lies inside the clipping rectangle if (x >= x1 && y >= y2 && x < x2 && y < y2). ggiSetClip(dc, x, y, x, y) disables all drawing.

ggi_bool ggiPointVisible(ggi_visual_t vis, int x, int y);

Returns true if the point (x,y) lies inside the clipping rectangle.

ggi_bool ggiRectVisible(ggi_visual_t vis, int x1, int y1, int x2, int y2);

Returns true if the rectangle ((x1,y1),(x2,y2)) is at least partially visible.

3.2 Drawing modes

void ggiSetArcMode(ggi_visual_t vis, ggi_arcmode mode);

ggi_arcmode ggiGetArcMode(ggi_visual_t vis);

Set/Get the current arc drawing mode:

void ggiSetPolyMode(ggi_visual_t vis, ggi_polymode mode);

ggi_polymode ggiGetPolyMode(ggi_visual_t vis);

Set/Get the current polygon filling mode:

In general, the modes differ only in cases where a complex, overlapping polygon must be filled (for example, a five-sided polygon that forms a five-pointed star with a pentagon in the center). In such cases, EVENODD mode fills every other enclosed region within the polygon (that is, the points of the star), but WINDING mode fills all regions (that is, the points and the pentagon).

When the fill mode is EVENODD, libGGI2D fills the area between odd-numbered and even-numbered polygon sides on each scan line. That is, libGGI2D fills the area between the first and second side, between the third and fourth side, and so on.

When the fill mode is WINDING, libGGI2D fills any region that has a nonzero winding value. This value is defined as the number of times a pen used to draw the polygon would go around the region. The direction of each edge of the polygon is important.

void ggiSetLineDash(ggi_visual_t vis, uint dash[], uint size);

void ggiGetLineDash(ggi_visual_t vis, uint dash[], uint *size);

Set/Get the current line pattern. A normal line will be drawn if size is 0.

void ggiSetAppendMode(ggi_visual_t vis, ggi_bool append);

ggi_bool ggiGetAppendMode(ggi_visual_t vis);

Set/Get the current append mode.

void ggiSetAntialias(ggi_visual_t vis, ggi_bool antialias);

ggi_bool ggiGetAntialias(ggi_visual_t vis);

Set/Get the antialiasing mode.

3.3 Color and texture

void ggiSetDrawColor(ggi_visual_t vis, ggi_col color);

ggi_col ggiGetDrawColor(ggi_visual_t vis);

Set/Get the current drawing color.

void ggiSetFillColor(ggi_visual_t vis, ggi_col color);

ggi_col ggiGetFillColor(ggi_visual_t vis);

Set/Get the current filling color.

void ggiSetFillTexture(ggi_visual_t vis, int refx, int refy, ggi_visual texture);

Set the texture and the reference point (refx,refy). The color of a drawn pixel at (x,y) is now the texel at (abs(refx-x) mod texture.width, abs(refy-y) mod texture.height).

ggi_visual ggiGetFillTexture(ggi_visual_t vis, int *refx, int *refy);

Get the current texture and reference point. Returns NULL and (0,0) if no texture is set.

3.4 Drawing style

void ggiSetOperator(ggi_visual_t vis, ggi_operator operator);

ggi_operator ggiGetOperator(ggi_visual_t vis);

Set/Get the current operator. The following operators are defined:

GGI_NOOP disables drawing.

void ggiSetAlpha(ggi_visual_t vis, ggi_alpha alpha);

ggi_alpha ggiGetAlpha(ggi_visual_t vis);

Set/Get the current alpha value. The alpha value determines the transparency of a drawn pixel. An alpha value of 0 disables drawing.


Next Previous Contents