Glimmr Drawing Commands

version 2/101030 by Erik Temple

  • Home page
  • Beginning
  • Previous
  • Next



  • Section: Tileset image-maps

    As with direct image-maps, we supply an origin point (upper left corner), and in addition, we must supply the dimensions of the tiles. All tiles in the image-map will be rendered at the same size, though the images themselves can be of different sizes. If an image has a different aspect ratio from the tile, the image will be stretched to fit.

    Tileset image-maps also require us to specify a tileset which will be used to interpret the list of numbers we are providing. (A tileset is an object of the kind "tileset." It provides a table, the "translation-table" property of the tileset object, that keys a number to a figure name. The tileset object also specifies the dimensions (in pixels) of the tiles that will make it up. More about tilesets can be found below.)

    The list that specifies the image-map should only include digits that are listed in the tileset's translation table. If a digit isn't found there, the cell will be skipped and nothing will be drawn for that tile. To specify an empty tile, we can use 0.

    If we like, we may supply a background color for the image-map, which will draw a rectangle of the specified color before drawing the image-map tiles. For the short form, the "current background-color" global provides the color of the background rectangle ("current foreground-color" has no effect).

        display an image-map in <window> at <origin> using <list of numbers> using <tileset> with tile-size <width> by <height> pixels

        display an image-map in <window> at <origin> using <list of numbers> using <tileset> with tile-size <width> by <height> pixels and background <color>

    Long forms:

        display an image-map in the graphics-window at {5, 120} using {
            { 11, 11, 11, 11, 11, 11, 11 },
            { 05, 00, 00, 00, 00, 00, 00 },
            { 05, 00, 00, 00, 00, 00, 00 },
            { 11, 11, 11, 11, 11, 11, 11 } } rendered by the Dungeon-tileset with tile-size 16 by 16 pixels.

        display an image-map in the graphics-window at 5 by 120 using Hallway-definition rendered by the Dungeon-tileset with tile-size 16 by 16 pixels.

        display an image-map in the graphics-window at {5, 120} using Hallway-definition rendered by the Dungeon-tileset with tile-size 16 by 16 pixels and background (hex #A9A9A9).

    Tileset objects should provide default tile dimensions. To use these, we just access the "tile-width" and "tile-height" properties of the tileset object:

        let XX be the tile-width of the Dungeon-tileset;
        let YY be the tile-height of the Dungeon-tileset;
        display an image-map in the graphics-window at {5, 120} using 7 wide data from (Hallway-definition) rendered by the Dungeon-tileset with tile-size XX by YY pixels and background (hex #A9A9A9).

    Short forms:

        image-map {
                    { 11, 11, 11, 11, 11, 11, 11 },
                    { 05, 00, 00, 00, 00, 00, 00 },
                    { 05, 00, 00, 00, 00, 00, 00 },
                    { 11, 11, 11, 11, 11, 11, 11 } } at {5, 120} tileset (Dungeon-tileset) size 16 x 16.

        image-map Hallway-definition at {5, 120} tileset (Dungeon-tileset) size 16 x 16, backgrounded.

    Speed notes:

        Image-maps must display a number of images every time they are redrawn. Their speed is likely faster than drawin the images individually using the "draw image" command. They are likely to perform well in any interpreter that draws images quickly. Direct image-maps should theoretically draw slightly faster than tileset maps, but in practice the extra table-lookup required for tileset maps seems to make little noticeable difference.

        The same speed optimization techniques described for images (see above) apply also to image-maps.