Glimmr Canvas-Based Drawing

version 2/101030 by Erik Temple

  • Home page
  • Beginning
  • Previous
  • Next



  • Section - Commands for centering the window frame on specific points
    [The window centering phrases will only work properly when used after the scaling and offset factors are determined. Usually these phrases will be used in the window-framing adjustment activity. Coordinates passed into the centering phrases should be in canvas coordinates, not screen coordinates.]

    To center the/-- frame/framing/-- of/-- (win - a g-window) on canvas/-- coordinates/-- (coord - a list of numbers):
        let x be entry 1 of coord;
        let y be entry 2 of coord;
        now entry 1 of the origin of win is x - (canvas-width of the associated canvas of win / 2);
        now entry 2 of the origin of win is y - (canvas-height of the associated canvas of win / 2);
        #if utilizing Glimmr debugging;
        say "[>console][CBD]Window [i][win][/i] recentered on canvas coordinates [coord in brace notation]; origin changed to ([entry 1 of origin of win], [entry 2 of origin of win]).[<]";
        #end if;

    To decide what list of numbers is the center-point of (panel - a g-canvas):
        let x be the canvas-width of panel divided by 2;
        let y be the canvas-height of panel divided by 2;
        let coord be {0, 0};
        now entry 1 of coord is x;
        now entry 2 of coord is y;
        decide on coord.

    To center the/-- frame/framing/-- of/-- (win - a g-window) on its g-canvas/canvas:
        let panel be the associated canvas of win;
        center win on the center-point of panel.

    To center the/-- frame/framing/-- of/-- (win - a g-window) on (item - a g-element):
        #if utilizing Glimmr debugging;
        say "[>console][CBD]Centering the window frame of [i][win][/i] on [i][item][/i].[<]";
        #end if;
        center win on the center-point of item.