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 = new SDL::Rect -x => $x, -y => $y,
29 -w => $app->width / scalar(keys %colors), -h => $app->height();
31 print "Sorted colors:\n";
33 for ( sort keys %colors ) {
34 print "$_ " . join (",",$colors{$_}->r(), $colors{$_}->g(),
35 $colors{$_}->b()) . "\n";
38 for ( sort keys %colors ) {
41 $app->fill($rect,$colors{$_});
46 $last = new SDL::Color -r => 128, -g => 128, -b => 128;
50 SDL_QUIT() => sub { exit(0); },
51 SDL_KEYDOWN() => sub { $app->fullscreen(); },
52 SDL_MOUSEBUTTONDOWN() => sub {
54 if ($e->button == 3) {
55 $last = $app->pixel($e->button_x(),$e->button_y());
56 print STDERR "X: ", $e->button_x(), " Y: ", $e->button_y(),
57 " R: ", $last->r(), " G: ", $last->g(),
58 " B: ", $last->b(), "\n";
60 $app->pixel($e->button_x(),$e->button_y(),$last);