Glimmr Canvas-Based Drawing

version 2/101030 by Erik Temple

  • Home page
  • Beginning
  • Previous
  • Next



  • Chapter - Coordinate Manipulation

    To decide which list of numbers is the (warp - a list of numbers) offset by (weft - a list of numbers):
        #if utilizing Glimmr debugging;
        if the number of entries of warp is not 2:
            say "[>console][CBD] ***Warning: Offsetting coordinates: [warp] is not a coordinate pair.[<]";
        if the number of entries of weft is not 2:
            say "[>console][CBD] ***Warning: Offsetting coordinates: [weft] is not a coordinate pair.[<]";
        #end if;
        let result1 be entry 1 of warp + entry 1 of weft;
        let result2 be entry 2 of warp + entry 2 of weft;
        let L be a list of numbers;
        Add result1 to L;
        Add result2 to L;
        decide on L.

    To decide which list of numbers is the canvas equivalent of the screen coordinates (X - a number) by (Y - a number) of (win - a g-window):
        let x-fixe be X as a fixed point number;
        let y-fixe be Y as a fixed point number;
        let x-fixe be (x-fixe real minus x-offset of win) real divided by the scaling factor of win;
        let y-fixe be (y-fixe real minus y-offset of win) real divided by the scaling factor of win;
        let L be a list of numbers;
        let L be {0, 0};
        now entry 1 of L is x-fixe as an integer;
        now entry 2 of L is y-fixe as an integer;
        decide on L;