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

Last change on this file since 1424 was 1424, checked in by Jean-Yves Lamoureux, 16 years ago
  • Added preliminary dither support to .NET bindings
  • Property svn:keywords set to Id
File size: 2.2 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 1424 2006-11-18 12:27:16Z 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        Console.WriteLine("libcaca .NET test");
25                Console.WriteLine("(c) 2006 Jean-Yves Lamoureux <jylam@lnxscene.org>");
26       
27        /* Instanciate a cucul canvas */
28        Cucul qq = new Cucul();
29
30        /* Get size, and change it */
31        Console.WriteLine("Old size : {0}x{1}", qq.getWidth(), qq.getHeight());
32        qq.setSize(80,50);
33        Console.WriteLine("Newsize  : {0}x{1}", qq.getWidth(), qq.getHeight());
34
35        /* Random number. This is a static method,
36           not to be used with previous instance */
37        Console.WriteLine("A random number : {0}", Cucul.Rand(0, 1337));
38
39        /* Draw stuff on our canvas */
40        qq.putChar(0,0, 'J');
41        qq.setColor(Cucul.CUCUL_BLUE, Cucul.CUCUL_RED);
42        qq.drawLine(10, 15, 45, 27, "#");
43        qq.putStr(10, 10, "Hello from .NET");
44        Console.WriteLine("Char at 0,0 : {0}", qq.getChar(0,0));
45        qq.Flip();
46
47
48        /* Create a Dither instance */
49        Dither dither = new Dither(32, 320, 200, 320, 0x00FF0000, 0x0000FF00, 0x000000FF, 0xFF000000);
50        dither.setBrightness((float)0.7);
51        string[] aalist = dither.getAntialiasList();
52        Console.WriteLine("List : '{0}'", aalist[1]);
53
54
55        /* We have a proper canvas, let's display it using Caca */
56        Caca kk = new Caca(qq);
57        kk.setDisplayTime(2000000); // Refresh every 2 seconds
58
59        kk.setDisplayTitle("libcaca .NET Bindings test suite");
60
61        Event e = new Event();
62        int startTime = kk.getDisplayTime();
63        while(kk.getEvent(Event.type.KEY_RELEASE, e, 10) == 0)
64          {
65          kk.Refresh();
66          Console.WriteLine("Render time : {0}", kk.getDisplayTime()-startTime);
67          }
68
69        /* Force deletion of our instance for fun */
70        qq.Dispose();
71        }
72
73}
Note: See TracBrowser for help on using the repository browser.