| HWimage Template Example 2 |
Zone Template (zone.txt)
The zone 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 zone forecast images seen in the basic mode. 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 300 200
#
# Now we put in the general info
textsize MEDIUM
textcolor RGB 0 0 255
textat center 2 "Forecast For"
textat center 18 "%%lcplace%%, %%lcstate%%"
# if forecast is unavail lets do unavail routine
dounavail
# other wise keep going
textsize TINY
textcolor RGB 0 0 0
textat center 34 "Dated: %%forecastdate%%"
textwrap 11
#
let hwvxoffset {$hwvdays = %%num_zone_days%% +0; $hwvdays=4 if ($hwvdays > 4); (4-$hwvdays) * 40+40; }
# Now lets display the 4th icon/day & condition. If the weather for this day
# does not exist nothing will show up because it willbe off the right side
# of the image
textsize MEDIUM
textat { 225 +%%hwvxoffset%% } 50 "%%day_title4%%" CENTER
image { 225 +%%hwvxoffset%% } 82 %%day_icon4%% CENTER
textsize SMALL
textat { 225 +%%hwvxoffset%% } 147 "%%day_weather4%%" SPACEWRAPCENTER
textsize TINY
textat { 225 +%%hwvxoffset%% } 175 "%%day_temps4%%" SPACEWRAPCENTER
#
# Now lets display the 3rd icon/day & condition.
textsize MEDIUM
textat { 150 +%%hwvxoffset%% } 50 "%%day_title3%%" CENTER
image { 150 +%%hwvxoffset%% } 82 %%day_icon3%% CENTER
textsize SMALL
textat { 150 +%%hwvxoffset%% } 147 "%%day_weather3%%" SPACEWRAPCENTER
textsize TINY
textat { 150 +%%hwvxoffset%% } 175 "%%day_temps3%%" SPACEWRAPCENTER
#
# Now lets display the 2nd icon/day & condition.
textsize MEDIUM
textat { 75 +%%hwvxoffset%% } 50 "%%day_title2%%" CENTER
image { 75 +%%hwvxoffset%% } 82 %%day_icon2%% CENTER
textsize SMALL
textat { 75 +%%hwvxoffset%% } 147 "%%day_weather2%%" SPACEWRAPCENTER
textsize TINY
textat { 75 +%%hwvxoffset%% } 175 "%%day_temps2%%" SPACEWRAPCENTER
#
# Now lets display the 1st icon/day & condition.
textsize MEDIUM
textat %%hwvxoffset%% 50 "%%day_title1%%" CENTER
image %%hwvxoffset%% 82 %%day_icon1%% CENTER
textsize SMALL
textat %%hwvxoffset%% 147 "%%day_weather1%%" SPACEWRAPCENTER
textsize TINY
textat %%hwvxoffset%% 175 "%%day_temps1%%" SPACEWRAPCENTER
end
unavailstart
textcolor RGB 0 0 0
textsize LARGE
textat center 60 "The Forecast is Unavailable"
end
|
| Line | Description |
| size 300 200 | Set the initial image size to a width of 300 and height of 200 |
| # Now we put in the general info | This is just a remark line, any line beginning with the pound sign (#) is just a remark and is ignored by HWimage. |
| textsize MEDIUM | Set the text size to medium (7x13) which is also bold. |
| textcolor RGB 0 0 255 | Sets the color to write text to the RGB color codes 0 0 255 (blue). this could have
also been written as textcolor BLUE or even textcolor RGBH 0000FF |
| textat center 2 "Forecast For" | Place the text "Forecast For" on the y axis at point 2 and center the text on the x axis for the image. |
| textat center 18 "%%lcplace%%, %%lcstate%%" | Tells HWimage to place the text 'place, state' on the y axis at point 2 and center the text on the x axis for the image. The %%lcplace%% and %%lcstate%% template variables will be replaced with the actual variables before the text is added. |
| 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 TINY | Sets the text size to small (5X8). |
| textcolor RGB 0 0 0 | Sets the color to write text to the RGB color codes 0 0 0 (black). this could have
also been written as textcolor BLACK or even textcolor RGBH 000000 |
| textat center 34 "Dated: %%forecastdate%%" | Tells HWimage to place the text 'Dated: forecastdate' on the y axis at point 2 and center the text on the x axis for the image. The %%forecastdate%% template variables will be replaced with the actual variables before the text is added. |
| textwrap 11 | Sets text wrapping to 11 characters. So if future textat command the text will auto wrap at 11 characters |
| let hwvxoffset {$hwvdays = %%num_zone_days%% +0; $hwvdays=4 if ($hwvdays > 4); (4-$hwvdays) * 40+40; } | Here we are setting a user defined variable to the x offset. This is used to center
the zone forecast in the graphic in case there are less than for 'days' of icons. In
this line we use the feature in HWimage that allows you to insert short bits of perl code
to calculate values. Where the last value set is the value returned to HWimage. This
method was used to handle installations which may have max days set to a higher number
than 4. If your server has max days set to four you could easily change this line to
: let hwvxoffset { (4-(%%num_zone_days%% + 0)) * 40 + 40 } |
| # Now lets display the 4th icon/day & condition. | This is a remark that is ignored but labels the beginning of the insertion of the data for the 4th day. If there is no data for the 4th day then the data will be inserted off the right edge of the screen thus producing nothing on the output (a nice little trick) |
| textsize MEDIUM | Set the text size to medium (7x13) which is also bold. |
| textat { 225 +%%hwvxoffset%% } 50 "%%day_title4%%" CENTER | Place the Day Title for the 4th icon at position (225 + the hwvxoffset, 50) and center the text at this position. Also remember that the text will be wrapped at every eleven characters max because we set the word wrapping to 11 earlier. |
| image { 225 +%%hwvxoffset%% } 82 %%day_icon4%% CENTER | Insert the Icon for the 4th day weather at position (225 + the hwvxoffset, 82) and center the image on the x axis at this position. |
| textsize SMALL | Sets the text size to small (6x12). |
| textat { 225 +%%hwvxoffset%% } 147 "%%day_weather4%%" SPACEWRAPCENTER | Place the day for weather condition text at position (225 + hwvoffset, 147) and wrap the text at every space and center each line of text on the x position. |
| textsize TINY | Sets the text size to small (5X8). |
| textat { 225 +%%hwvxoffset%% } 175 "%%day_temps4%%" SPACEWRAPCENTER | Place the day for temperature text(if available) at position (225 + hwvoffset, 147) and wrap the text at every space and center each line of text on the x position. |
| ........ | The above 8 lines are repeated for icons 3 , 2 and 1 just the x positions is slightly different. We will skip down to the end of the image. |
| 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. |
| textcolor RGB 0 0 0 | Sets the color to write text to the RGB color codes 0 0 0 (black). this could have
also been written as textcolor BLACK or even textcolor RGBH 000000 |
| textsize LARGE | Sets the text size to large (8x16). |
| textat 65 15 "Current Conditions Unavailable" SPACEWRAPLEFT | Display 'Current Conditions Unavailable' starting at position (65, 15). The text will be auto wrapped at each space, thus there will be three lines and each line will be left justified to the y position of 15. |
| 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.