Skip to content

Commit

Permalink
Added antialias for unfilled color circle in SDLx::Surface
Browse files Browse the repository at this point in the history
  • Loading branch information
kthakore committed Oct 26, 2010
1 parent 7822cb5 commit 81edab8
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 5 deletions.
12 changes: 10 additions & 2 deletions lib/SDLx/Surface.pm
Expand Up @@ -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");
Expand All @@ -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;
}

Expand Down
6 changes: 3 additions & 3 deletions lib/pods/SDLx/Surface.pod
Expand Up @@ -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


Expand Down
1 change: 1 addition & 0 deletions t/sdlx_surface.t
Expand Up @@ -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';
Expand Down

0 comments on commit 81edab8

Please sign in to comment.