Glimmr Drawing Commands

version 2/101030 by Erik Temple

  • Home page
  • Beginning
  • Previous
  • Next



  • Chapter - Outlined rectangles


    Section - Box

    To boxdraw (hue - a number) in (win - a g-window) from (x1 - a number) by (y1 - a number) to (x2 - a number) by (y2 - a number) with (wgt - a number), outlined or inset:
        (- DrawBox({hue}, {wgt}, {win}, {x1}, {y1}, {x2}, {y2}, {phrase options}); -)

    To draw/display a/-- box (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) with (wgt - a number) pixel/pixels/px/-- line-weight/stroke, outlined or inset:
        if outlined:
            boxdraw (hue) in (win) from (x1) by (y1) to (x2) by (y2) with (wgt), outlined;
        otherwise if inset:
            boxdraw (hue) in (win) from (x1) by (y1) to (x2) by (y2) with (wgt), inset;
        otherwise:
            boxdraw (hue) in (win) from (x1) by (y1) to (x2) by (y2) with (wgt);
        #if utilizing Glimmr debugging;
        say "[>console][DC]Drawing a box of color [hue] in [i][win][/i] with upper left ([x1], [y1]) and lower right ([x2], [y2]), line-weight [wgt] px[if outlined]; line is drawn outside the bounds of the box[otherwise if inset]; line is drawn inside the bounds of the box[end if].[<]";
        #end if;

    To draw/display a/-- box (hue - a number) in (win - a g-window) from (coord1 - a list of numbers) to (coord2 - a list of numbers) with (wgt - a number) pixel/pixels/px/-- line-weight/stroke, outlined or inset:
        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;
        if outlined:
            boxdraw (hue) in (win) from (x1) by (y1) to (x2) by (y2) with (wgt), outlined;
        otherwise if inset:
            boxdraw (hue) in (win) from (x1) by (y1) to (x2) by (y2) with (wgt), inset;
        otherwise:
            boxdraw (hue) in (win) from (x1) by (y1) to (x2) by (y2) with (wgt);
            
    To box (coord1 - a list of numbers) to (coord2 - a list of numbers) at (wgt - a number) px/pixels/pixel, outlined or inset:
        if the type of the current graphics window is not g-graphics:
            #if utilizing Glimmr debugging;
            say "*** Error: Short-form box-drawing directive ignored. The current graphics window global was not correctly specified.";
            #end if;
            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;
        if outlined:
            boxdraw (current foreground-color) in (current graphics window) from (x1) by (y1) to (x2) by (y2) with (wgt), outlined;
        otherwise if inset:
            boxdraw (current foreground-color) in (current graphics window) from (x1) by (y1) to (x2) by (y2) with (wgt), inset;
        otherwise:
            boxdraw (current foreground-color) in (current graphics window) from (x1) by (y1) to (x2) by (y2) with (wgt).


    Include (-

    [ DrawBox hue wgt win x1 y1 x2 y2 outline_opt ;
    ! Draws four rectangles that outline the coordinates given as input on the I7 level.
        if (win.ref_number) {
            if (outline_opt & 2) {
                glk_window_fill_rect(win.ref_number, hue, x1, y1, x2 - x1, wgt);
                glk_window_fill_rect(win.ref_number, hue, x2 - wgt, y1, wgt, y2 - y1);
                glk_window_fill_rect(win.ref_number, hue, x1, y2 - wgt, x2 - x1, wgt);
                glk_window_fill_rect(win.ref_number, hue, x1, y1, wgt, y2 - y1);
            }
            if (outline_opt & 1) {
                glk_window_fill_rect(win.ref_number, hue, x1 - wgt, y1 - wgt, wgt + x2 - x1, wgt);
                glk_window_fill_rect(win.ref_number, hue, x2, y1 - wgt, wgt, wgt + y2 - y1);
                glk_window_fill_rect(win.ref_number, hue, x1 - wgt, y2, wgt + wgt + x2 - x1, wgt);
                glk_window_fill_rect(win.ref_number, hue, x1 - wgt, y1 - wgt, wgt, wgt + y2 - y1);
            }
            if (~~outline_opt) {
                glk_window_fill_rect(win.ref_number, hue, x1 - (wgt / 2), y1 - (wgt / 2), x2 - x1, wgt);
                glk_window_fill_rect(win.ref_number, hue, x2 - (wgt / 2), y1 - (wgt / 2), wgt, (y2 - y1) + wgt);
                glk_window_fill_rect(win.ref_number, hue, x1 - (wgt / 2), y2 - (wgt / 2), x2 - x1, wgt);
                glk_window_fill_rect(win.ref_number, hue, x1 - (wgt / 2), y1 - (wgt / 2), wgt, y2 - y1);
            }
        }
    ];

    -).