5 blue_rect.pir - draw a blue rectangle with the SDL Parrot bindings
9 To run this file, run the following command from the Parrot directory:
11 $ ./parrot examples/sdl/blue_rect.pir
17 # first load the necessary libraries
18 load_bytecode "SDL/App.pir"
19 load_bytecode "SDL/Rect.pir"
20 load_bytecode "SDL/Color.pir"
22 # create an SDL::App object
24 app = new ['SDL'; 'App']
25 app.'init'( 'height' => 480, 'width' => 640, 'bpp' => 32, 'flags' => 1 )
27 # fetch the SDL::Surface representing the main window
28 .local pmc main_screen
29 main_screen = app.'surface'()
31 # create an SDL::Rect object
33 new rect, ['SDL'; 'Rect']
34 rect.'init'( 'height' => 100, 'width' => 100, 'x' => 270, 'y' => 190 )
36 # create an SDL::Color object
38 new color, ['SDL'; 'Color']
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
55 chromatic, E<lt>chromatic at wgz dot orgE<gt>.
59 Copyright (C) 2004-2008, Parrot Foundation.
67 # vim: expandtab shiftwidth=4 ft=pir: