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.
 
 
 
 
 
 

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