Glimmr Canvas-Based Drawing

version 2/101030 by Erik Temple

  • Home page
  • Beginning
  • Previous
  • Next



  • Chapter - Drawing the canvas background

    Drawing the canvas background of something is an activity.

    Last for drawing the canvas background of a graphics g-window (called the window) (this is the default canvas background drawing rule):
        let panel be the associated canvas of the window;
        if panel is not nothing:
            if the background image of panel is not Figure of Null:
                draw the background-image of panel in the window;
                #if utilizing Glimmr debugging;
                say "[>console][CBD]Drawing canvas background [i][background image of panel][/i] in [i][window][/i].[<]";
                #end if;
            otherwise:
                do nothing;
                #if utilizing Glimmr debugging;
                say "[>console][CBD]Canvas [i][panel][/i] has no background image.[<]";
                #end if;
        otherwise:
            say "*** Glimmr Error: No canvas defined for [i][window][/i]."

    To draw the background-image of (panel - a g-canvas) in (win - a g-window):
        (- DrawCanvas({panel}, {win}); -)

        
    Include (-

    [ DrawCanvas c g;
        if (g.ref_number) {
            if (g.scaling_factor~= (+ Divisor +) ) {!internal representation of 1.0000
                glk_image_draw_scaled(g.ref_number, ResourceIDsOfFigures-->c.background_img, g.x_offset, g.y_offset, c.scaled_width, c.scaled_height);
            }
            else {
                glk_image_draw(g.ref_number, ResourceIDsOfFigures-->c.background_img, g.x_offset, g.y_offset);
            }
        }
    ];

    -)