3 <h3 id="TOP">Index</h3>
5 <ul><li><a href="#NAME">NAME</a>
6 <ul><li><a href="#CATEGORY">CATEGORY</a></li>
9 <li><a href="#Perl_s_SDL_in_a_nutshell">Perl's SDL in a nutshell</a></li>
10 <li><a href="#SDL_power_through_simplicity">SDL - power through simplicity</a></li>
11 <li><a href="#Example_1_Model_of_a_2_D_Noninteract">Example 1: Model of a 2-D Noninteracting Gas</a>
12 <ul><li><a href="#Computational_Logic">Computational Logic</a></li>
13 <li><a href="#Animation_Logic">Animation Logic</a></li>
14 <li><a href="#Disappearing_Particles_Some_of_the_p">Disappearing Particles!
15 Some of the particles can drift off the screen. This is no good. What's causing this problem?</a></li>
16 <li><a href="#Disappearing_Particles_take_2">Disappearing Particles, take 2</a></li>
19 <li><a href="#What_s_in_a_Name_Pesky_conflicts_wit">What's in a Name? Pesky conflicts with main::in()</a>
20 <ul><li><a href="#Solution_1_Explicit_scoping_using_pa">Solution 1: Explicit scoping using packages</a></li>
21 <li><a href="#Solution_2_Removing_SDL_s_in_or_PDL_">Solution 2: Removing SDL's in or PDL's in from the symbol table</a></li>
24 <li><a href="#Making_the_simulation_interactive">Making the simulation interactive</a>
25 <ul><li><a href="#Present_state_of_the_code">Present state of the code</a></li>
26 <li><a href="#Listening_to_Events">Listening to Events</a></li>
27 <li><a href="#Responding_to_events">Responding to events</a></li>
28 <li><a href="#Final_State_of_the_Code">Final State of the Code</a></li>
31 <li><a href="#Directions_for_future_work">Directions for future work</a>
36 <h1 id="NAME">NAME</h1><p><a href="#TOP" class="toplink">Top</a></p>
37 <div id="NAME_CONTENT">
38 <p>SDL::CookBook::PDL -- CookBook for SDL + PDL</p>
39 <p>PDL provides great number crunching capabilities to Perl and SDL provides game-developer quality real-time bitmapping and sound. You can use PDL and SDL ''together'' to create real-time, responsive animations and simulations. In this section we will go through the pleasures and pitfalls of working with both powerhouse libraries.</p>
46 <h2 id="CATEGORY">CATEGORY</h2>
47 <div id="CATEGORY_CONTENT">
51 <h1 id="Perl_s_SDL_in_a_nutshell">Perl's SDL in a nutshell</h1><p><a href="#TOP" class="toplink">Top</a></p>
52 <div id="Perl_s_SDL_in_a_nutshell_CONTENT">
53 <p>SDL stands for Simple DirectMedia Layer. It's a cross-platform library written in C that's meant to handle all of the low-level graphics and sound stuff. You can read more about SDL here: http://www.libsdl.org/. Because SDL is focused on game programming, it has a raw but clean feel to it. We will focus for now on using SDL to handle images for us. Handling sound may some day be the focus of another chapter.</p>
54 <p>We will be using Perl's SDL module, not SDL directly. Fortunately, Perl's SDL module has a small collection of very simple tutorials that perfectly introduce basic usage. You can find them here: http://sdl.perl.org/tutorials/. Another excellent and very substantial introduction can be found here: http://arstechnica.com/gaming/news/2006/02/games-perl.ars</p>
55 <p>SDL is not a Perl core module, so you'll need to install it before moving forward. Before moving on, go through some of the tutorials and play around with SDL a little bit. Continue on once you think you've got the hang of it.</p>
58 <h1 id="SDL_power_through_simplicity">SDL - power through simplicity</h1><p><a href="#TOP" class="toplink">Top</a></p>
59 <div id="SDL_power_through_simplicity_CONTENT">
60 <p>One of the first questions you're bound to ask when you begin using SDL for your own work is, "How do I draw a line?" As it turns out, you don't! SDL's pixmap capabilities are just that - pixmap capabilities. If you want to draw a line, you'll have to do it manually.</p>
61 <p>For example, here is a very poorly implemented hack (read - don't do this at home) that will draw a simple sine-wave graph:</p>
72 # User defined pen-nib size.
76 my $app = SDL::App->new(
80 -title => "Hello, World!",
83 # our nib will be white
84 my $nib_color = SDL::Color->new(
90 # and our nib will be represented by a rectangle
91 # (Alternatively, you could use an image, which would allow
92 # for pretty anti-aliasing if you created it in GIMP with
94 my $nib = SDL::Rect->new(
100 # now draw a sine wave (wthout covering up previously drawn rectangles)
103 for($t = 0; $t < 50; $t += $t_step) {
104 $nib->x( $t * 8 );
105 $nib->y( sin($t) * 80 + 240 );
107 SDL::Video::fill_rect($app, $nib, $nib_color );
110 # Generally use the update command, but if you want to update the whole
112 SDL::Video::fill_rect($app,)
117 <p>Wait a second, you say, this doesn't seem either powerful or simple! You're right, but that's not because SDL is a poor tool. Rather, this example targets SDL's weaknesses rather than its strenghts.</p>
118 <p>If you need to make a plot, use PLplot or PGPLOT. If you need to make something move, use SDL.</p>
121 <h1 id="Example_1_Model_of_a_2_D_Noninteract">Example 1: Model of a 2-D Noninteracting Gas</h1><p><a href="#TOP" class="toplink">Top</a></p>
122 <div id="Example_1_Model_of_a_2_D_Noninteract-2">
123 <p>In this section we'll develop a fully working animation/simulation. We'll start with something quite simple for now and expand it as we go along. The goal of this example is for it to work, not to be well-designed. For a discussion of making your simulations well-designed, read below.</p>
124 <p>We will separate our program into two parts: the computational logic and the animation logic. Here's the introduction and the computational part:</p>
127 <h2 id="Computational_Logic">Computational Logic</h2>
128 <div id="Computational_Logic_CONTENT">
133 # A simple simulation
138 # Set up the system parameters, including random positions and velocities.
140 my $side_length = 200;
141 my $numb_of_atoms = 100;
142 my $positions = random(2, $numb_of_atoms) * $side_length;
143 my $velocities = random(2, $numb_of_atoms) * 6;
146 $positions += $d_t * $velocities;
150 <p>If you've ever written a simulation, you'll probably object that we don't have any iteration over time. You're right, but it turns out that the timing works much better in SDL's event loop than in our computational logic. The purpose of the computational logic is to let us focus on encoding our systems dynamics without having to worry about the application logic. In this case, the computational logic simply updates the positions of the particles according to their velocities.</p>
153 <h2 id="Animation_Logic">Animation Logic</h2>
154 <div id="Animation_Logic_CONTENT">
155 <p>We next need to figure out how the application is actually going to run and display anything. We'll do this in two stages, the application intialization and the run loop.</p>
156 <p>Here's some initialization code to get started; put this below the code already supplied above:</p>
164 my $app = SDL::App->new( -width => $side_length, -height => $side_length,
165 -title => "Simple Simulation!", -depth => 16, );
167 # white particles on a black background
168 my $particle_color = SDL::Color->new( 0xff, 0xff, 0xff, );
169 my $bg_color = SDL::Color->new( 0x00, 0x00, 0x00 );
171 # rectangles for the particles and the background
172 my $particle = SDL::Rect->new( 0,0, 5, 5);
173 my $bg = SDL::Rect->new( 0,0,$side_length, $side_length, );
176 <p>Hopefully this is straightforward code. We pull in our library dependencies and then create a few objects with the necessary properties. Finally, we get to the actual application loop:</p>
177 <pre> # Run the simulation by (1) computing the updated positions, clearing the canvas, drawing the
178 # new particles, updating the visual display, and pausing before continuing:
179 for(my $t = 0; $t < 20; $t += $d_t) {
183 SDL::Video::fill_rect($app, $bg, $bg_color);
184 for(my $i = 0; $i < $numb_of_atoms; $i++) {
185 $particle->x( $positions->at(0,$i) );
186 $particle->y( $positions->at(1,$i) );
187 SDL::Video::fill_rect($app, $particle, $particle_color );
189 SDL::Video::flip($app);
194 <p>When you run this code (combined with the code already supplied), you should get a bunch of particles slowly drifting down and to the right. Not all that interesting, but then again, we have a simulation up and working! Cool!.</p>
197 <h2 id="Disappearing_Particles_Some_of_the_p">Disappearing Particles!
198 Some of the particles can drift off the screen. This is no good. What's causing this problem?</h2>
199 <div id="Disappearing_Particles_Some_of_the_p-2">
200 <p>The root of the problem is that our computational code is, well, rather dumb, it doesn't check to see if the particle is about to go off the screen. So, we need to update our computational code to look like this:</p>
202 $positions += $d_t * $velocities;
204 # Find all particles that are 'outside' the box, place them back in
205 # box, and reverse their directions
206 my ($bad_pos, $bad_vel)
207 = where($positions, $velocities, $positions > $side_length);
209 $bad_pos .= 2 * $side_length - $bad_pos;
213 <p>With this change to the code, you should get particles that 'bounce' when the reach the far edge. This is far from satisfactory, however, because the compute code is adjusting the particle's ''left'' edge, not its center, so the particles nearly go off the screen before they bounce. To fix this, we work with an effective side length instead:</p>
214 <pre> my $effective_length = $side_length - 5;
216 $positions += $d_t * $velocities;
218 # Find all particles that are 'outside' the box and push them back in the
219 # opposite direction, reversing their directions, too.
220 my ($bad_pos, $bad_vel)
221 = where($positions, $velocities, $positions > $effective_length);
223 $bad_pos .= 2 * $effective_length - $bad_pos;
227 <p>So far I've been carrying that explicit constant of 5 to represent the size of the particles. We should put that in a variable somewhere so that it's a bitcode> and put it near the top. Also, the velocities are rather silly - we don't have any negative velocities. Let's try using <code>grandom</code> instead. Now your variable initialization code should look something like this:</p>
228 <pre> # Set up the system parameters, including random positions and velocities.
230 my $side_length = 200;
231 my $particle_size = 5;
232 my $numb_of_atoms = 100;
233 my $positions = random(2, $numb_of_atoms) * $side_length;
234 my $velocities = grandom(2, $numb_of_atoms) * 5;
239 <h2 id="Disappearing_Particles_take_2">Disappearing Particles, take 2</h2>
240 <div id="Disappearing_Particles_take_2_CONTEN">
241 <p>Unless you experience an unusual circumstance, all of the particles will quickly shrivel up and disappear! What's going on? It turns out we have a problem with our computational logic again, but we are also running into strange behavior from SDL. We'll take a look at SDL's weird behavior first.</p>
242 <p>Clearly the particle rectangle's size is not supposed to change, but somehow it does. To confince yourself of this, modify the <code>for</code> loop in the application loop so it looks more like this, which explicitly sets the particle size for every particle that's drawn:</p>
243 <pre> for(my $i = 0; $i < $numb_of_atoms; $i++) {
244 $particle->x( $positions->at(0,$i) );
245 $particle->y( $positions->at(1,$i) );
246 $particle->h( $particle_size );
247 $particle->w( $particle_size );
248 SDL::Video::fill_rect($app, $particle, $particle_color );
252 <p>Now it's clear that although we still have particles flying off the screen up and to the left, they are no longer shriveling away. This strange behavior is due to SDL's response to a negative position for a rectangle - it just resizes the rectangle so that it only the portion of the rectangle that's in positive territory remains. The upshot is that you must always be careful about how you handle drawing positons.</p>
253 <p>Now that the particles are no longer disappearing, it's clear that we forgot to set up a physical boundary condition for our particles on the uppper and left edges. To fix that, we modify the compute function:</p>
255 $positions += $d_t * $velocities;
257 # Find all particles that are 'outside' the box and push them back in the
258 # opposite direction, reversing their directions, too.
259 my ($bad_pos, $bad_vel)
260 = where($positions, $velocities, $positions > $effective_length);
262 $bad_pos .= 2 * $effective_length - $bad_pos;
264 ($bad_pos, $bad_vel) = where($positions, $velocities, $positions < 0);
270 <p>You can also remove the explicit particle-sizing that we put in before, because it's no longer a problem.</p>
271 <p>And there you have it! We have a fully fledged simulation of noninteracting particles in a box!</p>
274 <h1 id="What_s_in_a_Name_Pesky_conflicts_wit">What's in a Name? Pesky conflicts with main::in()</h1><p><a href="#TOP" class="toplink">Top</a></p>
275 <div id="What_s_in_a_Name_Pesky_conflicts_wit-2">
276 <p>If you've been running your simulations along with the demo, you'll almost certainly have noticed an error looking something like this:</p>
277 <pre> Prototype mismatch: sub main::in (;@) vs none at ./sdlsandbox.pl line 36
280 <p>This is the unfortunate consequence of both SDL and PDL exporting their <code>in</code> function to their enclosing namespace. The standard solution to this is to have modify one of your <code>use</code> lines so it looks like </p>
281 <pre> use PDL qw( !in );
284 <p>Unfortunately, PDL doesn't listen you what you say when it imports functions into the namespace. As far as I can tell, neither does SDL. The best way to fix this problem is to encapsulate one of the two pieces of code into its own package. We'll do that with the MyComputation package.</p>
287 <h2 id="Solution_1_Explicit_scoping_using_pa">Solution 1: Explicit scoping using packages</h2>
288 <div id="Solution_1_Explicit_scoping_using_pa-2">
289 <p>Tweak your code a bit so that you call <code>use PDL;</code> within the MyCompute package, and place all of the piddles within that package space:</p>
290 <pre> package MyCompute;
292 my $positions = random(2, $numb_of_atoms) * $side_length;
298 # ... and later, tweak the application loop
299 for(my $t = 0; $t < 20; $t += $d_t) {
300 MyCompute::compute();
303 <p>And now everything should run fine, without any more warnings!</p>
306 <h2 id="Solution_2_Removing_SDL_s_in_or_PDL_">Solution 2: Removing SDL's in or PDL's in from the symbol table</h2>
307 <div id="Solution_2_Removing_SDL_s_in_or_PDL_-2">
308 <p>Sometimes you have to mix your animation code with computational code, in which case the above solution doesn't solve your problem. If you find that you don't need to use one of PDL's or SDL's <code>in</code> function in your own code, go ahead and remove it from the main symbol table. You can always get back to it later by fully qualifying the function call. To remove SDL's <code>in</code> function, use code like this:</p>
309 <pre> # use SDL, but remove SDL's in function before loading PDL
317 <p>If you would rather have SDL's <code>in</code> function in your main symbol table, reverse the placement of <code>use SD<a href="#code">code</a> and <code>use PD<a href="#code">code</a> in the previous example:</p>
318 <pre> # use PDL, but remove its 'in' function before loading SDL
328 <h1 id="Making_the_simulation_interactive">Making the simulation interactive</h1><p><a href="#TOP" class="toplink">Top</a></p>
329 <div id="Making_the_simulation_interactive_CO">
330 <p>As the closing portion of this chapter, we'll consider how to make the simulation interactive. SDL captures keyboard and mouse behavior, so putting this into our simulator is straightforward.</p>
333 <h2 id="Present_state_of_the_code">Present state of the code</h2>
334 <div id="Present_state_of_the_code_CONTENT">
335 <p>Before moving into getting user interaction, I first want to be sure we're working with the same code. In particular, I've made a couple of important modifications so that this code is slightly different from what we were working with above. I'll point out those differences as we come to them. Here's the program as it stands, from top to bottom:</p>
336 <pre> #!/usr/bin/perl
337 # A simple simulation
341 ## Global Variables ##
343 # Set up the system parameters, including random positions and velocities.
345 my $side_length = 200;
346 my $particle_size = 5;
347 my $numb_of_atoms = 100;
349 ## Computational Stuff ##
353 my $positions = random(2, $numb_of_atoms) * $side_length;
354 my $velocities = grandom(2, $numb_of_atoms) * 6;
355 my $effective_length;
358 my $effective_length = $side_length - $particle_size;
360 # update the a real simulation, this is the interesting part
361 $positions += $d_t * $velocities;
363 # Check boundary conditions. Find all particles that are 'outside' the box,
364 # place them back in the box, and reverse their directions
365 my ($bad_pos, $bad_vel)
366 = where($positions, $velocities, $positions > $effective_length);
368 $bad_pos .= 2 * $effective_length - $bad_pos;
370 ($bad_pos, $bad_vel) = where($positions, $velocities, $positions < 0);
389 my $app = SDL::App->new( -width => $side_length, -height => $side_length,
390 -title => "Simple Simulation!", -depth => 16, );
392 # white particles on a black background
393 my $particle_color = SDL::Color->new( 0xff, 0xff, 0xff, );
394 my $bg_color = SDL::Color->new( 0x00, 0x00, 0x00 );
396 # rectangles for the particles and the background
397 my $particle = SDL::Rect->new( 0,0, 5, 5);
398 my $bg = SDL::Rect->new( 0,0,$side_length, $side_length, );
401 for(my $t = 0; $t < 20; $t += $d_t) {
402 MyCompute::compute();
405 SDL::Video::fill_rect($app, $bg, $bg_color);
406 for(my $i = 0; $i < $numb_of_atoms; $i++) {
407 $particle->x( $positions->at(0,$i) );
408 $particle->y( $positions->at(1,$i) );
409 SDL::Video::fill_rect($app, $particle, $particle_color );
411 SDL::Video::flip($app);
416 <p>So there it is, top to bottom, in about 75 lines.</p>
419 <h2 id="Listening_to_Events">Listening to Events</h2>
420 <div id="Listening_to_Events_CONTENT">
421 <p>To respond to user interactions, we have to listen to user events using an SDL::Event object. So first, add this line with our other use statements:</p>
422 <pre> use SDL::Event;
426 <p>and then be sure to create an event object amongst the animation initialization code:</p>
427 <pre> my $event = SDL::Event->new;
430 <p>Finally, we need to update the application loop so that it examines and responds to events. Replace the current application loop with this code:</p>
431 <pre> # Run the simulation
433 MyCompute::compute();
436 SDL::Video::fill_rect($app, $bg, $bg_color);
437 for(my $i = 0; $i < $numb_of_atoms; $i++) {
438 $particle->x( $positions->at(0,$i) );
439 $particle->y( $positions->at(1,$i) );
440 SDL::Video::fill_rect($app, $particle, $particle_col10);
442 while(SDL::Events::poll_event($event) ) {
443 if($event->type() == SDL_QUIT) {
450 <p>Now the animator will run indefinitely, until you explicitly tell it to close. (You may have noticed before that the application would not close even if you told it to close. Now we've fixed that.)</p>
453 <h2 id="Responding_to_events">Responding to events</h2>
454 <div id="Responding_to_events_CONTENT">
455 <p>When SDL gets a mouse response or a keyboard key press, it tells you with an event. The naive way to process these event is with a series of if statements. Don't do that.</p>
456 <p>Instead, create a dispatch table, which is nothing more than a hash whose values are the subroutines you want to have run when an event happens. Replace the application loop with the following code:</p>
457 <pre> # event dispatch table
458 my $keyname_dispatch_table = {
459 'up' => \&incr_particle_size, # up key makes particles larger
460 'down' => \&decr_particle_size, # down key makes particles smaller
461 'space' => sub { $d_t = -$d_t }, # space-bar reverses time
462 '.' => sub { $d_t *= 1.1 }, # right-angle-bracket fast-forwards
463 ',' => sub { $d_t /= 1.1 }, # left-angle-bracket slows down
464 'q' => sub { exit; }, # q exits
467 sub incr_particle_size {
469 $particle->h($particle_size);
470 $particle->w($particle_size);
473 sub decr_particle_size {
474 $particle_size-- if $particle_size > 1;
475 $particle->h($particle_size);
476 $particle->w($particle_size);
484 MyCompute::compute();
487 SDL::Video::fill_rect($app, $bg, $bg_color);
488 for(my $i = 0; $i < $numb_of_atoms; $i++) {
489 $particle->x( $positions->at(0,$i) );
490 $particle->y( $positions->at(1,$i) );
491 SDL::Video::fill_rect($app, $particle, $particle_color );
493 SDL::Video::flip($app);
496 while(SDL::Events::poll_event($event) ) {
497 if($event->type() == SDL_QUIT) {
499 } elsif($event->type() == SDL_QUIT) {
500 if(exists $keyname_dispatch_table->{$event->keysym_name()}) {
501 $keyname_dispatch_table->{$event->keysym_name()}->();
508 <p>Dispatch tables allow for powerful methods of abstracting your program logic. Now adding a new event handler is as easy as updating the dispatch table!</p>
509 <p>As written, you can now increase or decrease the particle size using the up and down arrow keys, you can increase ory using the right or left angle-brackets, you can reverse time using the space bar, or you can quit by pressing q.</p>
512 <h2 id="Final_State_of_the_Code">Final State of the Code</h2>
513 <div id="Final_State_of_the_Code_CONTENT">
514 <p>Just so that you've got a complete working example, here is the final state of the code, clocking in at a mere 115 lines:</p>
515 <pre> #!/usr/bin/perl
516 # A simple simulation
520 ## Global Variables ##
522 # Set up the system parameters, including random positions and velocities.
524 my $side_length = 200;
525 my $particle_size = 5;
526 my $numb_of_atoms = 100;
528 ## Computational Stuff ##
532 my $positions = random(2, $numb_of_atoms) * $side_length;
533 my $velocities = grandom(2, $numb_of_atoms) * 6;
534 my $effective_length;
537 my $effective_length = $side_length - $particle_size;
539 # update the positions. For a real simulation, this is the interesting part
540 $positions += $d_t * $velocities;
542 # Check boundary conditions. Find all particles that are 'outside' the box,
543 # place them back in the box, and reverse their directions
544 my ($bad_pos, $bad_vel)
545 = where($positions, $velocities, $positions > $effective_length);
547 $bad_pos .= 2 * $effective_length - $bad_pos;
549 ($bad_pos, $bad_vel) = where($positions, $velocities, $positions < 0);
570 my $app = SDL::App->new( -width => $side_length, -height => $side_length,
571 -title => "Simple Simulation!", -depth => 16, );
573 # white particles on a black background
574 my $particle_color = SDL::Color->new( 0xff, 0xff, 0xff, );
575 my $bg_color = SDL::Color->new( 0x00, 0x00, 0x00 );
577 # rectangles for the particles and the background
578 my $particle = SDL::Rect->new( 0,0, 5, 5);
579 my $bg = SDL::Rect->new( 0,0,$side_length, $side_length, );
582 my $event = SDL::Event->new();
584 # event dispatch table
585 my $keyname_dispatch_table = {
586 'up' => \&incr_particle_size, # up key makes particles large
587 'down' => \&decr_particle_size, # up key makes particles large
588 'space' => sub { $d_t = -$d_t },
589 '.' => sub { $d_t *= 1.1 }, # right-arrow fast-forwards
590 ',' => sub { $d_t /= 1.1 }, # left-arrow slows down
591 'q' => sub { exit; }, # q exits
594 sub incr_particle_size {
596 $particle->h($particle_size);
597 $particle->w($particle_size);
600 sub decr_particle_size {
601 $particle_size-- if $particle_size > 1;
602 $particle->h($particle_size);
603 $particle->w($particle_size);
611 MyCompute::compute();
614 SDL::Video::fill_rect($app, $bg, $bg_color);
615 for(my $i = 0; $i < $numb_of_atoms; $i++) {
616 $particle->x( $positions->at(0,$i) );
617 $particle->y( $positions->at(1,$i) );
618 SDL::Video::fill_rect($app, $particle, $particle_color );
620 SDL::Video::flip($app);
623 while(SDL::Events::poll_event($event) ) {
624 if($event->type() == SDL_QUIT) {
626 } elsif($event->type() == SDL_QUIT) {
627 if(exists $keyname_dispatch_table->{$event->keysym_name()}) {
628 $keyname_dispatch_table->{$event->keysym_name()}->();
635 <p>Next, if you want to model interactions among particles, you could write code in the compute function to handle that for you. If you wanted to use little balls instead of the boxes we've used here, you could create your own images and use an SDL::Surface to load the image. You can't resize an image using SDL, but then you'd probably be working with real interactions anyway, like a Coulomb force, in which case you'd really be adjusting the interaction strength, not the particle size.</p>
638 <h1 id="Directions_for_future_work">Directions for future work</h1><p><a href="#TOP" class="toplink">Top</a></p>
639 <div id="Directions_for_future_work_CONTENT">
640 <p>I have a couple of ideas for future work combining PDL and SDL.</p>
642 <dt>PLplot driver thingy that creates plots that can be blitted onto an app. This way, having a graph plotting along side your simulation would be straightforward.
643 =item Write a function to convert SDL::Surface to a collection of rgba piddles. We might even be able to convince the piddle to work directly with the memory allocated for the SDL::Survace object for super-fast PDL-based image manipulations. As an added bonus, you'd be able to slice and dice!</dt>