[t][TT #1119] Convert t/op/bitwise.t to PIR
[parrot.git] / examples / sdl / blue_rect.pl
blob4774348fec53c5cebdd53f8d2c387028c2347761
1 # $Id$
3 =head1 TITLE
5 blue_rect.pl - draw a blue rectangle using the SDL library and NQP
7 =head1 SYNOPSIS
9 To run this file, execute the following command from the Parrot
10 directory:
12 $ ./parrot compilers/nqp/nqp.pbc examples/sdl/blue_rect.pl
14 =cut
16 # load the SDL class libraries
17 PIR q< load_bytecode 'SDL/App.pir' >;
18 PIR q< load_bytecode 'SDL/Rect.pir' >;
19 PIR q< load_bytecode 'SDL/Color.pir' >;
21 # make sure NQP has class protoobjects for the SDL classes
22 Protomaker.new_proto('SDL::App');
23 Protomaker.new_proto('SDL::Rect');
24 Protomaker.new_proto('SDL::Color');
26 # create an SDL::App object
27 my $app := SDL::App.new();
28 $app.init( :height(480), :width(640), :bpp(0), :flags(1) );
30 # fetch the SDL::Surface representing the main window
31 my $main_screen := $app.surface();
33 # create an SDL::Rect object
34 my $rect := SDL::Rect.new();
35 $rect.init( :height(100), :width(100), :x(270), :y(190) );
37 # create an SDL::Color object
38 my $color := SDL::Color.new();
39 $color.init( :r(0), :g(0), :b(255) );
41 # draw the rectangle to the surface and update it
42 $main_screen.fill_rect( $rect, $color );
43 $main_screen.update_rect( $rect );
45 # pause for people to see it
46 PIR q< sleep 2 >;
48 # and that's it!
49 $app.quit();
52 =head1 AUTHOR
54 blue_rect.pl created by Patrick R. Michaud (pmichaud@pobox.com)
55 based on blue_rect.pir by chromatic (chromatic at wgz dot org).
57 =head1 COPYRIGHT
59 Copyright (C) 2004-2007, Parrot Foundation.
61 =cut
63 # Local Variables:
64 # mode: cperl
65 # cperl-indent-level: 4
66 # fill-column: 100
67 # End:
68 # vim: expandtab shiftwidth=4: