X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=lib%2FSDL%2FPalette.pm;h=9d3040a63a875a71e33f229477899dcaed21db70;hb=60891a9e021e167c097eeb9747b1a509a8eb2cb8;hp=8f388af4055e371953c097b76c1dffc5f03b5cdf;hpb=8fde61e3e900d5000c94503679d735221acc1882;p=sdlgit%2FSDL_perl.git diff --git a/lib/SDL/Palette.pm b/lib/SDL/Palette.pm index 8f388af..9d3040a 100644 --- a/lib/SDL/Palette.pm +++ b/lib/SDL/Palette.pm @@ -1,94 +1,15 @@ -# -# Palette.pm -# -# a module for manipulating SDL_Palette * -# -# Copyright (C) 2000,2002 David J. Goehrig - +#!perl package SDL::Palette; use strict; - -# NB: there is no palette destructor because most of the time the -# palette will be owned by a surface, so any palettes you create -# with new, won't be destroyed until the program ends! - -sub new { - my $proto = shift; - my $class = ref($proto) || $proto; - my $image; - my $self; - if (@_) { - $image = shift; - $self = \$image->palette(); - } else { - $self = \SDL::NewPalette(256); - } - bless $self, $class; - return $self; -} - -sub size { - my $self = shift; - return SDL::PaletteNColors($$self); -} - -sub color { - my $self = shift; - my $index = shift; - my ($r,$g,$b); - if (@_) { - $r = shift; $g = shift; $b = shift; - return SDL::PaletteColors($$self,$index,$r,$g,$b); - } else { - return SDL::PaletteColors($$self,$index); - } -} - -sub red { - my $self = shift; - my $index = shift; - my $c; - if (@_) { - $c = shift; - return SDL::ColorR( - SDL::PaletteColors($$self,$index),$c); - } else { - return SDL::ColorR( - SDL::PaletteColors($$self,$index)); - } -} - -sub green { - my $self = shift; - my $index = shift; - my $c; - if (@_) { - $c = shift; - return SDL::ColorG( - SDL::PaletteColors($$self,$index),$c); - } else { - return SDL::ColorG( - SDL::PaletteColors($$self,$index)); - } -} - -sub blue { - my $self = shift; - my $index = shift; - my $c; - if (@_) { - $c = shift; - return SDL::ColorB( - SDL::PaletteColors($$self,$index),$c); - } else { - return SDL::ColorB( - SDL::PaletteColors($$self,$index)); - } -} +use warnings; +require Exporter; +require DynaLoader; +our @ISA = qw(Exporter DynaLoader); +bootstrap SDL::Palette; 1; -__END__; +__END__ =pod @@ -98,37 +19,30 @@ SDL::Palette - a perl extension =head1 DESCRIPTION -L provides an interface to the SDL_Palette structures, +L provides an interface to the C structures, and can be used to set the color values of an existing palette's indexes. =head1 METHODS -=head2 blue ( index, [value] ) - -Fetches and sets the blue component of the color at index. +=head2 ncolors ( ) -=head2 green ( index, [value] ) +Fetches the number of colors in palette -Fetches and sets the green component of the color at index. +=head2 colors ( index ) -=head2 red ( index, [value] ) +Fetches an array of colors in palette -Fetches and sets the red component of the color at index. +=head2 color_index ( index ) -=head2 color ( index, [ r, g, b ] ) - -Fetches and sets the RGB, returns an SDL_Color *. +Fetches the SDL_Color at the provide index in palette =head2 size Returns the size of the palette. -=head1 AUTHOR - -David J. Goehrig =head1 SEE ALSO -L L L +L L =cut