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

NAME

Graphics::Grid::Grob::Polyline - Polyline grob

VERSION

version 0.0000_03

SYNOPSIS

    use Graphics::Grid::Grob::Polyline;
    use Graphics::Grid::GPar;
    my $polyline = Graphics::Grid::Grob::Polyline->new(
            x => [
                ( map { $_ / 10 } ( 0 .. 4 ) ),
                (0.5) x 5,
                ( map { $_ / 10 } reverse( 6 .. 10 ) ),
                (0.5) x 5
            ],
            y => [
                (0.5) x 5,
                ( map { $_ / 10 } reverse( 6 .. 10 ) ),
                (0.5) x 5,
                ( map { $_ / 10 } ( 0 .. 4 ) ),
            ],
            id => [ ( 1 .. 5 ) x 4 ],
            gp => Graphics::Grid::GPar->new(
                col => [qw(black red green3 blue cyan)],
                lwd => 3,
            )
    );

    # or use the function interface
    use Graphics::Grid::Functions qw(:all);
    my $polyline = polyline_grob(%params);

DESCRIPTION

This class represents a polyline graphical object.

ATTRIBUTES

x

A Grahpics::Grid::Unit object specifying x-values.

Default to unit([0, 1], "npc").

y

A Grahpics::Grid::Unit object specifying y-values.

Default to unit([0, 1], "npc").

x and y combines to define the points in the lines. x and y shall have same length. For example, the default values of x and y defines a line from point (0, 0) to (1, 1). If they have less than two elements, it is surely not enough to make a line and nothing would be drawn.

id

An array ref used to separate locations in x and y into multiple lines. All locations with the same id belong to the same line.

id needs to have the same length as x and y.

If id is not specified then all points would be regarded as being in one line.

gp

An object of Graphics::Grid::GPar. Default is an empty gpar object.

vp

A viewport object. When drawing a grob, if the grob has this attribute, the viewport would be temporily pushed onto the global viewport stack before drawing takes place, and be poped after drawing. If the grob does not have this attribute set, it would be drawn on the existing current viewport in the global viewport stack.

elems

Get number of sub-elements in the grob.

Grob classes shall implement a _build_elems() method to support this attribute.

For this module elems returns the number of lines (number of unique id) of a object.

METHODS

indexes_by_id($id)

Get unit indexes of attributes x, y, id, for a given id.

Returns an array ref.

unique_ids

Return an array ref of unique ids.

CONSTRUCTOR

SEE ALSO

Graphics::Grid::Functions

Graphics::Grid::Grob

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.