Creating pictures



  <picture id="pen">

  <picture id="checkerboard">

  <!-- ... -->


A picture's id attribute gives the label that the drawing instructions in the SXG file use to refer to this picture. A picture's type element specifies the picture's type. There are three picture types:


This creates a solid color picture.


This creates a text picture.


This creates a picture for a new pixmap. The picture uses the same pictformat as the main picture, creating a new pixmap of the appropriate depth.

A pixmap picture's size element calculates the pixmap's actual size. A pixmap has the same size element, too:


scaled is the default sizing type, if not specified. scaled pictures' pixmaps get scaled according to the main picture's size. This example specifies a 16x16 pixmap for this picture, with a 16x16 SXG file. With the picture's dimension matching the dimensions of the SXG file, this pictures' pixmap always gets scaled to match the scaled image's size.

If this SXG file gets scaled to a 32x32 image, this picture's pixmap's actual size also gets scaled accordingly. In this example, if the picture's width is 8, this always creates a pixmap for this picture that's half as wide as the main picture's pixmap.

The coordinates and dimensions given in a scaled picture's render commands also get scaled accordingly.


The picture's width and height elements specify a fixed picture size in pixels. The picture, and the coordinates for its render commands, do not get scaled.

fixed pictures get typically used to create pixel-specific rendering patterns.


Similar to fixed pictures, but the width and height specify the size of the picture in millimeters. The width and height can be fractional, but the final picture size gets rounded off to the nearest whole pixel size.

render command coordinates for mm picture get scaled accordingly. For example, a 10mm by 10mm picture's coordinates range from 0 and up to, but not including, 10. The coordinate (5, 5) is the center. If the display's resolution is 2.5 pixels per millimenter, the picture's pixmap's actual size is 25x25 pixels. Coordinates for the picture's rendering commands get scaled and rounded to the nearest pixel boundary, so the virtual coordinate (5, 5) gets scaled to the actual coordinate (13, 13), the center of the actual picture.


A special format that calculates the pixmap or the picture's size, and coordinates, based on scaled pseudo-millimeters. The scaling factors are based on the number of pixels per millimeter multiplied by factor (which defaults to 1), then rounded off to the nearest whole pixel value.

Example: the display's resolution is 4.5 pixels per millimeter, factor is .5, with a "10x10" picture or pixmap size. Multiplying 4.5*.5 gives 2.25, which gets rounded off to two pixels per "pseudo-millimeter", and the resulting image size becoms 20 pixels wide, and high.

If rounding off results in zero, this gets increased to one, so the result cannot be zero pixels per "pseudo-millimeter".

This is a convenient way to produce relatively small patterns that do not suffer from display artifacts due to rounding. Pixel coordinates can be fractional, but consider a small checkerboard-style pattern, with two columns and rows, defined by a pixmap or a picture object that's 1x1 millimeters in size, and a display with five pixels per millimeter. This may result in a visually-noticeable, uneven pattern of alternating two and three pixel-wide rows and columns.

Alternatively, using a mmrounded size with a factor of .5, the pixmap or picture's size can be specified as 2x2 rounded-off pseudo-millimeters, the final object size is guaranteed to have an even number of pixels.

A picture initial contents are cleared to a transparent background color (zero red, green, blue, and alpha channels).