Skip to content

Commit

Permalink
Added SDLx::Surface::draw_arc and draw_bezier
Browse files Browse the repository at this point in the history
  • Loading branch information
jtpalmer committed Jul 2, 2011
1 parent 46232de commit bb48b34
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 1 deletion.
14 changes: 13 additions & 1 deletion lib/SDLx/Surface.pm
Expand Up @@ -337,7 +337,12 @@ sub draw_polygon_filled {
} }


sub draw_arc { sub draw_arc {
my ( $self, $vector, $radius, $start, $end, $color ) = @_; my ( $self, $center, $radius, $start, $end, $color ) = @_;

Carp::cluck "Center needs to be an array of format [x,y]" unless ( ref $center eq 'ARRAY' && scalar @$center == 2 );
$color = SDLx::Validate::num_rgba($color);

SDL::GFX::Primitives::arc_color( $self, @$center, $radius, $start, $end, $color );


return $self; return $self;
} }
Expand Down Expand Up @@ -374,6 +379,13 @@ sub draw_ellipse_filled {
sub draw_bezier { sub draw_bezier {
my ( $self, $vector, $smooth, $color ) = @_; my ( $self, $vector, $smooth, $color ) = @_;


$color = SDLx::Validate::num_rgba($color);

my @vx = map { $_->[0] } @$vector;
my @vy = map { $_->[1] } @$vector;
SDL::GFX::Primitives::bezier_color( $self, \@vx, \@vy, scalar @$vector, $smooth, $color );

return $self;
} }


sub draw_gfx_text { sub draw_gfx_text {
Expand Down
19 changes: 19 additions & 0 deletions lib/pods/SDLx/Surface.pod
Expand Up @@ -217,6 +217,15 @@ Draws an B<filled> polygon with vertices C<($xN,$yN)> and $color.
Antialias is turned on automatically. Antialias is turned on automatically.
Returns $self Returns $self


=head2 draw_arc

$sdlx_surface->draw_arc( [ $x, $y ], $radius, $start, $end, $color );

Draws an arc around C<($x,$y)> with $radius, $start radius, $end radius
and $color.

Returns $self

=head2 draw_ellipse =head2 draw_ellipse


$sdlx_surface->draw_ellipse( [ $x, $y ], $rx, $ry, $color ); $sdlx_surface->draw_ellipse( [ $x, $y ], $rx, $ry, $color );
Expand All @@ -237,6 +246,16 @@ Antialias is turned on automatically.


Returns $self Returns $self


=head2 draw_bezier

$sdlx_surface->draw_bezier( [ [$x1, $y1], [$x2, $y2], [$x3, y3], ... ], $s, $color );

Draws a bezier curve of points C<($xN,$yN)> using $s steps for
interpolation and $color.
Antialias is turned on automatically.

Returns $self

=head2 draw_gfx_text =head2 draw_gfx_text


Draw text using gfx (not pretty but fast) at give vector, color. Draw text using gfx (not pretty but fast) at give vector, color.
Expand Down

0 comments on commit bb48b34

Please sign in to comment.