-
-
06 Nov 2018 00:14:30 UTC
- Distribution: Graphics-GVG
- Module version: 0.92
- Source (raw)
- Browse (raw)
- Changes
- Homepage
- How to Contribute
- Repository
- Issues
- Testers (659 / 0 / 4)
- Kwalitee
Bus factor: 0- 86.52% Coverage
- License: bsd
- Perl: v5.10.0
- Activity
24 month- Tools
- Download (15.83KB)
- MetaCPAN Explorer
- Permissions
- Subscribe to distribution
- Permalinks
- This version
- Latest version
NAME
Graphics::GVG::AST -- Abstract Syntax Tree for GVG scripts
DESCRIPTION
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.
Graphics::GVG::AST
This is the root object returned by
<Graphics::GVG-
parse()>>. It has one attribute,commands
, which returns an arrayref ofGraphics::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.
METHODS
to_string
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.
meta_data
Returns the hashref of metadata associated with this AST. This is only set on the root element of the AST.
COMMANDS
These all do the role
Graphics::GVG::AST::Command
, which in turn does theGraphics::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.
Circle
Attributes:
cx -- Num
cy -- Num
r -- Num
color -- Int
Ellipse
Attributes:
cx -- Num
cy -- Num
rx -- Num
ry -- Num
color -- Int
Line
Attributes:
x1 -- Num
y1 -- Num
x2 -- Num
y2 -- Num
color -- Int
Polygon
Attributes:
cx -- Num
cy -- Num
r -- Num
rotate -- Num
sides -- Int
color -- 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.Rect
Attributes:
x -- Num
y -- Num
width -- Num
height -- Num
color -- Int
EFFECTS
These all do the role
Graphics::GVG::AST::Effect
, which in turn does theGraphics::GVG::AST::Node
role.The
Graphics::GVG::AST::Effect
role has thecommands
attribute. This returns an arrayref ofGraphics::GVG::AST::Node
objects, which are all the nodes under this effect. Note that effects can be nested:glow { glow { line( #ff33ff00, 0.0, 0.0, 1.0, 1.1 ); } }
What this means is left to the renderer.
Glow
Module Install Instructions
To install Graphics::GVG, copy and paste the appropriate command in to your terminal.
cpanm Graphics::GVG
perl -MCPAN -e shell install Graphics::GVG
For more information on module installation, please visit the detailed CPAN module installation guide.