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 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.

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 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.

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 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:

    glow {
        glow {
            line( #ff33ff00, 0.0, 0.0, 1.0, 1.1 );
        }
    }

What this means is left to the renderer.

Glow