# Glulx Drawing Commands

## version 1/090629 by Erik Temple

Section - Flexible Windows drawing commands (for use with Flexible Windows by Jon Ingold)

To draw a/-- rectangle with (color - a glulx color value) stroke of (strok - a number) pixel/pixels in (win - a g-window) from/at --/coordinates (gleft - a number) by/and (gupper - a number) to (gright - a number) by/and (glower - a number), outlining:
(- DrawRectangle({color}, {strok}, {win}, {gleft}, {gupper}, {gright}, {glower}, {phrase options}); -)

To draw a/-- (color - a glulx color value) filled rectangle in (win - a g-window) from/at --/coordinates (gleft - a number) by/and (gupper - a number) to (gright - a number) by/and (glower - a number):
(- DrawFilledRect({color}, {win}, {gleft}, {gupper}, {gright}, {glower}); -)

To draw a/-- square with (color - a glulx color value) stroke of (strok - a number) pixel/pixels in (win - a g-window) at/from --/coordinates (gleft - a number) by/and (gupper - a number) with size (rect_size - a number), outlining:
if outlining:
draw a rectangle with color stroke of strok pixels in win from gleft by gupper to (gleft + rect_size) by (gupper + rect_size), outlining;
otherwise:
draw a rectangle with color stroke of strok pixels in win from gleft by gupper to (gleft + rect_size) by (gupper + rect_size);

To draw a/-- (color - a glulx color value) filled square in (win - a g-window) at/from --/coordinates (gleft - a number) by/and (gupper - a number) with size (rect_size - a number):
draw a color filled rectangle in win from gleft by gupper to (rect_size + gleft) by (rect_size + gupper);

To draw the/-- image/-- (ID - a figure-name) in (win - a g-window) at/from coordinates/-- (x - a number) by/and (y - a number):
(- DrawImage({ID}, {win}, {x}, {y}); -)

To draw the/-- image/-- (ID - a figure-name) in (win - a g-window) at/from coordinates/-- (x - a number) by/and (y - a number) with dimensions (image_x - a number) and/by (image_y - a number):
(- DrawImageScaled({ID}, {win}, {x}, {y}, {image_x}, {image_y}); -)

Include (-

[ DrawFilledRect color win left upper right lower ;
if (win.ref_number) {
color = ColVal(color);
glk_window_fill_rect(win.ref_number, color, left, upper, (right - left), (lower - upper) );
}
];

[ DrawRectangle color stroke win left upper right lower outlining ;
! Draws four rectangles that outline the coordinates given as input on the I7 level.
if (win.ref_number) {
color = ColVal(color);
if (~~outlining) {
glk_window_fill_rect(win.ref_number, color, left, upper, right - left, stroke);
glk_window_fill_rect(win.ref_number, color, right - stroke, upper, stroke, lower - upper);
glk_window_fill_rect(win.ref_number, color, left, lower - stroke, right - left, stroke);
glk_window_fill_rect(win.ref_number, color, left, upper, stroke, lower - upper);
}
if (outlining) {
glk_window_fill_rect(win.ref_number, color, left - stroke, upper - stroke, stroke + right - left, stroke);
glk_window_fill_rect(win.ref_number, color, right, upper - stroke, stroke, stroke + lower - upper);
glk_window_fill_rect(win.ref_number, color, left - stroke, lower, stroke + stroke + right - left, stroke);
glk_window_fill_rect(win.ref_number, color, left - stroke, upper - stroke, stroke, stroke + lower - upper);
}
}
];

[DrawImageScaled ID win x y image_x image_y ;
if (win.ref_number) {
glk_image_draw_scaled(win.ref_number, ID, x, y, image_x, image_y);
}
];

[DrawImage ID win x y ;
if (win.ref_number) {
glk_image_draw(win.ref_number, ID, x, y);
}
];

-).

Glulx Drawing Commands ends here.