From 66eebe567c6bb3202cf650ad4d4a0a146d75c68f Mon Sep 17 00:00:00 2001 From: Jean-Yves Lamoureux Date: Thu, 23 Nov 2006 20:22:03 +0000 Subject: [PATCH] * .Net : Fixed drawLine() and updated example (rasters rule) --- DotNet/Cucul.cs | 6 ++--- DotNet/test.cs | 61 ++++++++++++++++++++++++++++++------------------- 2 files changed, 40 insertions(+), 27 deletions(-) diff --git a/DotNet/Cucul.cs b/DotNet/Cucul.cs index a23384e..6f427c4 100644 --- a/DotNet/Cucul.cs +++ b/DotNet/Cucul.cs @@ -50,7 +50,7 @@ namespace libCucul [DllImport("libCucul.dll", CallingConvention=CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity] public static extern Int32 cucul_blit(IntPtr qq, Int32 x, Int32 y, IntPtr qq1, IntPtr qq2); [DllImport("libCucul.dll", CallingConvention=CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity] - public static extern Int32 cucul_draw_line(IntPtr qq, Int32 x1, Int32 y1, Int32 x2, Int32 y2, string c); + public static extern Int32 cucul_draw_line(IntPtr qq, Int32 x1, Int32 y1, Int32 x2, Int32 y2, Int32 c); [DllImport("libCucul.dll", CallingConvention=CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity] public static extern Int32 cucul_draw_polyline(IntPtr qq, Int32[] x, Int32[] y, Int32 n, IntPtr c); [DllImport("libCucul.dll", CallingConvention=CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity] @@ -190,7 +190,7 @@ namespace libCucul { return cucul_putchar(qq, x, y, c); } - public Int32 clearCanvas() + public Int32 Clear() { return cucul_clear_canvas(qq); } @@ -198,7 +198,7 @@ namespace libCucul { return cucul_blit(qq, x, y, qq1.get_cucul_t(), qq2.get_cucul_t()); } - public Int32 drawLine(Int32 x1, Int32 y1, Int32 x2, Int32 y2, string c) + public Int32 drawLine(Int32 x1, Int32 y1, Int32 x2, Int32 y2, Int32 c) { return cucul_draw_line(qq, x1, y1, x2, y2, c); } diff --git a/DotNet/test.cs b/DotNet/test.cs index b2c26bc..21f0bb4 100644 --- a/DotNet/test.cs +++ b/DotNet/test.cs @@ -21,53 +21,66 @@ class Test { public static void Main() { + int barCount = 6; Console.WriteLine("libcaca .NET test"); Console.WriteLine("(c) 2006 Jean-Yves Lamoureux "); /* Instanciate a cucul canvas */ Cucul qq = new Cucul(); - /* Get size, and change it */ - Console.WriteLine("Old size : {0}x{1}", qq.getWidth(), qq.getHeight()); - qq.setSize(80,50); - Console.WriteLine("Newsize : {0}x{1}", qq.getWidth(), qq.getHeight()); - + /* Random number. This is a static method, not to be used with previous instance */ Console.WriteLine("A random number : {0}", Cucul.Rand(0, 1337)); - /* Draw stuff on our canvas */ - qq.putChar(0,0, 'J'); - qq.setColor(Cucul.CUCUL_BLUE, Cucul.CUCUL_RED); - qq.drawLine(10, 15, 45, 27, "#"); - qq.putStr(10, 10, "Hello from .NET"); - Console.WriteLine("Char at 0,0 : {0}", qq.getChar(0,0)); - qq.Flip(); - - - /* Create a Dither instance */ - Dither dither = new Dither(32, 320, 200, 320, 0x00FF0000, 0x0000FF00, 0x000000FF, 0xFF000000); - dither.setBrightness((float)0.7); - string[] aalist = dither.getAntialiasList(); - Console.WriteLine("List : '{0}'", aalist[1]); /* We have a proper canvas, let's display it using Caca */ Caca kk = new Caca(qq); - kk.setDisplayTime(2000000); // Refresh every 2 seconds + kk.setDisplayTime(20000); // Refresh every 20 ms kk.setDisplayTitle("libcaca .NET Bindings test suite"); + double v; + Int32 y = 0; Event e = new Event(); - int startTime = kk.getDisplayTime(); + Int32 i; + + DateTime startTime = DateTime.Now; while(kk.getEvent(Event.type.KEY_RELEASE, e, 10) == 0) { - kk.Refresh(); - Console.WriteLine("Render time : {0}", kk.getDisplayTime()-startTime); + TimeSpan curTime = DateTime.Now - startTime; + double t = curTime.TotalMilliseconds; + qq.setColor(Cucul.CUCUL_WHITE, Cucul.CUCUL_BLACK); + for(i=0; i