Task

Create a window and draw a pixel in it, subject to the following:

  the window is 320 x 240
  the color of the pixel must be red (255,0,0)
  the position of the pixel is x = 100, y = 100
use GTK::Simple;
use GTK::Simple::DrawingArea;
use Cairo;
 
my $app = GTK::Simple::App.new(:title('Draw a Pixel'));
my $da  = GTK::Simple::DrawingArea.new;
gtk_simple_use_cairo;
 
$app.set-content( $da );
$app.border-width = 5;
$da.size-request(320,240);
 
sub rect-do( $d, $ctx ) {
    given $ctx {
        .rgb(1, 0, 0);
        .rectangle(100, 100, 1, 1);
        .fill;
    }
}
 
my $ctx = $da.add-draw-handler( &rect-do );
$app.run;