Glimmr Canvas-Based Drawing

version 2/101030 by Erik Temple

  • Home page
  • Beginning
  • Previous
  • Next



  • Chapter - Converting canvas to image-map coordinates

    To decide what list of numbers is the equivalent of canvas coordinate/coordinates/-- (coord1 - a list of numbers) in the/-- internal/-- coordinates of (grid - an image-map) image-map/--:
        let imap-x be the desired tile-width of the grid;
        let imap-y be the desired tile-height of the grid;
        let x1 be entry 1 of the origin of the grid;
        let y1 be entry 2 of the origin of the grid;
        let x2 be entry 1 of coord1;
        let y2 be entry 2 of coord1;
        let dx be x2 - x1;
        let dy be y2 - y1;
        let dx be (dx / imap-x) + 1;
        let dy be (dy / imap-y) + 1;
        let L be a list of numbers;
        add dx to L;
        add dy to L;
        decide on L.