NAME

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

VERSION

version 0.001

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. In this package it has a global Graphics::Grid object, on which the functions are operated.

FUNCTIONS

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 global Graphics::Grid object, 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 global Graphics::Grid object.

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();

unit(%params)

It's same as Graphics::Grid::Unit->new.

unit_c(@unit_objs)

It's same as Graphics::Grid::UnitList->new.

gpar(%params)

It's same as Graphics::Grid::GPar->new.

viewport(%params)

It's same as Graphics::Grid::Viewport->new.

viewport_tree($parent, $children)

It's same as Graphics::Grid::ViewportTree->new.

push_viewport($viewport)

It's same as Graphics::Grid's push_viewport method.

pop_viewport($n=1)

It's same as Graphics::Grid's pop_viewport method.

up_viewport($n=1)

It's same as Graphics::Grid's up_viewport method.

down_viewport($from_tree_node, $name)

It's same as Graphics::Grid's down_viewport method.

seek_viewport($name)

It's same as Graphics::Grid's seek_viewport method.

grid_layout(%prams)

It's same as Graphics::Grid::Layout->new.

grid_draw($grob)

It's same as Graphics::Grid's draw method.

grid_write($filename)

It's same as Graphics::Grid's write method.

gtree(%params)

It's same as Graphics::Grid::GTree->new.

grill(%params)

This creates a grill object.

grid_grill(%params)

This creates a grill object and draws it.

grob_width($grob)

grob_height($grob)

${grob_type}_grob(%params)

This creates a grob object.

$grob_type can be one of following,

grid_${grob_type}(%params)

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

See above for possible $grob_type.

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