Glimmr Canvas-Based Drawing

version 2/101030 by Erik Temple

  • Home page
  • Beginning
  • Previous
  • Next



  • Chapter - Sprite scaling rule

    An element scaling rule for a sprite (called the current-sprite) (this is the sprite scaling rule):
        unless the image-ID of current-sprite is Figure of Null:
            let sprite-ID be image-ID of current-sprite;
            let x-temp be the image-width of sprite-ID as a fixed point number;
            let y-temp be the image-height of sprite-ID as a fixed point number;
            unless the asymmetrical scaling option is active:
                now sprite-x is x-temp real times the scaling factor of current window real times the scaling factor of the current-sprite as an integer;
                now sprite-y is y-temp real times the scaling factor of current window real times the scaling factor of the current-sprite as an integer;
            otherwise:
                now sprite-x is x-temp real times the scaling factor of current window real times the x-scaling factor of the current-sprite as an integer;
                now sprite-y is y-temp real times the scaling factor of current window real times the y-scaling factor of the current-sprite as an integer;
            if current-sprite is center-aligned:
                now the win-x of current-sprite is win-x - (sprite-x) / 2;
                now the win-y of current-sprite is win-y - (sprite-y) / 2;
            if current-sprite is right-aligned:
                now the win-x of current-sprite is win-x - sprite-x;
                now the win-y of current-sprite is win-y - sprite-y;
        continue;