Permalink
Browse files

use common color format for sanity's sake

  • Loading branch information...
1 parent c1121a4 commit f305408c5713095f6315d0681351bf8020fdc23a @kthakore kthakore committed Sep 14, 2010
Showing with 18 additions and 13 deletions.
  1. +8 −9 code_listings/flower.pl
  2. +10 −4 src/02-drawing.pod
View
@@ -1,22 +1,18 @@
-use strict;
-use warnings;
use SDL;
use SDLx::App;
use SDLx::Sprite;
my $app = SDLx::App->new( w => 500, h => 500, d => 32, title => 'Pretty Flowers' );
+# Draw Code Starts here
my $flower = SDLx::Sprite->new ( width => 50, height => 100 );
-$flower->surface->draw_rect ( [0,0,50,100], 0x00000000 );
-
-$flower->surface->draw_rect ( [23,30, 4, 100], 0x00FF00FF );
-$flower->surface->draw_circle_filled ( [25,25], 10, 0xBB0000FF );
-
-$flower->surface->draw_circle ( [25,25], 10, 0xFF0000FF );
-
+$flower->surface->draw_rect ( [0,0,50,100], [0,0,0,0] );
+$flower->surface->draw_rect ( [23,30, 4, 100], [0,255,0,255] );
+$flower->surface->draw_circle_filled ( [25,25], 10, [150,0,0,255] );
+$flower->surface->draw_circle ( [25,25], 10, [255,0,0,255] );
$flower->alpha_key( 0 );
$app->draw_rect( [0,0,500,500], [20,50,170, 255] );
@@ -28,6 +24,9 @@
my $y = 425 - rand( 50 );
$flower->draw_xy( $app, rand(500)-20, $y );
}
+
+#Draw Code Ends Here
+
$app->update();
require SDL::Video;
View
@@ -21,6 +21,8 @@ Using SDL we will try to construct the following image.
=head1 Program
+Below is the program that generates the above image.
+
=for programlisting
use SDL;
@@ -33,11 +35,11 @@ Using SDL we will try to construct the following image.
my $flower = SDLx::Sprite->new ( width => 50, height => 100 );
- $flower->surface->draw_rect ( [0,0,50,100], 0x00000000 );
+ $flower->surface->draw_rect ( [0,0,50,100], [0,0,0,0] );
- $flower->surface->draw_rect ( [23,30, 4, 100], 0x00FF00FF );
- $flower->surface->draw_circle_filled ( [25,25], 10, 0xBB0000FF );
- $flower->surface->draw_circle ( [25,25], 10, 0xFF0000FF );
+ $flower->surface->draw_rect ( [23,30, 4, 100], [0,255,0,255] );
+ $flower->surface->draw_circle_filled ( [25,25], 10, [150,0,0,255] );
+ $flower->surface->draw_circle ( [25,25], 10, [255,0,0,255] );
$flower->alpha_key( 0 );
$app->draw_rect( [0,0,500,500], [20,50,170, 255] );
@@ -157,6 +159,10 @@ Now we will have a filled circle, colored blue and unfilled circle, colored as r
For more complex drawing functions have a look at C<SDL::GFX::Primitives>.
+=head1 Drawing the Flower, Sky and Field
+
+
+
=head1 Multiple Surfaces
So far we have been drawing only on one surface, the display. In SDL it is possible to write on

0 comments on commit f305408

Please sign in to comment.