Glimmr Canvas-Based Drawing

version 2/101030 by Erik Temple

  • Home page
  • Beginning
  • Previous
  • Next



  • Section - Bitmap-rendered string drawing rule

    An element display rule for a bitmap-rendered string (called the stream):
        if the text-string of the stream is "" and the cursor of the stream is not 0:
            #if utilizing Glimmr debugging;
            say "[>console][CBD]Rendered bitmap string [i][stream][/i] specifies no text and has not been rendered. To display only a cursor, now the cursor property of the bitmap-rendered string is 0.[<]";
            #end if;
            exit;
        let foreground-color be the tint of the stream;
        let background-color be the background tint of the stream;
        let len be the length of the stream;
        if the stream is right-aligned:
            now the win-x of the stream is the win-x of the stream - (len * dot-size);
        if the stream is center-aligned:
            now the win-x of the stream is the win-x of the stream - (len * dot-size) / 2;
        let row be the win-y of the stream;
        let column be the win-x of the stream;
        let column-index be column;
        unless background-color is g-PlaceNullCol or the text-string of the stream is "":
            dimrectdraw (color background-color) in (current window) at (column - dot-size of the stream) by (row - dot-size) with size (dot-size * len) + dot-size by (dot-size * font-height of the associated font of the stream) + dot-size;
        if the cursor of the stream is 0:
            dimrectdraw (color foreground-color) in (current window) at (column) by (row - dot-size) with size dot-size by (dot-size * font-height of the associated font of the stream);
        if the text-string of the stream is "":
            #if utilizing Glimmr debugging;
            say "[>console][CBD]Rendered bitmap string [i][stream][/i] specifies no text. Displaying cursor at position 0.[<]";
            #end if;
            exit;
        repeat with N running from 1 to the number of characters in the text-string of the stream:
            let V be the character code of position N of the text-string of the stream;
            if there is a char of V in the font table of the associated font of the stream:
                choose row with a char of V in the font table of the associated font of the stream;
            otherwise:
                choose row with a char of 32 in the font table of the associated font of the stream;
            let scan be 0;
            let bitmap-size be width entry * height entry;
            repeat with pointer running from (index entry + 1) to the (index entry + bitmap-size):
                increase scan by 1;
                if scan > width entry:
                    increase row by dot-size of the stream;
                    now column is column-index;
                    let scan be 1;
                if entry pointer of the glyph map of the associated font of the stream is 1:
                    dimrectdraw (color foreground-color) in (current window) at (column) by row + (yoffset entry * dot-size) with size dot-size of the stream by dot-size;
                increase column by the dot-size of the stream;
            if the cursor of the stream is N:
                dimrectdraw (color foreground-color) in (current window) at (column) by (win-y of the stream - dot-size) with size dot-size by (dot-size * font-height of the associated font of the stream);
            increase column-index by (advance entry * dot-size of the stream);
            now column is column-index;
            let row be the win-y of the stream;
        #if utilizing Glimmr debugging;
        say "[>console][CBD]Displaying rendered bitmap string [i][stream][/i], foreground color [color foreground-color], in [i][current window][/i] with upper left ([win-x of stream], [win-y]) and lower right ([column], [row + (font-height of the associated font of the stream * dot-size)])[unless background-color is g-PlaceNullCol]; background color [color background-color][end if][if stream is graphlinked]. [line break][CBD]Graphlink corresponding to [i][stream][/i] set from ([win-x of stream], [win-y of stream]) to ([column], [row + (font-height of the associated font of the stream * dot-size)]): [quotation mark][linked replacement-command of stream][quotation mark][end if].[<]";
        #end if;
        if the stream is graphlinked:
            set a graphlink in the current window identified as the stream from (win-x - dot-size) by (win-y - dot-size) to column by row + (font-height of the associated font of the stream * dot-size) as the linked replacement-command of the stream;