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

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