Changeset 1428
- Timestamp:
- Nov 23, 2006, 9:22:03 PM (16 years ago)
- Location:
- libcaca/trunk/DotNet
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
libcaca/trunk/DotNet/Cucul.cs
r1424 r1428 51 51 public static extern Int32 cucul_blit(IntPtr qq, Int32 x, Int32 y, IntPtr qq1, IntPtr qq2); 52 52 [DllImport("libCucul.dll", CallingConvention=CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity] 53 public static extern Int32 cucul_draw_line(IntPtr qq, Int32 x1, Int32 y1, Int32 x2, Int32 y2, stringc);53 public static extern Int32 cucul_draw_line(IntPtr qq, Int32 x1, Int32 y1, Int32 x2, Int32 y2, Int32 c); 54 54 [DllImport("libCucul.dll", CallingConvention=CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity] 55 55 public static extern Int32 cucul_draw_polyline(IntPtr qq, Int32[] x, Int32[] y, Int32 n, IntPtr c); … … 191 191 return cucul_putchar(qq, x, y, c); 192 192 } 193 public Int32 clearCanvas()193 public Int32 Clear() 194 194 { 195 195 return cucul_clear_canvas(qq); … … 199 199 return cucul_blit(qq, x, y, qq1.get_cucul_t(), qq2.get_cucul_t()); 200 200 } 201 public Int32 drawLine(Int32 x1, Int32 y1, Int32 x2, Int32 y2, stringc)201 public Int32 drawLine(Int32 x1, Int32 y1, Int32 x2, Int32 y2, Int32 c) 202 202 { 203 203 return cucul_draw_line(qq, x1, y1, x2, y2, c); -
libcaca/trunk/DotNet/test.cs
r1424 r1428 22 22 23 23 public static void Main() { 24 int barCount = 6; 24 25 Console.WriteLine("libcaca .NET test"); 25 26 Console.WriteLine("(c) 2006 Jean-Yves Lamoureux <jylam@lnxscene.org>"); … … 28 29 Cucul qq = new Cucul(); 29 30 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 31 35 32 /* Random number. This is a static method, 36 33 not to be used with previous instance */ 37 34 Console.WriteLine("A random number : {0}", Cucul.Rand(0, 1337)); 38 35 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 36 54 37 55 38 /* We have a proper canvas, let's display it using Caca */ 56 39 Caca kk = new Caca(qq); 57 kk.setDisplayTime(20000 00); // Refresh every 2 seconds40 kk.setDisplayTime(20000); // Refresh every 20 ms 58 41 59 42 kk.setDisplayTitle("libcaca .NET Bindings test suite"); 60 43 44 double v; 45 Int32 y = 0; 61 46 Event e = new Event(); 62 int startTime = kk.getDisplayTime(); 47 Int32 i; 48 49 DateTime startTime = DateTime.Now; 63 50 while(kk.getEvent(Event.type.KEY_RELEASE, e, 10) == 0) 64 51 { 65 kk.Refresh(); 66 Console.WriteLine("Render time : {0}", kk.getDisplayTime()-startTime); 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 67 79 } 68 80 69 /* Force deletion of our instance for fun */81 /* Force deletion of our instances for fun */ 70 82 qq.Dispose(); 83 kk.Dispose(); 71 84 } 72 85
Note: See TracChangeset
for help on using the changeset viewer.