line.c File Reference

Line drawing graphics routines. More...

#include "gfx.h"
#include "gfx_p.h"
#include "cfg/cfg_gfx.h"
#include <cfg/debug.h>
#include <cfg/macros.h>

Go to the source code of this file.

Functions

static void gfx_lineUnclipped (Bitmap *bm, coord_t x1, coord_t y1, coord_t x2, coord_t y2)
 Draw a sloped line without performing clipping.
static int gfx_findRegion (int x, int y, Rect *cr)
 Helper routine for gfx_line().
void gfx_line (Bitmap *bm, coord_t x1, coord_t y1, coord_t x2, coord_t y2)
 Draw a sloped line segment.
void gfx_moveTo (Bitmap *bm, coord_t x, coord_t y)
 Move the current pen position to the specified coordinates.
void gfx_lineTo (Bitmap *bm, coord_t x, coord_t y)
 Draw a line from the current pen position to the new coordinates.
void gfx_rectDraw (Bitmap *bm, coord_t x1, coord_t y1, coord_t x2, coord_t y2)
 Draw the perimeter of an hollow rectangle.
void gfx_rectFillC (Bitmap *bm, coord_t x1, coord_t y1, coord_t x2, coord_t y2, uint8_t color)
 Fill a rectangular area with color.
void gfx_rectFill (Bitmap *bm, coord_t x1, coord_t y1, coord_t x2, coord_t y2)
 Draw a filled rectangle.
void gfx_rectClear (Bitmap *bm, coord_t x1, coord_t y1, coord_t x2, coord_t y2)
 Clear a rectangular area.
void gfx_setViewRect (Bitmap *bm, vcoord_t x1, vcoord_t y1, vcoord_t x2, vcoord_t y2)
 Imposta gli estremi del sistema di coordinate cartesiane rispetto al rettangolo di clipping della bitmap.
coord_t gfx_transformX (Bitmap *bm, vcoord_t x)
 Transform a coordinate from the current reference system to a pixel offset within the bitmap.
coord_t gfx_transformY (Bitmap *bm, vcoord_t y)
 Transform a coordinate from the current reference system to a pixel offset within the bitmap.
void gfx_vline (Bitmap *bm, vcoord_t x1, vcoord_t y1, vcoord_t x2, vcoord_t y2)
 Draw a line from (x1;y1) to (x2;y2).

Detailed Description

Line drawing graphics routines.

Version:
Id
line.c 2730 2009-07-02 13:12:51Z lottaviano
Author:
Bernie Innocenti <bernie@codewiz.org>
Stefano Fedrigo <aleph@develer.com>
See also:
gfx.h

Definition in file line.c.


Function Documentation

void gfx_line ( Bitmap bm,
coord_t  x1,
coord_t  y1,
coord_t  x2,
coord_t  y2 
)

Draw a sloped line segment.

Draw a sloped line segment identified by the provided start and end coordinates on the bitmap bm.

The line endpoints are clipped inside the current bitmap clipping rectangle using the Cohen-Sutherland algorithm, which is very fast.

Note:
The point at coordinates x2 y2 is not drawn.
This function does not update the current pen position.

Definition at line 184 of file line.c.

void gfx_lineTo ( Bitmap bm,
coord_t  x,
coord_t  y 
)

Draw a line from the current pen position to the new coordinates.

Note:
This function moves the current pen position to the new coordinates.
See also:
gfx_line()

Definition at line 264 of file line.c.

static void gfx_lineUnclipped ( Bitmap bm,
coord_t  x1,
coord_t  y1,
coord_t  x2,
coord_t  y2 
) [static]

Draw a sloped line without performing clipping.

Parameters are the same of gfx_line(). This routine is based on the Bresenham Line-Drawing Algorithm.

Note:
Passing coordinates outside the bitmap boundaries will result in memory trashing.
See also:
gfx_line()

Definition at line 71 of file line.c.

void gfx_moveTo ( Bitmap bm,
coord_t  x,
coord_t  y 
)

Move the current pen position to the specified coordinates.

The pen position is used for drawing operations such as gfx_lineTo(), which can be used to draw polygons.

Definition at line 250 of file line.c.

void gfx_rectClear ( Bitmap bm,
coord_t  x1,
coord_t  y1,
coord_t  x2,
coord_t  y2 
)

Clear a rectangular area.

Note:
The bottom-right border of the rectangle is not cleared.
This function does not update the current pen position.

Definition at line 354 of file line.c.

void gfx_rectDraw ( Bitmap bm,
coord_t  x1,
coord_t  y1,
coord_t  x2,
coord_t  y2 
)

Draw the perimeter of an hollow rectangle.

Note:
The bottom-right corner of the rectangle is drawn at (x2-1;y2-1).
This function does not update the current pen position.

Definition at line 277 of file line.c.

void gfx_rectFill ( Bitmap bm,
coord_t  x1,
coord_t  y1,
coord_t  x2,
coord_t  y2 
)

Draw a filled rectangle.

Note:
The bottom-right border of the rectangle is not drawn.
This function does not update the current pen position.

Definition at line 341 of file line.c.

void gfx_rectFillC ( Bitmap bm,
coord_t  x1,
coord_t  y1,
coord_t  x2,
coord_t  y2,
uint8_t  color 
)

Fill a rectangular area with color.

Note:
The bottom-right border of the rectangle is not drawn.
This function does not update the current pen position.

Definition at line 298 of file line.c.