Glimmr Canvas-Based Drawing

version 2/101030 by Erik Temple

  • Home page
  • Beginning
  • Previous
  • Next



  • Section - Centering algorithm for bitmaps

    To decide what list of numbers is the center-point of (item - a bitmap):
        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 the bitmap-width be the number of entries in entry 1 of the bitmap-array of the item;
        let dot-scale be (bit-size of the item * bitmap-width) as a fixed point number;
        unless the asymmetrical scaling option is active:
            let dx be the dot-scale real times the scaling factor of the item as an integer;
            let dy be the dot-scale real times the scaling factor of the item as an integer;
        otherwise:
            let dx be the dot-scale real times the x-scaling factor of the item as an integer;
            let dy be the dot-scale real times the y-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.