wiki:DrawingCommands

Version 3 (modified by cinc, 12 years ago) (diff)

Correction for 'transl' command. Added color commands

Drawing Commands of the Icon Engine

Save/restore current context

<ctxt>save/restore</>

   Save and restore the current paint context.

The icon engine holds internal data defining the current colors, fonts, angle of rotation etc. Some paint commands alter this information in a global way. To preserve a set state the <ctxt> command can be used. It stores all the data on a stack and any changes will be reverted when issuing a <ctx>restore</>.
It is save to have several of these commands in a set of commands. Make sure every save has an associated restore.

See the Icon Tutorial for an example.

Moving paint position for images

<transl>x y</>

   Specify the position for the next image command.

X and y specify the position on the surface where subsequent painting will take place. 0.0 0.0 is the upper left corner. The values may run from 0.0 to 1.0.

See the Icon Tutorial for an example.

Note that for other drawing commands the position is set using <move></>.

Setting colors

<color>r g b</>

   Set the color to be used by the next command.

The values r, g and b are in the range 0.0 to 1.0. They form a final RGB value for the color.

Examples:

   0.2 0.2 0.2 : a light grey
   1.0 0.0 0.0 : pure red
    1   0   0  : same as before
   0.0 0.0 0.0 : black

<colora>r g b a</>

   Set the color and alpha to be used by the next command.

Same as the <color></> but you may specify the alpha. A value of a can be chosen between 0.0 to 1.

  a=1   : completely opaque
  a=0.0 : completely transparent (this means invisible)
  a=0.5 : 50% transparent

Sizing

<scale>xsize ysize</>

   Apply scaling to the next set of commands.

The values xsize and ysize are factors between 0.0 and 1.0. They specify the size of the items which will be painted afterwards. Note that this scaling is a global setting and will be applied to all paint commands which follow. Use <ctxt>save</> to save current scaling settings. Note that the factors usually have to be rather small. A value of 1.0 does not mean current icon size but is way bigger.

See the Icon Tutorial for an example.

Using Images

<imgkey>imgname # alpha</>

   Paint an image specified by the key 'imgname' on the current surface with an alpha level of 'alpha'.

This command will paint an image at the current position with the current scaling. The value of alpha may run from 0.0 to 1.0 where 1.0 means completely opaque while 0.0 means completely translucent. imgname is the name of a key in the ini file specifiying the image file to be used. The path is a relative one as known from the 'Image' key. Note that the spelling of the key is important and references to keys belonging to other icons are not possible.

See the Icon Tutorial for an example.