Graphics::GVG::AST -- Abstract Syntax Tree for GVG scripts
GVG scripts are compiled into an Abstract Syntax Tree (AST). Renderers will walk the AST and generate the code they need to render the vectors.
Everything is a Moose object.
This is the root object returned by <Graphics::GVG-parse()>>. It has one attribute, commands, which returns an arrayref of Graphics::GVG::AST::Node objects. Each of these nodes correspond to a command or an effect.
Note that variables are filled in statically. They don't appear in the generated AST.
Returns the string corresponding to the GVG script representation of the AST. Note that the output may not be exactly what you input, as certain compile time transforms will loose information. The two should be semantically identical, however.
Returns the hashref of metadata associated with this AST. This is only set on the root element of the AST.
These all do the role Graphics::GVG::AST::Command, which in turn does the Graphics::GVG::AST::Node role.
All Nodes require a to_string() method, which will output the GVG script representation of the object.
The attributes on each object correspond to their function description in the language. See Graphics::GVG for details.
cx -- Num
cy -- Num
r -- Num
color -- Int
rx -- Num
ry -- Num
x1 -- Num
y1 -- Num
x2 -- Num
y2 -- Num
rotate -- Num
sides -- Int
There is also a special attribute, coords, which returns an arrayref of arrayrefs of coordinates (numbers). These are the list of x/y coords of the calculated polygon.
x -- Num
y -- Num
width -- Num
height -- Num
These all do the role Graphics::GVG::AST::Effect, which in turn does the Graphics::GVG::AST::Node role.
The Graphics::GVG::AST::Effect role has the commands attribute. This returns an arrayref of Graphics::GVG::AST::Node objects, which are all the nodes under this effect. Note that effects can be nested:
line( #ff33ff00, 0.0, 0.0, 1.0, 1.1 );
What this means is left to the renderer.
To install Graphics::GVG, copy and paste the appropriate command in to your terminal.
perl -MCPAN -e shell
For more information on module installation, please visit the detailed CPAN module installation guide.