# Glimmr Drawing Commands

## version 2/101030 by Erik Temple

**Section - Text-painting without a background color**

To paintimgtext of/-- (STR - indexed text) in (win - a g-window) at (X1 - a number) by/x (Y1 - a number) using font/-- (TYPF - a font) scaled at (SCF - a real number), center-aligned or right-aligned:

unless STR is "":

now g-LEN is the length of STR set in TYPF;

now g-LEN is g-LEN real times SCF as an integer;

if right-aligned:

let X1 be X1 - g-LEN;

if center-aligned:

let X1 be X1 - (g-LEN / 2);

now current g-row is Y1;

now current g-column is X1;

let vertical-size be font-height of TYPF real times SCF as an integer;

repeat with N running from 1 to the number of characters in STR:

let V be the character code of position N of STR;

if there is a char of V in the font table of TYPF:

choose row with a char of V in the font table of TYPF;

otherwise:

choose row with a char of 32 in the font table of TYPF;

let the chosen glyph be glyph-ref entry;

let the yoffset be yoffset entry real times SCF as an integer;

now g-imgwidth is the image-width of chosen glyph;

now g-imgheight is the image-height of chosen glyph;

now g-imgwidth is g-imgwidth real times SCF as an integer;

now g-imgheight is g-imgheight real times SCF as an integer;

drscimage (chosen glyph) in (WIN) at (current g-column) by (current g-row + yoffset) with dimensions (g-imgwidth) by (g-imgheight);

increase current g-column by the advance entry real times SCF as an integer;

To paint/display an/-- image-based text of/-- (STR - indexed text) in (win - a g-window) at (X1 - a number) by/x (Y1 - a number) using font/-- (TYPF - a font) scaled at (SCF - a real 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])[if center-aligned], center-aligned[end if][if right-aligned], right-aligned[end if]. Font: [TYPF], scaled at [SCF].[<]";

#end if;

if center-aligned:

paintimgtext of (STR) in (WIN) at (X1) by (Y1) using (TYPF) scaled at (SCF), center-aligned;

if right-aligned:

paintimgtext of (STR) in (WIN) at (X1) by (Y1) using (TYPF) scaled at (SCF), right-aligned;

paintimgtext of (STR) in (WIN) at (X1) by (Y1) using (TYPF) scaled at (SCF).

To paint/display an/-- image-based text (hue - a number) of (str - indexed text) in (win - a g-window) at (coord1 - a list of numbers) using font/-- (typf - a font) scaled at (SCF - a real number), center-aligned or right-aligned:

let x1 be entry 1 of coord1;

let y1 be entry 2 of coord1;

if center-aligned:

paint image-based text of (STR) in (WIN) at (X1) by (Y1) using (TYPF) scaled at (SCF), center-aligned;

rule succeeds;

if right-aligned:

paint image-based text of (STR) in (WIN) at (X1) by (Y1) using (TYPF) scaled at (SCF), right-aligned;

rule succeeds;

paint image-based text of (STR) in (WIN) at (X1) by (Y1) using (TYPF) scaled at (SCF).