ソースを参照

* Implemented getVersion() in the C# bindings.

* Slightly improved the C# test program.
tags/v0.99.beta14
Sam Hocevar sam 17年前
コミット
1c3f8fee16
3個のファイルの変更39行の追加6行の削除
  1. +13
    -1
      csharp/Caca.cs
  2. +8
    -1
      csharp/Cucul.cs
  3. +18
    -4
      csharp/test.cs

+ 13
- 1
csharp/Caca.cs ファイルの表示

@@ -21,6 +21,18 @@ using Cucul;

namespace Caca
{
/* Static libcaca stuff that does not fit in any object */
public static class Libcaca
{
[DllImport("libcaca.dll", CallingConvention=CallingConvention.Cdecl),
SuppressUnmanagedCodeSecurity]
private static extern IntPtr caca_get_version();
public static string getVersion()
{
return Marshal.PtrToStringAnsi(caca_get_version());
}
}

public enum CacaEventType
{
NONE = 0x0000,
@@ -148,7 +160,7 @@ namespace Caca
get
{
caca_get_event_key_utf8(cevent, utf8);
return Marshal.PtrToStringUni(utf8);
return Marshal.PtrToStringAnsi(utf8);
}
}



+ 8
- 1
csharp/Cucul.cs ファイルの表示

@@ -25,12 +25,19 @@ namespace Cucul
[DllImport("libcucul.dll", CallingConvention=CallingConvention.Cdecl),
SuppressUnmanagedCodeSecurity]
private static extern int cucul_rand(int min, int max);

public static int Rand(int min, int max)
{
return cucul_rand(min, max);
}

[DllImport("libcucul.dll", CallingConvention=CallingConvention.Cdecl),
SuppressUnmanagedCodeSecurity]
private static extern IntPtr cucul_get_version();
public static string getVersion()
{
return Marshal.PtrToStringAnsi(cucul_get_version());
}

public const int BLACK = 0x00,
BLUE = 0x01,
GREEN = 0x02,


+ 18
- 4
csharp/test.cs ファイルの表示

@@ -33,9 +33,6 @@ class DemoCanvas : CuculCanvas

table = new uint[16,16];
d = new CuculDither(32, 16, 16, 16 * 4, 0xff0000, 0xff00, 0xff, 0x0);
for(int y = 0; y < 16; y++)
for(int x = 0; x < 16; x++)
table[x,y] = (uint)((x + y) << 16) | (uint)(x << 8) | (uint)(y);
}

public void Draw()
@@ -45,6 +42,23 @@ class DemoCanvas : CuculCanvas

Clear();

double cos = Math.Cos(t / 500.0);
double sin = Math.Sin(t / 500.0);

for(int y = 0; y < 16; y++)
for(int x = 0; x < 16; x++)
{
double xt = (double)(x - 8);
double yt = (double)(y - 8);
int x2 = (int)(xt * cos + yt * sin + 8.0);
int y2 = (int)(xt * sin - yt * cos + 8.0);
if(x2 < 0) x2 = 0;
if(y2 < 0) y2 = 0;

table[x,y] = (uint)((x2 + y2) << 16)
| (uint)(x2 << 8)
| (uint)(y2);
}
ditherBitmap(0, 0, width, height, d, table);

setColorAnsi(Libcucul.WHITE, Libcucul.BLACK);
@@ -102,7 +116,7 @@ class Test
{
public static void Main()
{
Console.WriteLine("libcaca .NET test");
Console.WriteLine("libcaca {0} .NET test", Libcaca.getVersion());
Console.WriteLine("(c) 2006 Jean-Yves Lamoureux <jylam@lnxscene.org>");

/* Instanciate a cucul canvas */


読み込み中…
キャンセル
保存