The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.

NAME

Graphics::Grid::Functions - Function interface for Graphics::Grid

VERSION

version 0.0000_02

SYNOPSIS

    use Graphics::Grid::Functions qw(:all);

    grid_driver( width => 900, height => 300, format => 'svg' );
    grid_rect();    # draw white background

    for my $setting (
        { color => 'red',   x => 1 / 6 },
        { color => 'green', x => 0.5 },
        { color => 'blue',  x => 5 / 6 }
      )
    {
        push_viewport(
            viewport( x => $setting->{x}, y => 0.5, width => 0.2, height => 0.6 ) );
        grid_rect( gp => { fill => $setting->{color}, lty => 'blank' } );
        grid_text( label => $setting->{color}, y => -0.1 );

        pop_viewport();
    }

    grid_write("foo.svg");

DESCRIPTION

This is the function interface for Graphics::Grid.

FUNCTIONS

unit(%params)

It's equivalent to Graphics::Grid::Unit->new.

viewport(%params)

It's equivalent to Graphics::Grid::Viewport->new.

gpar(%params)

It's equivalent to Graphics::Grid::GPar->new.

push_viewport($viewport)

It's equivalent to Graphics::Grid's push_viewport method.

pop_viewport($n=1)

It's equivalent to Graphics::Grid's pop_viewport method.

up_viewport($n=1)

It's equivalent to Graphics::Grid's up_viewport method.

down_viewport($from_tree_node, $name)

It's equivalent to Graphics::Grid's down_viewport method.

seek_viewport($name)

It's equivalent to Graphics::Grid's seek_viewport method.

${grob_type}_grob(%params)

This creates a grob object.

$grob_type can be one of following,

  • circle

  • lines

  • points

  • polygon

  • polyline

  • rect

  • segments

  • text

  • null

  • zero

grid_${grob_type}(%params)

This creates a grob, and draws it. This is equivalent to Graphics::Grid's ${grob_type}(...) method.

See above for possible $grob_type.

gtree(%params)

It's equivalent to Graphics::Grid::GTree->new.

grid_draw($grob)

It's equivalent to Graphics::Grid's draw method.

grid_driver(:$driver='Cairo', %rest)

Set the device driver. If you don't run this function, the default driver will be effective.

If $driver consumes Graphics::Grid::Driver, $driver is assigned to the grid singleton, and %rest is ignored.

    grid_driver(driver => Graphics::Grid::Driver::Cairo->new(...));

If $driver is a string, a Graphics::Grid::Driver::$driver object is created with %rest as construction parameters, and is assigned to the grid singleton.

    grid_driver(driver => 'Cairo', width => 800, height => 600);

You may run it at the the beginning of you code. At present changing driver settings at the middle is not guarenteed to work.

This function returns current width and height.

    my $driver = grid_device();

grid_write($filename)

It's equivalent to Graphics::Grid's write method.

SEE ALSO

Graphics::Grid

Examples in the examples directory of the package release.

AUTHOR

Stephan Loyd <sloyd@cpan.org>

COPYRIGHT AND LICENSE

This software is copyright (c) 2018 by Stephan Loyd.

This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.