# Glimmr Drawing Commands

## version 2/101030 by Erik Temple

**Section - Rectangle**

To rectdraw (hue - a number) in (win - a g-window) from (x1 - a number) by (y1 - a number) to (x2 - a number) by (y2 - a number):

(- DrawRect({hue}, {win}, {x1}, {y1}, {x2}, {y2}); -)

To draw/display a/-- rectangle/rect (hue - a number) in (win - a g-window) from (x1 - a number) by/x (y1 - a number) to (x2 - a number) by/x (y2 - a number):

rectdraw (hue) in (win) from (x1) by (y1) to (x2) by (y2);

#if utilizing Glimmr debugging;

say "[>console][DC]Drawing a rectangle of color [hue] in [i][win][/i] with upper left ([x1], [y1]) and lower right ([x2], [y2]).[<]";

#end if.

To draw/display a/-- rectangle/rect (hue - a number) in (win - a g-window) from (coord1 - a list of numbers) to (coord2 - a list of numbers):

let x1 be entry 1 of coord1;

let y1 be entry 2 of coord1;

let x2 be entry 1 of coord2;

let y2 be entry 2 of coord2;

rectdraw (hue) in (win) from (x1) by (y1) to (x2) by (y2).

To rect/rectangle (coord1 - a list of numbers) to (coord2 - a list of numbers):

if the type of the current graphics window is not g-graphics:

say "*** Error: Short-form rectangle-drawing directive ignored. The current graphics window global was not correctly specified.";

rule fails;

let x1 be entry 1 of coord1;

let y1 be entry 2 of coord1;

let x2 be entry 1 of coord2;

let y2 be entry 2 of coord2;

draw a rectangle (current foreground-color) in (current graphics window) from (x1) by (y1) to (x2) by (y2).

Include (-

[ DrawRect hue win x1 y1 x2 y2 ;

if (win.ref_number) {

glk_window_fill_rect(win.ref_number, hue, x1, y1, x2 - x1, y2 - y1 );

}

];

-).