| HWimage Template Example 3 |
Weather Station Template (ws.txt)
The weather station template included in the HWimage build creates images that look similar to :

Below is an example of the template file that can be used with HWimage in advanced
mode, with explanations of what each line is doing. This actual template is included
in the build and can be used to create the weather station look. This template
is a bit more complicated but shows the power of what can be done with HWimage templates.
For a complete list of the HWimage template commands visit the Template Command Page and for information about the general syntax of the HWimage templates visit the Template Syntax page.
Following the template you will find a line by line explanation. (Note: The coloring is added only for visibility):
size 400 300
image 0 0 hwitemplates/ws.gif
textsize MEDIUM
textcolor RGB 255 255 255
textat 291 95 "%%hsky%%" SPACEWRAPCENTER
textsize GIANT
textcolor RGB 255 255 0
textwrap 25
textat 125 40 "%%lcplace%%, %%state%%" CENTER
# if forecast is unavail lets do unavail routine
dounavail
# other wise keep going
textsize SMALL
textwrap 39
textcolor RGB 255 255 255
textat 125 80 {substr("%%day_forecast1%% ",0, 100)} CENTER
textwrap 0
textcolor RGB 255 255 0
textat 15 280 "Dated: %%hforecastdate%%"
textsize MEDIUM
textat 372 42 "%%htempf%%°F" CENTER
textsize GIANT
textat 68 148 "%%hrh%%%" CENTER
textat 173 148 "%%hpressure%%" CENTER
textat 281 148 "%%hwind%%" CENTER
drawcolor RGB 255 0 0
drawwidth 3
line 382 {265-int((%%htempf%%+50)*1.166)} 382 265
#
drawwidth 2
let hwvd2r {atan2(1,1) / 45}
#
let hwvx {67 + int(0.5 + 45 * cos((%%hrh%%*2.2 - 200) * %%hwvd2r%%))}
let hwvy {218 + int(0.5 + 45 * sin((%%hrh%%*2.2 - 200) * %%hwvd2r%%))}
line 67 218 %%hwvx%% %%hwvy%%
image 60 211 hwitemplates/ws_circle.gif
#
let hwvpressure {substr("%%hpressure%%",0,5)-27}
let hwvx {175 + int(0.5+ 45 *cos((%%hwvpressure%%*66.25 - 245) *%%hwvd2r%%))}
let hwvy {218 + int(0.5 + 45 * sin((%%hwvpressure%%*66.25 - 245) * %%hwvd2r%%))}
line 175 218 %%hwvx%% %%hwvy%%
image 168 211 hwitemplates/ws_circle.gif
#
let hwvx {281 + int(0.5+ 45 *cos((%%hwind_val%%*4.42 - 245) *%%hwvd2r%%))}
let hwvy {218 + int(0.5 + 45 * sin((%%hwind_val%%*4.42 - 245) * %%hwvd2r%%))}
line 281 218 %%hwvx%% %%hwvy%%
image 274 211 hwitemplates/ws_circle.gif
#
image 264 29 %%hicon_path%%
end
#
unavailstart
textsize SMALL
textwrap 39
textcolor RGB 255 255 255
textat 125 80 "Weather Information Unavailable" CENTER
image 264 29 hwitemplates/na.gif
end
|
| Line | Description |
| size 400 300 | Set the initial image size to a width of 400 and height of 300 |
| image 0 0 hwitemplates/ws.gif | Load up the 'base' image to build upon. Note that for the image path you can provide the complete path name or if the image is in the hwitemplates directory you can simply provide a name similar to the one given. |
| textsize MEDIUM | Set the text size to medium (7x13) which is also bold. |
| textcolor RGB 255 255 255 | Sets the color to write text to the RGB color codes 255 255 255 (white). this could
have also been written as textcolor WHITE or even textcolor RGBH FFFFFF |
| textat 291 95 "%%hsky%%" SPACEWRAPCENTER | Place the current sky condition text at the location (291, 95) and wrap the text at every space while centering each line of text on the x axis coordinate. |
| textsize GIANT | Set the text size to medium (9x15) . |
| textcolor RGB 255 255 0 | Sets the color to write text to the RGB color codes 255 255 0 (yellow). this could
have also been written as textcolor YELLOW or even textcolor RGBH FFFF00 |
| textwrap 25 | Sets text wrapping to 25 characters. So in future textat command the text will auto wrap at 25 characters max. (BTW HWimage will handle spacing properly. |
| textat 125 40 "%%lcplace%%, %%state%%" CENTER | Tells HWimage to place the text 'place, state' oat the position (125, 40) and to center the text on the x axis coordinate. The %%lcplace%% and %%lcstate%% template variables will be replaced with the actual variables before the text is added. |
| # if forecast is unavail lets do unavail routine | This is just a remark line, any line beginning with the pound sign (#) is just a remark and is ignored by HWimage. |
| dounavail | This tells HWimage that is the current conditions requested were unavailable then to skip down to the unavailstart command and begin parsing there. If the conditions were available then it continues with the next line in the template. This allows us to display a proper unavailable message. |
| textsize SMALL | Sets the text size to small (6x12). |
| textwrap 39 | Sets text wrapping to 39 characters. So in future textat command the text will auto wrap at 39 characters max. (BTW HWimage will handle spacing properly. |
| textcolor RGB 255 255 255 | Sets the color to write text to the RGB color codes 255 255 255 (white). this could
have also been written as textcolor WHITE or even textcolor RGBH FFFFFF |
| textat 125 80 {substr("%%day_forecast1%% ",0, 100)} CENTER | Place the forecast text for the current day at position (125, 80). Remember that text
wrap was set to 39 so we will wrap the text at every 39 characters max and center each
line of text on the x axis coordinate of 125. The portion 'substr("%%day_forecast1%%",0, 100)' uses the feature of HWimage to allow for small segments of perl code to be inserted to obtain a value. In this case we are using ht perl substr command to limit the text of the forecast to only the first 100 characters, this is because we only have 3 lines available for forecast text. |
| textwrap 0 | Sets text wrapping to 0, thus turning off text wrapping. |
| textcolor RGB 255 255 0 | Sets the color to write text to the RGB color codes 255 255 0 (yellow). this could
have also been written as textcolor YELLOW or even textcolor RGBH FFFF00 |
| textat 15 280 "Dated: %%hforecastdate%%" | Place the text "Dated: forecastdate" at position (15, 280). The template variable %%hforecastdate%% will be replaced by the current conditions forecast date when creating the image. |
| textsize MEDIUM | Set the text size to medium (7x13) which is also bold. |
| textat 372 42 "%%htempf%%°F" CENTER | Place the current temp text at position (372, 42) and center the text on the x axis coordinate. The template variable %%htempf%% will be replaced by the correct value when creating the image. |
| textsize GIANT | Set the text size to medium (9x15) . |
| textat 68 148 "%%hrh%%%" CENTER | Place the relative humidity text at at position (68, 148) and center the text on the x axis coordinate. The template variable %%hrh%% will be replaced by the correct value when creating the image. |
| textat 173 148 "%%hpressure%%" CENTER | Place the pressure text at at position (173, 148) and center the text on the x axis coordinate. The template variable %%hpressure%% will be replaced by the correct value when creating the image. |
| textat 281 148 "%%hwind%%" CENTER | Place the pressure text at at position (281, 148) and center the text on the x axis coordinate. The template variable %%hwind%% will be replaced by the correct value when creating the image. |
| drawcolor RGB 255 0 0 | Set the drawing color to the RGB color codes 255 0 0 (red). this could have also been
written as drawcolor RED or even drawcolor RGBH FF0000 |
| drawwidth 3 | Set the width for drawing to 3 pixels |
| line 382 {265-int((%%htempf%%+50)*1.166)} 382 265 | Here we are drawing the red line in the thermometer. With the line command we provide the start (x,y) coordinate and the end (x.y) coordinate. For the thermometer the end is at position (382, 265) but the start is y position calculated from the current temperature value. |
| drawwidth 2 | Set the width for drawing to 2 pixels |
| let hwvd2r {atan2(1,1) / 45} | Set the user variable hwvd2r to a value to be used in future calculations to draw the red lines in the dials |
| let hwvx {67 + int(0.5 + 45 * cos((%%hrh%%*2.2 - 200) * %%hwvd2r%%))} | Set the user defined variable 'hwvx' to the value of the x coordinate to draw the red line in the Relative humidity dial to. The template variables %%hrh%% and %%hwvd2r%% will be replaced by their correct values during the image creation. |
| let hwvy {218 + int(0.5 + 45 * sin((%%hrh%%*2.2 - 200) * %%hwvd2r%%))} | Set the user defined variable 'hwvy' to the value of the y coordinate to draw the red line in the Relative humidity dial to. The template variables %%hrh%% and %%hwvd2r%% will be replaced by their correct values during the image creation. |
| line 67 218 %%hwvx%% %%hwvy%% | Draw the red dial line in the Relative Humidity dial from the center to the calculated (hwvx, hwvy) coordinates. (Note that standard geometry is used to compute the hwvx and hwvy values. |
| image 60 211 hwitemplates/ws_circle.gif | Insert the 'center cap' image into the center of the dial. Note that for the image path you can provide the complete path name or if the image is in the hwitemplates directory you can simply provide a name similar to the one given. |
| let hwvpressure {substr("%%hpressure%%",0,5)-27} | Set the user variable 'hwvpressure' to the current pressure value - 27, so that our
value is a number between 0 and 4 instead of 27 and 31. The portion 'substr("%%hpressure%%",0,5)-27' uses the feature of HWimage to allow for small segments of perl code to be inserted to obtain a value. In this case we are using the perl substr command to obtain only the value of the pressure and leave off any text that may be added. |
| let hwvx {175 + int(0.5+ 45 *cos((%%hwvpressure%%*66.25 - 245) *%%hwvd2r%%))} | Set the user defined variable 'hwvx' to the value of the x coordinate to draw the red line in the Pressure humidity dial to. The template variables %%hpressure%% and %%hwvd2r%% will be replaced by their correct values during the image creation. |
| let hwvy {218 + int(0.5 + 45 * sin((%%hwvpressure%%*66.25 - 245) * %%hwvd2r%%))} | Set the user defined variable 'hwvy' to the value of the y coordinate to draw the red line in the Pressure humidity dial to. The template variables %%hpressure%% and %%hwvd2r%% will be replaced by their correct values during the image creation. |
| line 175 218 %%hwvx%% %%hwvy%% | Draw the red dial line in the Pressure dial from the center to the calculated (hwvx, hwvy) coordinates. (Note that standard geometry is used to compute the hwvx and hwvy values. |
| image 168 211 hwitemplates/ws_circle.gif | Insert the 'center cap' image into the center of the dial. Note that for the image path you can provide the complete path name or if the image is in the hwitemplates directory you can simply provide a name similar to the one given. |
| let hwvx {281 + int(0.5+ 45 *cos((%%hwind_val%%*4.42 - 245) *%%hwvd2r%%))} | Set the user defined variable 'hwvx' to the value of the x coordinate to draw the red line in the Wind speed humidity dial to. The template variables %%hwind_val%% and %%hwvd2r%% will be replaced by their correct values during the image creation. |
| let hwvy {218 + int(0.5 + 45 * sin((%%hwind_val%%*4.42 - 245) * %%hwvd2r%%))} | Set the user defined variable 'hwvy' to the value of the y coordinate to draw the red line in the Wind speed humidity dial to. The template variables %%hwind_val%% and %%hwvd2r%% will be replaced by their correct values during the image creation. |
| line 281 218 %%hwvx%% %%hwvy%% | Draw the red dial line in the Wind Speed dial from the center to the calculated (hwvx, hwvy) coordinates. (Note that standard geometry is used to compute the hwvx and hwvy values. |
| image 274 211 hwitemplates/ws_circle.gif | Insert the 'center cap' image into the center of the dial. Note that for the image path you can provide the complete path name or if the image is in the hwitemplates directory you can simply provide a name similar to the one given. |
| image 264 29 %%hicon_path%% | Insert the current condition icon into position (264, 29) |
| end | End the current image. |
| unavailstart | This command lets HWimage know where the weather info unavail commands start in the template and is accessed when the dounavail command is found. |
| textsize SMALL | Sets the text size to small (6x12). |
| textwrap 39 | Sets text wrapping to 39 characters. So in future textat command the text will auto wrap at 39 characters max. (BTW HWimage will handle spacing properly. |
| textcolor RGB 255 255 255 | Sets the color to write text to the RGB color codes 255 255 255 (white). this could
have also been written as textcolor WHITE or even textcolor RGBH FFFFFF |
| textat 125 80 "Weather Information Unavailable" CENTER | Tells HWimage to place the text 'Weather Information Unavailable' oat the position (125, 80) and to center the text on the x axis coordinate. |
| image 264 29 hwitemplates/na.gif | Insert the not available icon into position (264, 29). I |
| end | End the current image. |
For a complete list of the HWimage template commands visit the Template Command Page and for information about the general syntax of the HWimage templates visit the Template Syntax page.