Glimmr Canvas-Based Drawing

version 2/101030 by Erik Temple

  • Home page
  • Beginning
  • Previous
  • Next



  • Section - Centering algorithm for image-rendered strings

    To decide what list of numbers is the center-point of (item - a image-rendered string):
        let dx be a number;
        let dy be a number;
        let x be entry 1 of the origin of item;
        let y be entry 2 of the origin of item;
        let string-width be length of the item plus (2 * background-margin of the associated font of the item) as a fixed point number;
        let string-height be font-height of the associated font of the item plus (2 * background-margin of the associated font of the item) as a fixed point number;
        unless the asymmetrical scaling option is active:
            let dx be the string-width real times the scaling factor of the item as an integer;
            let dy be the string-height real times the scaling factor of the item as an integer;
        otherwise:
            let dx be the string-width real times the x-scaling factor of the item as an integer;
            let dy be the string-height real times the x-scaling factor of the item as an integer;
        let x be x + (dx / 2);
        let y be y + (dy / 2);
        let coord be {0, 0};
        now entry 1 of coord is x;
        now entry 2 of coord is y;
        decide on coord.