- Timestamp:
- Nov 27, 2007, 2:55:41 AM (16 years ago)
- Location:
- libcaca/trunk/csharp
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
libcaca/trunk/csharp/Cucul.cs
r2081 r2082 805 805 return ret; 806 806 } 807 808 [DllImport("libcucul.dll", CallingConvention=CallingConvention.Cdecl), 809 SuppressUnmanagedCodeSecurity] 810 private static extern int cucul_render_canvas(IntPtr cv, IntPtr f, 811 IntPtr buf, int w, int h, 812 int pitch); 813 public int Render(CuculCanvas cv, uint[,] buf, int pitch) 814 { 815 GCHandle gch = GCHandle.Alloc(buf, GCHandleType.Pinned); 816 int ret = cucul_render_canvas(cv._cv, _font, 817 gch.AddrOfPinnedObject(), 818 buf.GetLength(0), buf.GetLength(1), 819 pitch); 820 gch.Free(); 821 return ret; 822 } 807 823 } 808 824 } -
libcaca/trunk/csharp/test.cs
r2081 r2082 28 28 private DateTime startTime; 29 29 private CuculDither d; 30 private Cucul Font f;30 private CuculCanvas scroll; 31 31 32 32 public DemoCanvas() … … 34 34 startTime = DateTime.Now; 35 35 36 image = new uint[16,16]; 37 d = new CuculDither(32, new Size(16, 16), 16 * 4, 38 0xff0000, 0xff00, 0xff, 0x0); 39 f = new CuculFont(CuculFont.getList()[0]); 40 f.getBlocks(); 36 string message = "LIBCACA *** 100% PURE WIN *** "; 37 38 scroll = new CuculCanvas(new Size(message.Length, 1)); 39 scroll.setColorAnsi(Libcucul.WHITE, Libcucul.BLACK); 40 scroll.putStr(new Point(0, 0), message); 41 42 CuculFont f = new CuculFont(CuculFont.getList()[0]); 43 int w = f.Size.Width * message.Length; 44 int h = f.Size.Height; 45 image = new uint[w, h]; 46 d = new CuculDither(32, new Size(w, h), w * 4, 47 0xff0000, 0xff00, 0xff, 0xff000000); 48 f.Render(scroll, image, image.GetLength(0) * 4); 41 49 } 42 50 … … 48 56 Clear(); 49 57 50 double cos = Math.Cos(t / 500.0); 51 double sin = Math.Sin(t / 500.0); 52 53 for(int y = 0; y < 16; y++) 54 for(int x = 0; x < 16; x++) 55 { 56 double xt = (double)(x - 8); 57 double yt = (double)(y - 8); 58 int x2 = (int)(xt * cos + yt * sin + 8.0); 59 int y2 = (int)(xt * sin - yt * cos + 8.0); 60 if(x2 < 0) x2 = 0; 61 if(y2 < 0) y2 = 0; 62 63 image[x,y] = (uint)((x2 + y2) << 16) 64 | (uint)(x2 << 8) 65 | (uint)(y2); 66 } 67 ditherBitmap(Rectangle, d, image); 58 int w = Size.Width; 59 int h = Size.Height; 60 int x = (int)(t / 10) % (6 * w); 61 int y = (int)(h * (2.0 + Math.Sin(t / 200.0)) / 4); 62 ditherBitmap(new Rectangle(- x, h / 2 - y, w * 6, y * 2), d, image); 63 ditherBitmap(new Rectangle(6 * w - x, h / 2 - y, w * 6, y * 2), d, image); 68 64 69 65 setColorAnsi(Libcucul.WHITE, Libcucul.BLACK);
Note: See TracChangeset
for help on using the changeset viewer.