Glimmr Drawing Commands

version 2/101030 by Erik Temple

  • Home page
  • Beginning
  • Previous
  • Next



  • Chapter - Text-painting with bitmap fonts


    Section - Bitmap strings with a background color

    To paintbittext (hue - a number) of (str - indexed text) in (win - a g-window) at (X1 - a number) by/x (Y1 - a number) using font/-- (typf - a font) with dot/-- size (wgt - a number) pixel/pixels/px/-- and background (bkgd - a number), center-aligned or right-aligned:
        unless STR is "":
            now g-LEN is the length of STR set in TYPF;
            if right-aligned:
                now X1 is X1 - (g-LEN * WGT);
            if center-aligned:
                now X1 is X1 - (g-LEN * WGT) / 2;
            now current g-row is Y1;
            now current g-column is X1;
            now column-index is current g-column;
            dimrectdraw (BKGD) in (WIN) at (current g-column - WGT) by (current g-row - WGT) with size (WGT * g-LEN) + WGT by (WGT * font-height of TYPF) + WGT;
            repeat with N running from 1 to the number of characters in STR:
                now char_code is the character code of position N of STR;
                if there is a char of char_code in the font table of TYPF:
                    choose row with a char of char_code in the font table of TYPF;
                otherwise:
                    choose row with a char of 32 in the font table of TYPF;
                now g-scan is 0;
                [let bitmap-size be width entry * height entry;]
                repeat with pointer running from (index entry + 1) to (index entry + (width entry * height entry)):
                    increase g-scan by 1;
                    if g-scan > width entry:
                        increase current g-row by WGT;
                        now current g-column is column-index;
                        let g-scan be 1;
                    if entry pointer of the glyph map of TYPF is 1:
                        dimrectdraw (HUE) in WIN at (current g-column) by current g-row + (yoffset entry * WGT) with size WGT by WGT;
                    increase current g-column by WGT;
                increase column-index by (advance entry * WGT);
                now current g-column is column-index;
                now current g-row is Y1;

    To paint/display a/-- bitmap text (hue - a number) of (str - indexed text) in (win - a g-window) at (X1 - a number) by/x (Y1 - a number) using font/-- (typf - a font) with dot/-- size (wgt - a number) pixel/pixels/px/-- and background (bkgd - a number), center-aligned or right-aligned:
        #if utilizing Glimmr debugging;
        say "[>console][DC]Painting bitmap text string [quotation mark][STR][quotation mark] in [i][WIN][/i] with origin ([X1], [Y1]) and dot size [WGT][if center-aligned], center-aligned[end if][if right-aligned], right-aligned[end if]. Font: [TYPF], background color: [BKGD].[<]";
        #end if;
        if center-aligned:
            paintbittext (HUE) of (STR) in (WIN) at (X1) by (Y1) using (TYPF) with size (WGT) and background (BKGD), center-aligned;
            rule succeeds;
        if right-aligned:
            paintbittext (HUE) of (STR) in (WIN) at (X1) by (Y1) using (TYPF) with size (WGT) and background (BKGD), right-aligned;
            rule succeeds;
        paintbittext (HUE) of (STR) in (WIN) at (X1) by (Y1) using (TYPF) with size (WGT) and background (BKGD).

    To paint/display a/-- bitmap text (hue - a number) of (str - indexed text) in (win - a g-window) at (coord1 - a list of numbers) using font/-- (typf - a font) with dot/-- size (wgt - a number) pixel/pixels/px/-- and background (bkgd - a number), center-aligned or right-aligned:
        let x1 be entry 1 of coord1;
        let y1 be entry 2 of coord1;
        if center-aligned:
            paint bitmap text (HUE) of (STR) in (WIN) at (X1) by (Y1) using (TYPF) with size (WGT) and background (BKGD), center-aligned;
            rule succeeds;
        if right-aligned:
            paint bitmap text (HUE) of (STR) in (WIN) at (X1) by (Y1) using (TYPF) with size (WGT) and background (BKGD), right-aligned;
            rule succeeds;
        paint bitmap text (HUE) of (STR) in (WIN) at (X1) by (Y1) using (TYPF) with size (WGT) and background (BKGD).