Documentation

An example of program written in George.

The program on the next page comes from the file clock.grg. It allows you to draw a clock displaying the current time on the project window.



We suggest you create a button assigned to this script in a custom panel, as explained previously. After this operation, it should be easy for you to test this George Script in the project window.

Once this stage is passed, you can try to edit the George Script, to modify it and to test it again in TVPaint Animation. This should help you learn the basics of the George Language.

The best way to get used to George scripts is probably to try the example programs that come with TVPaint Animation.
Study them and make small alterations to them, then run them and see the effects of your changes.


The clock.grg script :
Param Circle
// TVPaint should wait for the coordinates of a circle before running the
// program. The user must therefore draw a circle to start the program.

Parse result command x y r button // Fetches the coordinates of the user’s circle.

if cmp(command,"Circle")==0
tv_Warn "This program needs the coordinates of a circle !"
exit // If there are no coordinates for a circle, warn the user and end the program.
End

t=time
parse t h m s // Fetches the hours (h), minutes (m) and seconds (s) of the current time.
m=m+s/60 // The seconds can slightly alter the minutes arm of the clock.
tv_Pen r/30 // Selects a pen proportional to the clock size.
tv_Circle x y r // Draws the outline of the clock.
ang=360/12
d=r-(r/10)
#for i=0 to 360-ang step ang // Loop to draw the 12 hour markers on the clock
#a=cos(i)*d
#b=sin(i)*d
tv_Dot x+a y-b 0
#end

i=h*360/12 // Draw in the hours
d=r/2
a=sin (i)*d
b=cos (i)*d
tv_Line x y x+a y-b

i=m*360/60 // Draw in the minutes
d=r-(r/8)
a=sin(i)*d
b=cos(i)*d
tv_Line x y x+a y-b // End of the example

Commands Description

Here are some information regarding the commands that you can find on the previous page :

Below, each command will be followed by the syntax of the variables it requires.
For example, to draw a straight line from one point to another, you must give the coordinates of the start point then the end point.

The syntax to draw such a line would be:
tv_Line x1 y1 x2 y2 [0/1]
The [0/1] parameter indicates that you can use either the left [0] or the right [1] mouse button. This is optional; by default, it’s always the left button that will be used.

To summarize :
[ ] Variables inside square brackets are optional.
/ The “/” symbol separates several options of which only one is used.
For instance, 0/1 means either 0 or 1.

tv_Circle x y r [0/1]
This command allows you to draw a circle with a radius r and a center located on the pixel with (x,y) coordinates.
The [0/1] parameter indicates that you can use either the left [0] or the right [1] mouse button.
Of course, the circle will be drawn on the current image on the current layer.

tv_Dot x y [0/1]
this command allows you to use the current tool (airbrush, pen, custombrush,…) on the pixel with (x,y) coordinates, in the current image on the current layer.
The [0/1] parameter indicates that you can use either the left [0] or the right [1] mouse button.

tv_Warn text
This command displays a popup dialog box containing the character string text and an “ok” button.
The character string must be surrounded by quotation marks.

tv_Pen size
This command allows you to select the pen tool with its current parameters (drawing mode, opacity, power, ...) and change its size.

You should always remember that a George Script will use TVP Animation as it finds it, i.e. with the functions and options that are currently set.

For instance, if you want to draw a red line with a George Script, the script needs to be told more than just the line coordinates. Unless you explicitly tell it to use a red color, your script will go ahead and use the current color when the script is run, whatever it may be.

Similarly, if when you run the script it is in the Behind or Colorize drawing mode, you won’t exactly be getting the clean line you were hoping for.