| 137 | |
| 138 | |
| 139 | == Drawing rectangles == |
| 140 | |
| 141 | The engine supports the drawing of rectangles with or without borders. |
| 142 | |
| 143 | === Defining the rectangle === |
| 144 | |
| 145 | {{{ |
| 146 | <rect>Xpos yPos width height</> |
| 147 | |
| 148 | Draw a rectangle at position 'Xpos/Ypos' with given 'height' and 'width'. |
| 149 | }}} |
| 150 | |
| 151 | Note that nothing is actually painted yet. You need to issue a ''<fill></>'' or ''<stroke></>'' command. |
| 152 | |
| 153 | |
| 154 | === Fill rectangle === |
| 155 | |
| 156 | {{{ |
| 157 | <fill></> |
| 158 | |
| 159 | Fill the rectangle with the set color. |
| 160 | }}} |
| 161 | |
| 162 | The color used is the one previously set using the ''<color>'' or ''<colora>'' commands like in this example: |
| 163 | |
| 164 | {{{ |
| 165 | <colora> 0 0.3 0.65 0.8</><rect>0.13 0.345 0.7 0.3</><fill></> |
| 166 | }}} |
| 167 | |
| 168 | === Draw outline rectangle === |
| 169 | |
| 170 | Similar to line drawing one has to issue the stroke command to actually draw the outline: |
| 171 | |
| 172 | {{{ |
| 173 | <stroke></> |
| 174 | |
| 175 | Do the actual drawing. |
| 176 | }}} |
| 177 | |
| 178 | or |
| 179 | |
| 180 | {{{ |
| 181 | <stroke>preserve</> |
| 182 | |
| 183 | Do the actual drawing but keep all line information in the context. |
| 184 | }}} |
| 185 | |
| 186 | Note that you have to define the line features prior to this command. You must at least specify the line width: |
| 187 | |
| 188 | {{{ |
| 189 | <colora> 0 0.3 0.65 0.8</><rect>0.13 0.345 0.7 0.3</><lwidth>0.05</><stroke></> |
| 190 | }}} |
| 191 | |
| 192 | |
| 193 | === Draw a filled rectangle with border === |
| 194 | |
| 195 | Combining the previous commands it is possible to draw rectangles with borders using any combination of color and line with. |
| 196 | |
| 197 | The following sequence of commands draws a rectangle with a blue semitransparent border filled with a solid grey color: |
| 198 | {{{ |
| 199 | <colora>0 0.3 0.65 0.8</><rect>0.13 0.345 0.7 0.3</><lwidth>0.05</><stroke>preserve</><color>0.5 0.5 0.5</><fill></> |
| 200 | }}} |
| 201 | |
| 202 | Note the use of ''<stroke>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. |
| 203 | |
| 204 | When using ''<stroke></>'' here only the border is drawn because there is no definition for any shape when the ''<fill></>' command is encountered. |