Glimmr Canvas-Based Drawing

version 2/101030 by Erik Temple

  • Home page
  • Beginning
  • Previous
  • Next

  • Part - Converting between image-map, screen, and canvas coordinates

    Chapter - Converting image-map to canvas coordinates

    To decide what list of numbers is the canvas coordinate/coordinates/-- equivalent of (coord1 - a list of numbers) in the/-- 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 dx be (entry 1 of coord1 - 1) * imap-x;
        let dy be (entry 2 of coord1 - 1) * imap-y;
        let x1 be (entry 1 of the origin of grid) + dx;
        let y1 be (entry 2 of the origin of grid) + dy;
        let L be a list of numbers;
        add x1 to L;
        add y1 to L;
        decide on L.