source: libcaca/trunk/csharp/test.cs @ 2046

Last change on this file since 2046 was 2046, checked in by Sam Hocevar, 13 years ago
  • Started Cucul# cleanup: added missing functions, used get/set attributes when meaningful, removed deprecated bindings.
  • Property svn:keywords set to Id
File size: 2.5 KB
Line 
1/*
2 *  Test      .NET bindings test program
3 *  Copyright (c) 2006 Jean-Yves Lamoureux <jylam@lnxscene.org>
4 *                All Rights Reserved
5 *
6 *  $Id: test.cs 2046 2007-11-24 15:00:21Z sam $
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
15
16using System;
17
18using Cucul;
19using Caca;
20
21class Test {
22
23
24
25        public static void Main() {
26        int barCount = 6;
27        Console.WriteLine("libcaca .NET test");
28                Console.WriteLine("(c) 2006 Jean-Yves Lamoureux <jylam@lnxscene.org>");
29
30        /* Instanciate a cucul canvas */
31        CuculCanvas cv = new CuculCanvas();
32
33
34        /* Random number. This is a static method,
35           not to be used with previous instance */
36        Console.WriteLine("A random number : {0}", Libcucul.Rand(0, 1337));
37
38
39
40        /* We have a proper canvas, let's display it using Caca */
41        Display dp = new Display(cv);
42        dp.setDisplayTime(20000); // Refresh every 20 ms
43
44        dp.setDisplayTitle("libcaca .NET Bindings test suite");
45
46        double v;
47        Int32 y = 0;
48        Event e = new Event();
49        int i;
50
51        DateTime startTime = DateTime.Now;
52        while(dp.getEvent(Event.type.KEY_RELEASE, e, 10) == 0)
53          {
54            TimeSpan curTime = DateTime.Now - startTime;
55            double t = curTime.TotalMilliseconds;
56            cv.setColorAnsi(Libcucul.WHITE, Libcucul.BLACK);
57            for(i=0; i<barCount;i++)
58             {
59                v = ((Math.Sin((t/500.0)+(i/((double)barCount)))+1)/2)*cv.height;
60                y = (Int32) v;
61
62
63
64                cv.setColorAnsi(i+9, Libcucul.BLACK);
65                /* drawLine is already clipped, we don't care about overflows */
66                cv.drawLine(0, y-2, cv.width, y-2, '-');
67                cv.drawLine(0, y-1, cv.width, y-1, '*');
68                cv.drawLine(0, y, cv.width, y, '#');
69                cv.drawLine(0, y+1, cv.width, y+1, '*');
70                cv.drawLine(0, y+2, cv.width, y+2, '-');
71             }
72
73             cv.setColorAnsi(Libcucul.WHITE, Libcucul.BLUE);
74             cv.putStr(cv.width - 30,cv.height - 2," -=[ Powered by libcaca ]=- ");
75             cv.setColorAnsi(Libcucul.WHITE, Libcucul.BLACK);
76
77
78            dp.Refresh();
79            cv.Clear();
80
81          }
82
83        /* Force deletion of our instances for fun */
84        dp.Dispose();
85        cv.Dispose();
86        }
87
88}
Note: See TracBrowser for help on using the repository browser.