Glimmr Canvas-Based Drawing

version 2/101030 by Erik Temple

  • Home page
  • Beginning
  • Previous
  • Next

  • Section - Rectangle Primitive

    A rectangle primitive is a kind of primitive.

    The specification of rectangle primitive is "A rectangle primitive is a type of g-element, a simple rectangle of color. The rectangle is specified from an origin coordinate in the upper left corner to an endpoint in the lower right corner. These coordinate pair properties are each specified using list formatting, e.g. {20, 10}. The color of the rectangle, as with all primitives, is specified using the 'tint' property. The tint is specified as a glulx color value (see the Glulx Text Effects extension)."

    An element display rule for a rectangle primitive (called the rectangle):
        [if the rectangle is center-aligned:
            now the win-x of the rectangle is win-x - (end-x) / 2;
            now the win-y of the rectangle is win-y - (end-y) / 2;
        if the rectangle is right-aligned:
            now the win-x of the rectangle is win-x - end-x;
            now the win-y of the rectangle is win-y - end-y;]
        #if utilizing Glimmr debugging;
        say "[>console][CBD]Drawing rectangle primitive [i][rectangle][/i], color [color tint of rectangle], in [i][current window][/i] with upper left ([win-x], [win-y]) and lower right ([end-x], [end-y])[if the rectangle is graphlinked]. [line break][CBD]Graphlink corresponding to [i][rectangle][/i] set from ([win-x of rectangle], [win-y of rectangle]) to ([end-x], [end-y]): [quotation mark][linked replacement-command][quotation mark][end if].[<]";
        #end if;
        rectdraw (color tint of the rectangle) in (current window) from (win-x) by (win-y) to (end-x) by (end-y);
        if the rectangle is graphlinked:
            set a graphlink in the current window identified as the rectangle from win-x by win-y to end-x by end-y as the linked replacement-command of the rectangle.