# Glulx Drawing Commands

## version 1/090629 by Erik Temple

Section - Simple Graphical Window (for use with Simple Graphical Window by Emily Short)

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

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

To draw a/-- square with (color - a glulx color value) stroke of (strok - a number) pixel/pixels 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 from gleft by gupper to (gleft + rect_size) by (gupper + rect_size), outlining;
otherwise:
draw a rectangle with color stroke of strok pixels from gleft by gupper to (gleft + rect_size) by (gupper + rect_size);

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

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

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

Include (-

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

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

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

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

Constant glulx_colour_table = (+Table of Common color Values+);
! From Jon Ingold's Flexible Windows - provides I6 interface to Glulx Text Effects color table
[ ColVal c i max;
max=TableRows(glulx_colour_table);
for ( i=1:i<=max:i++ ) {
if (TableLookUpEntry(glulx_colour_table, 1, i) == c)
return TableLookUpEntry(glulx_colour_table, 2, i);
}
];

-).