/t_backcompat/testgraphictool.pl

http://github.com/PerlGameDev/SDL · Perl · 65 lines · 49 code · 12 blank · 4 comment · 0 complexity · d623813f80b6092a1a737e653dd41787 MD5 · raw file

  1. #!/usr/bin/env perl
  2. use strict;
  3. use warnings;
  4. use SDL;
  5. use SDL::Surface;
  6. use SDLx::App;
  7. use SDL::Tool::Graphic;
  8. my $app = SDLx::App->new(
  9. -title => "Graphic Tool Test",
  10. -width => 640,
  11. -height => 480,
  12. -depth => 16,
  13. -fullscreen => 0
  14. );
  15. my $app_rect = SDL::Rect->new(
  16. -x => 0,
  17. -y => 0,
  18. -width => $app->width,
  19. -height => $app->height
  20. );
  21. my $sprite = SDL::Surface->new( -name => "data/logo.png" );
  22. $sprite->display_format();
  23. #Test Zoom
  24. my $graphicTool = SDL::Tool::Graphic->new();
  25. $graphicTool->zoom( $sprite, .5, .5, 1 );
  26. my $sprite_rect = SDL::Rect->new(
  27. -x => 0,
  28. -y => 0,
  29. -width => $sprite->width,
  30. -height => $sprite->height
  31. );
  32. $sprite->blit( $sprite_rect, $app, $sprite_rect );
  33. $app->flip();
  34. sleep 4;
  35. $app->fill( $app_rect, $SDL::Color::black );
  36. #Test Rotate
  37. $graphicTool->rotoZoom( $sprite, 90, 1, 1 );
  38. $sprite_rect = SDL::Rect->new(
  39. -x => 0,
  40. -y => 0,
  41. -width => $sprite->width,
  42. -height => $sprite->height
  43. );
  44. $sprite->blit( $sprite_rect, $app, $sprite_rect );
  45. $app->flip();
  46. sleep 4;
  47. +print "GrayScaling\n";
  48. +$app->fill( $app_rect, $SDL::Color::black );
  49. #Test GrayScale
  50. $graphicTool->grayScale($sprite);
  51. $sprite->blit( $sprite_rect, $app, $sprite_rect );
  52. $app->flip();
  53. sleep 4;