Graphics-Framebuffer
view release on metacpan or search on metacpan
examples/vector.pl view on Meta::CPAN
parse(@text);
sleep $delay;
$F->cls('ON');
$F->text_mode();
sub parse {
my @cmds = @_;
foreach my $line (@cmds) {
$line =~ s/\#.*//;
next if ($line eq '');
my ($c, $t, @p);
unless ($line =~ /\s+/) {
$c = $line;
$cmd->{$line}->();
} else {
($c, $t) = ($line =~ /^(.*?)\s+(.*)/);
if ($t =~ /,/) {
@p = split(/,\s*/, $t);
} else {
push(@p, $t);
}
} ## end else
if (exists($cmd->{ uc($c) })) {
$cmd->{ uc($c) }->(@p);
} else {
warn "$c not found!";
}
} ## end foreach my $line (@cmds)
sleep $delay;
} ## end sub parse
__END__
=pod
=head1 VECTOR DRAWING
=head2 DESCRIPTION
A simple layer to draw simple primitives using the Perl Graphics::Framebuffer similar to BASIC, and resolution independent.
The vector layer uses a virtual 3840 x 2160 screen, regardless of the actual resolution. This means your drawings will always look great no matter what the actual resolution is.
There is also a timing delay to allow for specifically timed displays.
=head2 SYNOPSIS
./vector.pl draw.gfb
=head2 COMMANDS
=over 4
=item B<ADD_MODE>
Sets the drawing mode to B<add> drawing mode. Pixels will be ADDed with what is already on the screen.
=item B<ALPHA_MODE>
Sets the drawing mode to B<alpha> drawing mode. Pixels will be overlayed on top of what is already on the screen based on the alpha (opacity) value of the FOREGROUND color.
=item B<AND_MODE>
Sets the drawing mode to B<and> drawing mode. Pixels will be ANDed with what is already on the screen.
=item B<ANGLE_LINE> x, y, radius, angle
Draws a line, in the FOREGROUND color, starting at point x,y with the length of radius at the given compass angle.
=item B<ARC> x, y, radius, start degrees, end degrees [, granularity]
Draws a circular arc at virtual center point x,y starting at start degree to end degree with the set radius, using the selected granularity
=item B<ATTRIBUTE_RESET>
Sets the FOREGROUND color to white, the BACKGROUND color to black, and resets clipping.
=item B<BACKGROUND> red, green, blue [, alpha]
Sets the background color.
=item B<BEZIER> points, pixel size, coordinate pairs
Draws a bezier curve using the number of points, pixel size, and set number of coordinates (always in x,y pairs).
=item B<BLIT_COPY> x, y, width, height, new x, new y
One screen section can be copied to another location.
=item B<BLIT_MOVE> x, y, width, height, new x, new y
One screen section can be moved to another location.
=item B<BOX> x, y, xx, yy [, filled] [, corner radius]
Draws a box at point x,y to point xx,yy optionally filled and optionally with rounded corners of a specified radius.
=item B<CIRCLE> x, y, radius [, filled]
Draws a circle at center point x,y with the specified radius and optionally filled.
=item B<CLIP_RESET>
Turns off clipping
=item B<CLIP_RSET> x, y, width, height
Sets a clipping rectangle
=item B<CLIP_SET> x, y, xx, yy
Sets a clipping rectangle.
=item B<CLS>
The screen will be cleared with the BACKGROUND color. Also sets the pixel location to 0,0
=item B<DIVIDE_MODE>
Sets the drawing mode to B<divide> drawing mode. Pixels will be DIVIDEDed with what is already on the screen.
( run in 1.644 second using v1.01-cache-2.11-cpan-39bf76dae61 )