Glimmr Canvas-Based Drawing

version 2/101030 by Erik Temple

  • Home page
  • Beginning
  • Previous
  • Next



  • Section - Point primitive

    A point primitive is a kind of primitive.

    The specification of point primitive is "A point primitive is a type of g-element. It draws a square centered on a coordinate specified using the 'origin' property. The coordinate pair is supplied using list formatting, e.g. {20, 10}. The color of the point is specified with the 'tint' property, a glulx color value (see the Glulx Text Effects extension). The size of the square is given using the 'line-weight' property; line weight of 1 pixel for example, will result in a square of a single pixel. The line-weight will be scaled along with the canvas; that is, if the line-weight is specified as 4 pixels wide and the canvas must be scaled to 50% to fit in the window, the actual displayed width of the line will be 2 pixels."

    A point primitive has a number called the line-weight. The line-weight of a point primitive is 1.

    [The stroke is a scaled value, presented in the coordinate system of the window rather than of the canvas. They are recalculated every time the window is redrawn and under most circumstances should not be specified by the author.]

    A point primitive has a number called the stroke. The stroke of a point primitive is 1.


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