source: libcaca/trunk/DotNet/test.cs @ 1462

Last change on this file since 1462 was 1462, checked in by Sam Hocevar, 14 years ago
  • Bwarf, typo in the no warranty clause.
  • Property svn:keywords set to Id
File size: 2.6 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 1462 2006-12-12 01:53:54Z 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;
17using libCucul;
18using libCaca;
19
20class Test {
21
22
23
24        public static void Main() {
25        int barCount = 6;
26        Console.WriteLine("libcaca .NET test");
27                Console.WriteLine("(c) 2006 Jean-Yves Lamoureux <jylam@lnxscene.org>");
28       
29        /* Instanciate a cucul canvas */
30        Cucul qq = new Cucul();
31
32 
33        /* Random number. This is a static method,
34           not to be used with previous instance */
35        Console.WriteLine("A random number : {0}", Cucul.Rand(0, 1337));
36
37
38
39        /* We have a proper canvas, let's display it using Caca */
40        Caca kk = new Caca(qq);
41        kk.setDisplayTime(20000); // Refresh every 20 ms
42
43        kk.setDisplayTitle("libcaca .NET Bindings test suite");
44
45        double v;
46        Int32 y = 0;
47        Event e = new Event();
48        Int32 i;
49       
50        DateTime startTime = DateTime.Now;
51        while(kk.getEvent(Event.type.KEY_RELEASE, e, 10) == 0)
52          {
53            TimeSpan curTime = DateTime.Now - startTime;
54            double t = curTime.TotalMilliseconds;
55            qq.setColor(Cucul.CUCUL_WHITE, Cucul.CUCUL_BLACK);
56            for(i=0; i<barCount;i++)
57             {
58                v = ((Math.Sin((t/500.0)+(i/((double)barCount)))+1)/2)*qq.getHeight();
59                y = (Int32) v;
60
61 
62
63                qq.setColor(i+9, Cucul.CUCUL_BLACK);
64                /* drawLine is already clipped, we don't care about overflows */
65                qq.drawLine(0, y-2, qq.getWidth(), y-2, '-');
66                qq.drawLine(0, y-1, qq.getWidth(), y-1, '*');
67                qq.drawLine(0, y, qq.getWidth(), y, '#');
68                qq.drawLine(0, y+1, qq.getWidth(), y+1, '*');
69                qq.drawLine(0, y+2, qq.getWidth(), y+2, '-');
70             }
71
72             qq.setColor(Cucul.CUCUL_WHITE, Cucul.CUCUL_BLUE);   
73             qq.putStr(qq.getWidth() - 30,qq.getHeight() - 2," -=[ Powered by libcaca ]=- ");
74             qq.setColor(Cucul.CUCUL_WHITE, Cucul.CUCUL_BLACK);   
75 
76
77            kk.Refresh();
78            qq.Clear();
79           
80          }
81
82        /* Force deletion of our instances for fun */
83        qq.Dispose();
84        kk.Dispose();
85        }
86
87}
Note: See TracBrowser for help on using the repository browser.