NAME

Data::Turtle

VERSION

version 0.01

SYNOPSIS

use Data::Turtle;
my $turtle = Turtle->new;
$turtle->pen_up;
$turtle->turn(45);
$turtle->forward(10);
$turtle->pen_down;
for my $i ( 1 .. 4 ) {
    $turtle->forward(50);
    $turtle->right(90);
}
$turtle->pen_up;
$turtle->goto( 10, 10 );
$turtle->mirror;
$turtle->backward(10);
my ( $x, $y, $heading, $pen_status, $pen_color, $pen_size ) = $turtle->get_state;
$turtle->set_state( $x, $y, $heading, $pen_status, $pen_color, $pen_size );

DESCRIPTION

This module enables basic turtle movement and state operations without requiring any particular graphics package.

The methods don't draw anything per se. They set or output coordinates and values for line drawing by your favorite graphics package.

NAME

Turtle - Turtle Movement and State Operations

ATTRIBUTES

width, height

Drawing surface dimensions.

x, y, heading

Coordinate parameters.

pen_status

Is the pen is up or down?

pen_color, pen_size

Pen properties.

METHODS

home()

$turtle->home;

Move the turtle cursor to the starting x,y position and heading.

pen_up()

$turtle->pen_up;

Raise the pen head to stop drawing.

pen_down()

$turtle->pen_down;

Lower the pen head to begin drawing.

turn()

$turtle->right($degrees);

Set the heading to the given degrees.

right()

$turtle->right($degrees);

Turn to the right.

left()

$turtle->left($degrees);

Turn to the left.

position()

@pos = $turtle->position;

Return the current pen position as a list of the x and y values.

get_state()

@state = $turtle->get_state;

Return the following settings as a list:

x, y, heading, pen_status, pen_color, pen_size

set_state()

$turtle->set_state( $x, $y, $heading, $pen_status, $pen_color, $pen_size );

Set the turtle state with the given parameters.

forward()

@line = $turtle->forward($steps);

Move forward the given number of steps.

backward()

@line = $turtle->backward($steps);

Move backward the given number of steps.

mirror()

$turtle->mirror;

Reflect the heading by multiplying by -1.

goto()

@line = $turtle->goto( $x, $y );

Move the pen to the given coordinate.

SEE ALSO

https://metacpan.org/source/YVESP/llg-1.07/Turtle.pm

AUTHOR

Gene Boggs <gene@cpan.org>

COPYRIGHT AND LICENSE

This software is copyright (c) 2015 by Gene Boggs.

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