HWimage Template Commands

Click on the template command name to view description of command.

BACKGROUND LOADIMAGE
DOUNAVAIL LOADVARS
DRAWCOLOR NOCACHE
DRAWWIDTH RECTANGLE
END SAVEVARS
FILL SIZE
FILLCOLOR TEXTAT
KILLIMAGE TEXTCOLOR
IMAGE TEXTSIZE
LET TEXTWRAP
LIB UNAVAILSTART
LINE

BACKGROUND

    BACKGROUND colorspec

Sets the background color to the given colorspec. The default background color is white.

Examples:

    BACKGROUND WHITE
    BACKGROUND RGB 255 255 255 
    BACKGROUND RGBH FF FF FF

Back to top


DOUNAVAIL

    DOUNVAIL

If the forecast was unavailable then this command tells HWimage to skip the following command until the UNAVAILSTART command is reached, at which point HWimage should start processing commands again. If the forecast was available then this command is ignored and HWimage will continue processing command normally.

This command is used as an error trap in case the forecast was unavailable, you can politely let the user know.

Example:

    DOUNAVAIL

Back to top 

DRAWCOLOR

    DRAWCOLOR colorspec

Sets the color used to draw with to the given colorspec. The default drawcolor color is black.

Examples:

    DRAWCOLOR WHITE
    DRAWCOLOR RGB 255 255 255 
    DRAWCOLOR RGBH FF FF FF
Back to top 

DRAWWIDTH

    DRAWWIDTH width

Sets the width to use when drawing lines. The default drawwidth is one pixel.

Example:

    DRAWWIDTH 2

Back to top 

END

    END

Tells HWimage to end the drawing of the current image. This is command is not needed. HWimage will end normally at the end of the template.  The end command is often placed on the line before the UNAVAILSTART command, to show that HWimage will stop drawing if the forecast was available, but continue drawing if it were not. (Again it is not needed, but allows for better template clarity.)

Example:

    END

Back to top 

FILL

    FILL x y

Flood-fills a region that contains the point with coordinates (x, y). The region is filled with the color specified by the FILLCOLOR command.  The default FILLCOLOR is black.

Example:

    FILL 25 25

Back to top 

FILLCOLOR

    FILLCOLOR colorspec

Sets the color used to flood-fill a region, when using the FILL command,  to the given colorspec. The default fillcolor color is black.

Examples:

    FILLCOLOR WHITE
    FILLCOLOR RGB 255 255 255 
    FILLCOLOR RGBH FF FF FF
Back to top 

IMAGE (Being replaced by LOADIMAGE)

    IMAGE x y filename [halign]

NOTE:  This command is being replaced by the LOADIMAGE command, which is basically the same but with more functionality.  The IMAGE command is still supported for backward compatability.

Inputs the image named  "filename" into the current image at the location specified by the (x, y) coordinate. X must be an integer or the word center. If x equals 'center' then the imported image will be centered on the x (horizontal) axis.

The halign parameter can be either LEFT, CENTER or RIGHT.  If LEFT is specified then the top left corner of the imported image will be at the (X, Y) coordinate.  If RIGHT then the top right corner of the imported image will be at the (X, Y) coordinate.   If CENTER then the imported image will be centered on the (X, Y) coordinate.   If the halign parameter is not specified then 'LEFT' is assumed by default.

Note:  The image to be imported must be a gif image.

Examples:

    IMAGE 25 25 ex1.gif
    IMAGE 25 25 ex1.gif RIGHT

Back to top 

KILLIMAGE

    KILLIMAGE

Kills the image that is currently being worked on and also ends the parsing of the current image file and then nothing is outputted.  If this command is used in conjunction with a web browser it will result in a broken image, thus it is normally only used when running HWimage from a command line (telnet or cronjob).  Can be useful to keep HWimage from overwriting a previous image if the weather data is unavailable.

Examples:

    KILLIMAGE

Back to top 

LET

    LET variablename value

Sets the variable named in 'variablename' to the value specified.

Variables use the same syntax as used with HAMweather Variables in normal HAMweather usage.  They variable name should start with the letters 'hwv'  if they do not HWimage will automatically add the letter to the front of the variable name.  As with normal HAMweather Variables to insert the variables value in elsewhere in the template simply add %%variablename%% where you want the variables value to be inserted.

Examples:

    LET hwvx 25 
    LET hwvycoord 50 
    LET hwvy %%hwvx%%
    LET hwvx {atan2(1,1) / 45} 
    LET hwvx { %%hwvx%% + 1 }

Back to top 

LIB

    LIB libname

Tells HWimage to load the HWimage extension library file name by libname.

The lib command can be used to add additional functionality to HWimage by adding additional commands for use by your templates.  Keep a look out in the future for additional HWimage extension libraries to be released. (One such extension could offer control commands, such as IF...THEN...ELSE, FOR loops and WHILE loops.

Examples:

    LIB control

Back to top 

LINE

    LINE X1 Y1 X2 Y2

Tells HWimage to draw a line from the (X1, Y1) coordinate to the (X2, Y2) coordinate.

The color of the line drawn is determined by he DRAWCOLOR and the width is determined by he DRAWWIDTH.

Examples:

    LINE 0 0 100 50
    LINE 382 {265-int((%%htempf%%+50)*1.166)} 382 265 

Back to top 

LOADIMAGE

    LOADIMAGE x y filename [halign] [resize width] [resize height]

Inputs the image named  "filename" into the current image at the location specified by the (x, y) coordinate. X must be an integer or the word center. If x equals 'center' then the imported image will be centered on the x (horizontal) axis.  

The halign parameter can be either LEFT, CENTER or RIGHT.  If LEFT is specified then the top left corner of the imported image will be at the (X, Y) coordinate.  If RIGHT then the top right corner of the imported image will be at the (X, Y) coordinate.   If CENTER then the imported image will be centered on the (X, Y) coordinate.   If the halign parameter is not specified then 'LEFT' is assumed by default.

If the [resize width] and [resize height] are provided, then the imported image will be resized to the size specified before being imported into the main image.

Note:  The image to be imported must be a gif image.

Examples:

    LOADIMAGE 25 25 ex1.gif
    LOADIMAGE 25 25 ex1.gif RIGHT
    LOADIMAGE 25 25 ex1.gif RIGHT 50 75

Back to top 

LOADVARS (Implemented as of HWimage 1.04)

    LOADVARS varfilename 

Tells HWimage to load up previously saved user variables. If the varfilename is specified then this file will be used to obtain the variables.  The filename shoud leb alphanumeric such as "myvars" etc. HAMweather loads these inthe "hwitemplates/hwv" directory/

Examples:

    LOADVARS oldvarfilename

Back to top 

NOCACHE

    NOCACHE

Tells HWimage not to save the current image in the cache once it is completed.   This is useful to keep HWimage from caching an image during development, yet allowing HWimage to keep caching other images.

Examples:

    NOCACHE

Back to top 

RECTANGLE

    RECTANGLE X1 Y1 X2 Y2

Tells HWimage draw a rectangle with the top left corner being at the (X1, Y1) coordinate and the bottom right corner being at the (X2, Y2) coordinate.

If border color of the rectangle is determined by the DRAWCOLOR and the border width is determined by the DRAWWIDTH.

If the FILLCOLOR has been defined then the rectangle will be filled with this color.

Examples:

    RECTANGLE 10 10 200 50
    RECTANGLE 10 10 {10 + %%hwvwidth%%} {10 + %%hwvheight%%}

Back to top 

SAVEVARS (Implemented as of HWimage 1.04)

    SAVEVARS varfilename variablename1 variablename2 ...

Tells HWimage to save the current user variables.  you specify the name of the file to save them too.  The filename shoudl be alphanumeric only such as "myvars".

You must also declare what variables you want to save. If you want to save all the user variables then in the variablename1 position simply use the word 'all'.  To define only certain variables to save place the variable names (without any percent signs) after the varfilename, separating each one with a space.  Remember, user variables must begin with the letters 'hwv' if they do not then HWimage will add this to them automatically.

Examples:

    SAVEVARS default all
    SAVEVARS default hwvx hwvy
    SAVEVARS blacksburgvars all
    SAVEVARS blacksburgvars hwvx hwvy

Back to top 

SIZE

    SIZE width height [resize]

Defines the size of the current image.  This is often the first line of a template.  The default size is 100 x 100 pixels.

If the word 'resize' is added then the current image will be resized to the new size parameters.

Examples:

    SIZE 200 150
    SIZE 200 150 resize

Back to top 

TEXTAT

    TEXTAT x y "text" [halign]

Places the "text" in the image starting at the (X,Y) coordinate. X must be an integer or the word center. If x equals 'center' then the text will be centered on the x (horizontal) axis.

The halign parameter is optional and can be any of the values in the table below. If not given then it is assumed to be LEFT.

HALIGN Parameter Description
CENTER The text is centered on the X coordinate.
(Same as putting the word 'center' as the x coordinate)
LEFT The text is left justified on the X coordinate.
RIGHT The text is Right justified on the X coordinate.
SPACEWRAPCENTER The text is centered on the X coordinate, but the text will auto wrap downward at each space in the text.
SPACEWRAPLEFT The text is left justified on the X coordinate, but the text will auto wrap downward at each space in the text.
SPACEWRAPRIGHT The text is right justified on the X coordinate, but the text will auto wrap downward at each space in the text.


Examples:

    TEXTAT 0 0 "This is text"
    TEXTAT center 0 "This is text"
    TEXTAT 50 25 "This is text" CENTER
    TEXTAT center 0 "%%hwvtext%%"

Back to top 

TEXTCOLOR

    TEXTCOLOR colorspec

Sets the color used to draw text with to the given colorspec. The default text color is black.

Examples:

    TEXTCOLOR WHITE
    TEXTCOLOR RGB 255 255 255 
    TEXTCOLOR RGBH FF FF FF
    TEXTCOLOR RGBH FFFFFF
Back to top 

TEXTSIZE

    TEXTSIZE sizespec

Sets the size of text to be drawn using subsequent textat commands.  The sizespec can be any value from the table below.  The default text size is SMALL.

Sizespec Parameter Description
5X8 Each character of text is 5x8 in size.
TINY Each character of text is 5x8 in size.
6X12 Each character of text is 6x12 in size.
SMALL Each character of text is 6x12 in size.
7X13 Each character of text is 7x13 in size and bold.
MEDIUM Each character of text is 7x13 in size and bold.
8X16 Each character of text is 8x16 in size.
LARGE Each character of text is 8x16 in size.
9X15 Each character of text is 9x15 in size.
GIANT Each character of text is 9x15 in size.

Examples:

    TEXTSIZE MEDIUM
    TEXTSIZE 9X15

Back to top 

TEXTWRAP

    TEXTWRAP n

Sets the maximum number of text characters that can be on the current line before wrapping must take place.  The wrap will normally take place at a space if possible.   To turn word wrapping off set textwrap to 0.  Textwrap is defaulted to off.

Examples:

    TEXTWRAP 30
    TEXTWRAP 0

Back to top 

UNAVAILSTART

    UNAVAILSTART

This command is use as an error trap in case the forecast was unavailable.  If the forecast was unavailable then HWimage will continue processing the template lines following the UNAVAILSTART command.  If the forecast was available then HWimage will immediately stop processing command as if and end command was found.

This command if often used in combination of the DOUNVAIL command.  If HWimage finds the DOUNVAIL and the forecast was unavailable, then HWimage will immediately skip to the UNAVAILSTART command.

Example:

    UNAVAILSTART

Back to top