11 Right click on any pixel to get its color values
12 Left click on any pixel to set its value to the last selected
15 $app = new SDL::App -width => 320, -height => 240, -depth => 8;
18 red => (new SDL::Color -r => 255, -g => 0, -b => 0 ),
19 green => (new SDL::Color -r => 0, -g => 255, -b => 0),
20 blue => (new SDL::Color -r => 0, -g => 0, -b => 255),
21 yellow => (new SDL::Color -r => 255, -g => 255, -b => 0),
22 purple => (new SDL::Color -r => 255, -g => 0, -b => 255),
23 white => (new SDL::Color -r => 255, -g => 255, -b => 255)
28 $rect = SDL::Rect->new( $x, $y, $app->width / scalar(keys %colors), $app->height());
30 print "Sorted colors:\n";
32 for ( sort keys %colors ) {
33 print "$_ " . join (",",$colors{$_}->r(), $colors{$_}->g(),
34 $colors{$_}->b()) . "\n";
37 for ( sort keys %colors ) {
40 $app->fill($rect,$colors{$_});
45 $last = new SDL::Color -r => 128, -g => 128, -b => 128;
49 SDL_QUIT() => sub { exit(0); },
50 SDL_KEYDOWN() => sub { $app->fullscreen(); },
51 SDL_MOUSEBUTTONDOWN() => sub {
53 if ($e->button == 3) {
54 $last = $app->pixel($e->button_x(),$e->button_y());
55 print STDERR "X: ", $e->button_x(), " Y: ", $e->button_y(),
56 " R: ", $last->r(), " G: ", $last->g(),
57 " B: ", $last->b(), "\n";
59 $app->pixel($e->button_x(),$e->button_y(),$last);