= Drawing Commands of the Icon Engine = == Save/restore current context == {{{ 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 '''' command can be used. It stores all the data on a stack and any changes will be reverted when issuing a ''restore''.[[BR]] It is save to have several of these commands in a set of commands. Make sure every '''save''' has an associated '''restore'''. See the [IconTutorial Icon Tutorial] for an example. == Setting colors == {{{ 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 }}} ---- {{{ r g b a Set the color and alpha to be used by the next command. }}} Same as the '''' 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 }}} == Move the drawing position == {{{ Xpos Ypos Move to the position ''xpos/yPos'' on the current surface. }}} This command specifies the position where the next drawing command will take place. The command may be drawing of an rectangle, a line, text or something else. == Drawing a line == For drawing a line one has to perform a sequence of commands: * Move to the start position using ''Xpos Ypos'' * Set the line width using ''width'' * Optionally specify how to paint line endpoints using '''' * Set the end point using 'toX toY'' * Finally drawing the line using '''' For example: {{{ 0.5 0.5 0.90.050.1 0.30.8 0.9 }}} The commands will be described in detail in the following paragraphs. === Set line width === {{{ width Set the width for subsequently drawn lines. }}} The value may range from 0.0 to 1.0. === Set the shape of the lines end point === {{{ style Draw the end point of a line using ''style''. }}} The parameter ''style'' may be one of: {{{ round: the line start/end point is rounded with the center of the circle specified by the given x/y position square: the line start or end point is a square with the center specified by the given x/y point butt: the line starts and ends exactly at the specified positions }}} === Set next line point === {{{ toX toY Draw a line from the current position to toX/toY. }}} === Perform the line drawing === There are two commands doing the actual drawing of the line. {{{ Do the actual drawing. }}} Using '''' all information about the painted path (start position, line segments, width etc.) is cleared from the curent context. This means for example one has to issue a new ''move'' command prior to any more line drawing. {{{ preserve Do the actual drawing but keep all line information in the context. }}} ''preserve'' will keep all the path information in the drawing context. Subsequent drawing will take place at the last position specified by one of the drawing commands. It is possible to do several ''move'' and ''line'' commands on a surface. The actual drawing only takes place when performing the ''stroke'' command. == Drawing rectangles == The engine supports the drawing of rectangles with or without borders. === Defining the rectangle === {{{ Xpos yPos width height Draw a rectangle at position 'Xpos/Ypos' with given 'height' and 'width'. }}} Note that nothing is actually painted yet. You need to issue a '''' or '''' command. === Fill rectangle === {{{ Fill the rectangle with the set color. }}} The color used is the one previously set using the '''' or '''' commands like in this example: {{{ 0 0.3 0.65 0.80.13 0.345 0.7 0.3 }}} === Draw outline rectangle === Similar to line drawing one has to issue the stroke command to actually draw the outline: {{{ Do the actual drawing. }}} or {{{ preserve Do the actual drawing but keep all line information in the context. }}} Note that you have to define the line features prior to this command. You must at least specify the line width: {{{ 0 0.3 0.65 0.80.13 0.345 0.7 0.30.05 }}} === Draw a filled rectangle with border === Combining the previous commands it is possible to draw rectangles with borders using any combination of color and line with. The following sequence of commands draws a rectangle with a blue semitransparent border filled with a solid grey color: {{{ 0 0.3 0.65 0.80.13 0.345 0.7 0.30.05preserve0.5 0.5 0.5 }}} Note the use of ''preserve'' here. This way the information about the rectangle's shape is kept in the current drawing context after drawing the border and the fill command is applied to the same shape. When using '''' here only the border is drawn because there is no definition for any shape when the ''' command is encountered. == Using Images == Painting of images is done with some special commands described here. === Moving paint position for images === {{{ 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 [IconTutorial Icon Tutorial] for an example. Note that for other drawing commands the position is set using ''''. === Sizing the image === {{{ 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 ''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 [IconTutorial Icon Tutorial] for an example. === Painting the image === {{{ 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 [IconTutorial Icon Tutorial] for an example.