Permalink
Browse files

Added SDLx::Surface::draw_arc and draw_bezier

  • Loading branch information...
1 parent 46232de commit bb48b34438a07a4118be644794b85b525bf135d4 @jtpalmer jtpalmer committed Jul 2, 2011
Showing with 32 additions and 1 deletion.
  1. +13 −1 lib/SDLx/Surface.pm
  2. +19 −0 lib/pods/SDLx/Surface.pod
View
@@ -337,7 +337,12 @@ sub draw_polygon_filled {
}
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;
}
@@ -374,6 +379,13 @@ sub draw_ellipse_filled {
sub draw_bezier {
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 {
@@ -217,6 +217,15 @@ Draws an B<filled> polygon with vertices C<($xN,$yN)> and $color.
Antialias is turned on automatically.
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
$sdlx_surface->draw_ellipse( [ $x, $y ], $rx, $ry, $color );
@@ -237,6 +246,16 @@ Antialias is turned on automatically.
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
Draw text using gfx (not pretty but fast) at give vector, color.

0 comments on commit bb48b34

Please sign in to comment.