Browse files

Added antialias for unfilled color circle in SDLx::Surface

  • Loading branch information...
1 parent 7822cb5 commit 81edab8cdad9065bcc29842cfeaeb95c9194ed4e @kthakore kthakore committed Oct 26, 2010
Showing with 14 additions and 5 deletions.
  1. +10 −2 lib/SDLx/Surface.pm
  2. +3 −3 lib/pods/SDLx/Surface.pod
  3. +1 −0 t/sdlx_surface.t
View
12 lib/SDLx/Surface.pm
@@ -278,12 +278,19 @@ sub draw_circle {
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::circle_color( $self, @{$center}, $radius, $color );
+ unless( $antialias )
+ {
+ SDL::GFX::Primitives::circle_color( $self, @{$center}, $radius, $color );
+ }
+ else
+ {
+ SDL::GFX::Primitives::aacircle_color( $self, @{$center}, $radius, $color );
+ }
return $self;
}
sub draw_circle_filled {
- my ( $self, $center, $radius, $color, $antialias ) = @_;
+ my ( $self, $center, $radius, $color) = @_;
unless ( SDL::Config->has('SDL_gfx_primitives') ) {
Carp::cluck("SDL_gfx_primitives support has not been compiled");
@@ -294,6 +301,7 @@ sub draw_circle_filled {
$color = SDLx::Validate::num_rgba($color);
SDL::GFX::Primitives::filled_circle_color( $self, @{$center}, $radius, $color );
+
return $self;
}
View
6 lib/pods/SDLx/Surface.pod
@@ -169,18 +169,18 @@ Returns $self
=head2 draw_circle
- $sdlx_surface->draw_circle( [$x1, $y1], $radius, \@color );
+ $sdlx_surface->draw_circle( [$x1, $y1], $radius, \@color, $antialias );
Draws an unfilled circle at C<($x1,$y1)> of size $radius and $color.
-
+Antialias is turned on if $antialias is true.
Returns $self
=head2 draw_circle_filled
$sdlx_surface->draw_filled_circle( [$x1, $y1], $radius, \@color );
Draws an B<filled> circle at C<($x1,$y1)> of size $radius and $color.
-
+Antialias is turned on automatically.
Returns $self
View
1 t/sdlx_surface.t
@@ -165,6 +165,7 @@ SKIP:
foreach my $cir_color (@colors_t) {
my $cir_color = [ 255, 0, 0, 255 ];
$surfs[0]->draw_circle( [ 100, 10 ], 20, $cir_color ); #no fill
+ $surfs[0]->draw_circle( [ 102, 12 ], 22, $cir_color , 1 );
$surfs[0]->draw_circle_filled( [ 100, 10 ], 20, $cir_color ); #fill
isnt( $surfs[0]->[100][10], 0 );
pass 'draw_circle works';

0 comments on commit 81edab8

Please sign in to comment.