Glimmr Canvas-Based Drawing

version 2/101030 by Erik Temple

  • Home page
  • Beginning
  • Previous
  • Next



  • Chapter - Bitmap base class

    A bitmap is a kind of g-element.

    The specification of bitmap is "A bitmap element draws a rectangular image composed of individual 'bits' that are specified by the author in the form of a list of lists of numbers (the 'bitmap-array') defining the status of each bit. For example, a cross might be specified like so:

    {
    { 0, 0, 1, 0, 0 },
    { 0, 0, 1, 0, 0 },
    { 1, 1, 1, 1, 1 },
    { 0, 0, 1, 0, 0 },
    { 0, 0, 1, 0, 0 } }.

    The ones represent bits that are turned on, while the zeros represent bits that are off. Note that each row is represented by its own list of numbers, and that we need to have the same number of entries in each row or errors will result.

    When image files such as PNGs or JPEGs are scaled, pixels can be interpolated so that the image file can be presented at virtually any scaling factor. However, the pixels of a bitmap element are set directly, and so the individual pixel is the primary unit of measurement. Thus, a bitmap displayed with a bit-size of 2 will be twice as wide and twice as high as the same bitmap displayed with a bit-size of 1. Glimmr will attempt to scale bitmaps to the canvas, but they cannot be scaled with the accuracy that sprites can be.

    There are two types of bitmaps: monochrome and polychrome bitmaps. In a monochrome bitmap, a maximum of two colors are allowed--all bits are either on or off. In a polychrome bitmap, the author can specify a full RGB color for each pixel. For both types, bits are rendered using the properties 'tint' (foreground color) and 'background tint' (background color)."

    A bitmap has a list of lists of numbers called the bitmap-array. The bitmap-array of a bitmap is {}.
    A bitmap has a glulx color value called the tint. The tint of a bitmap is g-White.
    A bitmap has a glulx color value called the background tint. The background tint of a bitmap is g-PlaceNullCol.
    A bitmap has a number called the bit-size. The bit-size of a bitmap is 1.
    [A bitmap has a number called the vertical ratio. The vertical ratio of a bitmap is 1.]

    [The dot-size is set automatically by the extension. Authors need not use it.]
    A bitmap has a number called the dot-size. The dot-size of a bitmap is 1.