@@ -347,6 +347,19 @@ <h4>Color</h4>
347
347
348
348
< pre > < code > my $color = [255, 255, 255, 255];</ code > </ pre >
349
349
350
+ < p > The magnitude of each color value determines how much of that color
351
+ component will be mixed into the resulting color. A 0 value specifies that
352
+ none of the color channel should be used while 255 specifies a maximum
353
+ intensity for a particular channel. The first value corresponds with the
354
+ Red channel, so a higher number there means more red will be mixed into the
355
+ resulting color. It is a common practice to achieve a grayscale of varying
356
+ intensity by specifying the same value for each of the Red, Green, and Blue
357
+ color channels. The fourth and final value designates the transparency (or
358
+ Alpha channel) where a 0 value makes the resulting color fully transparent
359
+ and 255 makes it entirely opaque. A transparency value somewhere in between
360
+ will allow underlying colors to be blended with the specified RGB values
361
+ into the final color output.</ p >
362
+
350
363
< p > You may also represent a color as hexadecimal values, where the values
351
364
of the numbers range from 0-255 for 32 bit depth in RGBA format:</ p >
352
365
@@ -593,53 +606,12 @@ <h2>Lots of Flowers but One Seed</h2>
593
606
< pre > < code > for (0 .. 500) {
594
607
my $y = 425 - rand( 50);
595
608
$flower->draw_xy( $app, rand(500) - 20, $y );
596
- }
597
-
598
- $app->update();
599
-
600
- sleep(1);</ code > </ pre >
609
+ }</ code > </ pre >
601
610
602
611
< p > ... to make an entire field of flowers.</ p >
603
612
604
613
< p > Probably don't need this.</ p >
605
614
606
- < h2 > Program</ h2 >
607
-
608
- < p > The final program looks like this:</ p >
609
-
610
- < pre > < code > use SDL;
611
- use SDLx::App;
612
- use SDLx::Sprite;
613
-
614
- my $app = SDLx::App->new(
615
- w => 500,
616
- h => 500,
617
- d => 32,
618
- title => 'Pretty Flowers'
619
- );
620
-
621
- # Draw Code Starts here
622
- my $flower = SDLx::Sprite->new( width => 50, height => 100 );
623
-
624
- $flower->surface->draw_rect( [ 0, 0, 50, 100 ], [ 0, 0, 0, 0 ] );
625
- $flower->surface->draw_rect( [ 23, 30, 4, 100 ], [ 0, 255, 0, 255 ] );
626
- $flower->surface->draw_circle_filled( [ 25, 25 ], 10, [ 150, 0, 0, 255 ] );
627
- $flower->surface->draw_circle( [ 25, 25 ], 10, [ 255, 0, 0, 255 ] );
628
- $flower->alpha_key(0);
629
-
630
- $app->draw_rect( [ 0, 0, 500, 500 ], [ 20, 50, 170, 255 ] );
631
- $app->draw_rect( [ 0, 400, 500, 100 ], [ 50, 170, 20, 100 ] );
632
-
633
- for(0..500){
634
- my $y = 425 - rand( 50);
635
- $flower->draw_xy( $app, rand(500) - 20, $y );
636
- }
637
- #Draw Code Ends Here
638
-
639
- $app->update();
640
-
641
- sleep(2);</ code > </ pre >
642
-
643
615
< h1 > Handling Events</ h1 >
644
616
645
617
< p > </ p >
@@ -682,12 +654,10 @@ <h1>Handling Events</h1>
682
654
683
655
sub do_key { $quit = 1 }</ code > </ pre >
684
656
685
- < p > Add other types of events.</ p >
686
-
687
- < p > </ p >
657
+ < p > </ p >
688
658
689
659
< p > Every event has an associated type which represents the category of the
690
- event. The previous example looks for a keypress event (footnote: SDL
660
+ event. The previous example looks for a keypress event (footnote: SDL
691
661
separates the event of pressing a key from the event of releasing a key,
692
662
which allows you to identify combinations of keypresses, such as Ctrl + P
693
663
to print.). The SDL library defines several types of events, and SDL_perl
@@ -703,6 +673,60 @@ <h1>Handling Events</h1>
703
673
handle events. Processing events is a matter of setting up the appropriate
704
674
callbacks and letting SDL do the heavy work.</ p >
705
675
676
+ < blockquote >
677
+
678
+ < p > < b > SDL Events Types</ b > </ p >
679
+
680
+ < p > Additional Event types that can be captured by SDL are:</ p >
681
+
682
+ < ul >
683
+
684
+ < li > Keyboard
685
+
686
+ < p > < code > SDL_KEYDOWN</ code > < code > SDL_KEYUP</ code > - Keyboard button
687
+ pressed</ p >
688
+
689
+ < li > Mouse
690
+
691
+ < p > < code > SDL_MOUSEMOTION</ code > - Mouse motion occured</ p >
692
+
693
+ < p > < code > SDL_MOUSEBUTTONDOWN</ code > < code > SDL_MOUSEBUTTONUP</ code > - Mouse
694
+ button pressed</ p >
695
+
696
+ < li > Joystick
697
+
698
+ < p > < code > SDL_JOYAXISMOTION</ code > - Joystick axis motion</ p >
699
+
700
+ < p > < code > SDL_JOYBALLMOTION</ code > - Joystick trackball motion</ p >
701
+
702
+ < p > < code > SDL_JOYHATMOTION</ code > - Joystick hat position change</ p >
703
+
704
+ < p > < code > SDL_JOYBUTTONDOWN</ code > < code > SDL_JOYBUTTONUP</ code > - Joystick
705
+ button pressed</ p >
706
+
707
+ < li > Window \& System
708
+
709
+ < p > < code > SDL_ACTIVEEVENT</ code > - Application visibility</ p >
710
+
711
+ < p > < code > SDL_VIDEORESIZE</ code > - Window resized</ p >
712
+
713
+ < p > < code > SDL_VIDEOEXPOSE</ code > - Window exposed</ p >
714
+
715
+ < p > < code > SDL_QUIT</ code > - Quit requested</ p >
716
+
717
+ < p > < code > SDL_USEREVENT</ code > - A user-defined event type</ p >
718
+
719
+ < p > < code > SDL_SYSWMEVENT</ code > - Platform-dependent window manager
720
+ event</ p >
721
+
722
+ </ ul >
723
+
724
+ < p > For more information look at:</ p >
725
+
726
+ < pre > < code > perldoc SDL::Event </ code > </ pre >
727
+
728
+ </ blockquote >
729
+
706
730
< h2 > Quitting with Grace</ h2 >
707
731
708
732
< p > The example applications so far have not exited cleanly. Handling quit
@@ -893,7 +917,7 @@ <h2>POD ERRORS</h2>
893
917
894
918
< ul >
895
919
896
- < li > Around line 259 :
920
+ < li > Around line 317 :
897
921
898
922
< p > =end programlisting without matching =begin. (Stack: [empty])</ p >
899
923
0 commit comments