Drawing primitives

[ Back ]

NaaLaa doesn't have many primitive types for drawing, but hopefully you'll get around.

Sub routines

procedure draw line x0, y0, x1, y1
procedure draw pixel x, y
procedure set pixel x, y
procedure draw rect x, y, w, h[, fill]
procedure draw poly points[][, fill] / procedure draw polyf points#[][, fill]
procedure set color r, g, b[, a]
function pixel[](x, y)
procedure set colori c
function pixeli([image_id, ]x, y)
procedure set additive value
procedure hscroll dx
procedure vscroll dy
procedure scroll dx, dy
procedure set clip rect x, y, width, height


procedure draw line x0, y0, x1, y1

Draw line from x0, y0 to x1, y1.


procedure draw pixel x, y

Draw pixel at x, y.


procedure set pixel x, y

Set pixel at x, y to current drawing color (see set color and set colori)


procedure draw rect x, y, w, h[, fill]

Draw rectangle of width w and height h with upper left corner at x, y. If fill is submitted and set to true, the rectangle is filled.


procedure draw poly points[][, fill]
procedure draw polyf points#[][, fill]

Draw a polygon of the points in points. If the optional fill is supplied and set to true, the polygon will be filled. The format of the points should be [x1, y1, x2, y2, x3, y3, ...]. Ex:

draw poly [100, 100, 200, 100, 200, 200, 100, 200], true

, draws a filled rectangle.


procedure set color r, g, b[, a]

Set color to r, g, b (RGB) or r, g, b, a (RGBA) if an alpha (transparency) value is submitted. This color will affect all drawing operation, including text output.


function pixel[](x, y)

Return color at x, y as an integer array [r, g, b, a] (RGBA).


procedure set colori c

Set current drawing color to c. c is an integer containing one byte per color channel (in the RGBA format AARRGGBB). See pixeli for more information.


function pixeli([image_id, ]x, y)

Get color as an integer (in the RGBA format AARRGGBB) at position x, y. If an image, image_id, is submitted, the pixel will be read from that image.


procedure set additive value

Use additive draw mode if value is set to true.


procedure hscroll dx

Scroll image dx steps horisontally.


procedure vscroll dy

Scroll image dy steps vertically.


procedure scroll dx, dy

Scroll image dx steps horisontally and dy steps vertically.


procedure set clip rect x, y, w, h

Set clipping rectangle for current image to position x, y and width and height w, h. Graphics wont be drawn outside of this rectangle.


function cels(image_id)

Return number of cels in image image_id. See set image grid.


function cols(image_id)

Return number of columns in image image_id. See set image grid.


function rows(image_id)

Return number of rows in image image_id. See set image grid.


function width(image_id)

Return width (or cel width) of image image_id.


function height(image_id)

Return height (or cel height) of image image_id.


procedure draw hraster image_id, y, x_start, x_end, u_start#, v_start#, u_end#, v_end#

Draw a horizontal line from x_start, y to x_end, y. This line uses image image_id as a texture. The texture coordinates at x_start, y are u_start, v_start, and the texture coordinates at x_end, y are u_end, v_end. The texture coordinates are measured from the top left corner of image image_id, and they should be in the range 0..1 (where 1, 1 is the bottom right of the image).

This procedure does not handle transparency (alpha channel) of the source image, nor is it affected by the additive draw mode. Also, the color set with set color works as a "fog" on the texture. That is, if you use set color 255, 255, 255, 0, the texture will look as it does in the image image_id. But if you use set color 255, 255, 255, 255, the texture will be replaced by a solid white color.


procedure draw vraster image_id, x, y_start, y_end, u_start#, v_start#, u_end#, v_end#

Draw a vertical line from x, y_start to x, y_end. This line uses image image_id as a texture. The texture coordinates at x, y_start are u_start, v_start, and the texture coordinates at x, y_end are u_end, v_end. The texture coordinates are measured from the top left corner of image image_id, and they should be in the range 0..1 (where 1, 1 is the bottom right of the image).

For information about how set color affects this procedure, have a look at draw hraster.


[ Back ]