You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

87 line
2.5 KiB

  1. /*
  2. * Test .NET bindings test program
  3. * Copyright (c) 2006 Jean-Yves Lamoureux <jylam@lnxscene.org>
  4. * All Rights Reserved
  5. *
  6. * $Id$
  7. *
  8. * This library is free software; you can redistribute it and/or
  9. * modify it under the terms of the Do What The Fuck You Want To
  10. * Public License, Version 2, as published by Sam Hocevar. See
  11. * http://sam.zoy.org/wtfpl/COPYING for more details.
  12. */
  13. using System;
  14. using libCucul;
  15. using libCaca;
  16. class Test {
  17. public static void Main() {
  18. int barCount = 6;
  19. Console.WriteLine("libcaca .NET test");
  20. Console.WriteLine("(c) 2006 Jean-Yves Lamoureux <jylam@lnxscene.org>");
  21. /* Instanciate a cucul canvas */
  22. Cucul qq = new Cucul();
  23. /* Random number. This is a static method,
  24. not to be used with previous instance */
  25. Console.WriteLine("A random number : {0}", Cucul.Rand(0, 1337));
  26. /* We have a proper canvas, let's display it using Caca */
  27. Caca kk = new Caca(qq);
  28. kk.setDisplayTime(20000); // Refresh every 20 ms
  29. kk.setDisplayTitle("libcaca .NET Bindings test suite");
  30. double v;
  31. Int32 y = 0;
  32. Event e = new Event();
  33. Int32 i;
  34. DateTime startTime = DateTime.Now;
  35. while(kk.getEvent(Event.type.KEY_RELEASE, e, 10) == 0)
  36. {
  37. TimeSpan curTime = DateTime.Now - startTime;
  38. double t = curTime.TotalMilliseconds;
  39. qq.setColor(Cucul.CUCUL_WHITE, Cucul.CUCUL_BLACK);
  40. for(i=0; i<barCount;i++)
  41. {
  42. v = ((Math.Sin((t/500.0)+(i/((double)barCount)))+1)/2)*qq.getHeight();
  43. y = (Int32) v;
  44. qq.setColor(i+1, Cucul.CUCUL_BLACK);
  45. /* drawLine is already clipped, we don't care about overflows */
  46. qq.drawLine(0, y-2, qq.getWidth(), y-2, '-');
  47. qq.drawLine(0, y-1, qq.getWidth(), y-1, '*');
  48. qq.drawLine(0, y, qq.getWidth(), y, '#');
  49. qq.drawLine(0, y+1, qq.getWidth(), y+1, '*');
  50. qq.drawLine(0, y+2, qq.getWidth(), y+2, '-');
  51. }
  52. qq.setColor(Cucul.CUCUL_WHITE, Cucul.CUCUL_BLUE);
  53. qq.putStr(qq.getWidth() - 30,qq.getHeight() - 2," -=[ Powered by libcaca ]=- ");
  54. qq.setColor(Cucul.CUCUL_WHITE, Cucul.CUCUL_BLACK);
  55. kk.Refresh();
  56. qq.Clear();
  57. }
  58. /* Force deletion of our instances for fun */
  59. qq.Dispose();
  60. kk.Dispose();
  61. }
  62. }