Home  Contents

gcx:line

Graphics Core4 Lua Commands

SYNOPSIS

  1. gcx:line(x1, y1, x2, y2[, rgb])
  2. gfx.line(x1, y1, x2, y2, function callback(x, y) ... end)

DESCRIPTION

The first form draws a line from x1, y1 to x2, y2 using the specified color rgb.
If color is not given, uses the stored foreground color.

The second form calculates all points on the line from x1, y1 to x2, y2. For each point it calls the function callback with two parameters, the x and y coordinate of the calculated point. This form does not require a graphics context. It can be called independently of any graphics hardware.

ERRORS

Raises an error if gcx is not a graphics context.

EXAMPLE

Draws a blue cross across the screen:
gcx:line(0, 0, gcx:width()-1, gcx:height()-1, 0x0000FF)
gcx:line(gcx:width()-1, 0, 0, gcx:height()-1, 0x0000FF)

SEE ALSO