@@ -18,13 +18,19 @@ using System.Runtime.InteropServices; | |||
using System.Security; | |||
using System.Drawing; | |||
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 int caca_rand(int min, int max); | |||
public static int Rand(int min, int max) | |||
{ | |||
return caca_rand(min, max); | |||
} | |||
[DllImport("libcaca.dll", CallingConvention=CallingConvention.Cdecl), | |||
SuppressUnmanagedCodeSecurity] | |||
private static extern IntPtr caca_get_version(); | |||
@@ -32,6 +38,30 @@ namespace Caca | |||
{ | |||
return Marshal.PtrToStringAnsi(caca_get_version()); | |||
} | |||
public const uint BLACK = 0x00, | |||
BLUE = 0x01, | |||
GREEN = 0x02, | |||
CYAN = 0x03, | |||
RED = 0x04, | |||
MAGENTA = 0x05, | |||
BROWN = 0x06, | |||
LIGHTGRAY = 0x07, | |||
DARKGRAY = 0x08, | |||
LIGHTBLUE = 0x09, | |||
LIGHTGREEN = 0x0a, | |||
LIGHTCYAN = 0x0b, | |||
LIGHTRED = 0x0c, | |||
LIGHTMAGENTA = 0x0d, | |||
YELLOW = 0x0e, | |||
WHITE = 0x0f, | |||
DEFAULT = 0x10, | |||
TRANSPARENT = 0x20; | |||
public const uint BOLD = 0x01, | |||
ITALICS = 0x02, | |||
UNDERLINE = 0x04, | |||
BLINK = 0x08; | |||
} | |||
public enum CacaEventType | |||
@@ -110,6 +140,899 @@ namespace Caca | |||
F15 = 0x128, | |||
} | |||
public class CacaCanvas : IDisposable | |||
{ | |||
public readonly IntPtr _c_cv; | |||
/* libcaca basic functions */ | |||
[DllImport("libcaca.dll", CallingConvention=CallingConvention.Cdecl), | |||
SuppressUnmanagedCodeSecurity] | |||
private static extern IntPtr caca_create_canvas(int w, int h); | |||
public CacaCanvas() | |||
{ | |||
_c_cv = caca_create_canvas(0, 0); | |||
} | |||
public CacaCanvas(Size s) | |||
{ | |||
_c_cv = caca_create_canvas(s.Width, s.Height); | |||
} | |||
public CacaCanvas(int w, int h) | |||
{ | |||
_c_cv = caca_create_canvas(h, w); | |||
} | |||
[DllImport("libcaca.dll", CallingConvention=CallingConvention.Cdecl), | |||
SuppressUnmanagedCodeSecurity] | |||
private static extern int caca_free_canvas(IntPtr cv); | |||
public void Dispose() | |||
{ | |||
/* FIXME: don't destroy ourselves if we're attached */ | |||
caca_free_canvas(_c_cv); | |||
GC.SuppressFinalize(this); | |||
} | |||
[DllImport("libcaca.dll", CallingConvention=CallingConvention.Cdecl), | |||
SuppressUnmanagedCodeSecurity] | |||
private static extern int caca_set_canvas_size(IntPtr cv, | |||
int w, int h); | |||
[DllImport("libcaca.dll", CallingConvention=CallingConvention.Cdecl), | |||
SuppressUnmanagedCodeSecurity] | |||
private static extern int caca_get_canvas_width(IntPtr cv); | |||
[DllImport("libcaca.dll", CallingConvention=CallingConvention.Cdecl), | |||
SuppressUnmanagedCodeSecurity] | |||
private static extern int caca_get_canvas_height(IntPtr cv); | |||
public Size Size | |||
{ | |||
get { return new Size(caca_get_canvas_width(_c_cv), | |||
caca_get_canvas_height(_c_cv)); } | |||
set { caca_set_canvas_size(_c_cv, value.Width, value.Height); } | |||
} | |||
public Rectangle Rectangle | |||
{ | |||
get { return new Rectangle(0, 0, caca_get_canvas_width(_c_cv), | |||
caca_get_canvas_height(_c_cv)); } | |||
set { caca_set_canvas_size(_c_cv, value.Width, value.Height); } | |||
} | |||
/* canvas drawing */ | |||
[DllImport("libcaca.dll", CallingConvention=CallingConvention.Cdecl), | |||
SuppressUnmanagedCodeSecurity] | |||
private static extern int caca_gotoxy(IntPtr cv, int x, int y); | |||
[DllImport("libcaca.dll", CallingConvention=CallingConvention.Cdecl), | |||
SuppressUnmanagedCodeSecurity] | |||
private static extern int caca_get_cursor_x(IntPtr cv); | |||
[DllImport("libcaca.dll", CallingConvention=CallingConvention.Cdecl), | |||
SuppressUnmanagedCodeSecurity] | |||
private static extern int caca_get_cursor_y(IntPtr cv); | |||
public Point Cursor | |||
{ | |||
get { return new Point(caca_get_cursor_x(_c_cv), | |||
caca_get_cursor_y(_c_cv)); } | |||
set { caca_gotoxy(_c_cv, value.X, value.Y); } | |||
} | |||
[DllImport("libcaca.dll", CallingConvention=CallingConvention.Cdecl), | |||
SuppressUnmanagedCodeSecurity] | |||
private static extern int caca_put_char(IntPtr cv, | |||
int x, int y, uint c); | |||
public int putChar(Point p, uint c) | |||
{ | |||
return caca_put_char(_c_cv, p.X, p.Y, c); | |||
} | |||
public int putChar(int x, int y, uint c) | |||
{ | |||
return caca_put_char(_c_cv, x, y, c); | |||
} | |||
[DllImport("libcaca.dll", CallingConvention=CallingConvention.Cdecl), | |||
SuppressUnmanagedCodeSecurity] | |||
private static extern uint caca_get_char(IntPtr cv, int x, int y); | |||
public uint getChar(Point p) | |||
{ | |||
return caca_get_char(_c_cv, p.X, p.Y); | |||
} | |||
public uint getChar(int x, int y) | |||
{ | |||
return caca_get_char(_c_cv, x, y); | |||
} | |||
[DllImport("libcaca.dll", CallingConvention=CallingConvention.Cdecl), | |||
SuppressUnmanagedCodeSecurity] | |||
private static extern int caca_put_str(IntPtr cv, | |||
int x, int y, string c); | |||
public int putStr(Point p, string c) | |||
{ | |||
return caca_put_str(_c_cv, p.X, p.Y, c); | |||
} | |||
public int putStr(int x, int y, string c) | |||
{ | |||
return caca_put_str(_c_cv, x, y, c); | |||
} | |||
[DllImport("libcaca.dll", CallingConvention=CallingConvention.Cdecl), | |||
SuppressUnmanagedCodeSecurity] | |||
private static extern int caca_get_attr(IntPtr cv, int x, int y); | |||
public int getAttr(Point p) | |||
{ | |||
return caca_get_attr(_c_cv, p.X, p.Y); | |||
} | |||
public int getAttr(int x, int y) | |||
{ | |||
return caca_get_attr(_c_cv, x, y); | |||
} | |||
[DllImport("libcaca.dll", CallingConvention=CallingConvention.Cdecl), | |||
SuppressUnmanagedCodeSecurity] | |||
private static extern int caca_set_attr(IntPtr cv, uint a); | |||
public int setAttr(uint a) | |||
{ | |||
return caca_set_attr(_c_cv, a); | |||
} | |||
[DllImport("libcaca.dll", CallingConvention=CallingConvention.Cdecl), | |||
SuppressUnmanagedCodeSecurity] | |||
private static extern int caca_put_attr(IntPtr cv, | |||
int x, int y, uint a); | |||
public int putAttr(Point p, uint a) | |||
{ | |||
return caca_put_attr(_c_cv, p.X, p.Y, a); | |||
} | |||
public int putAttr(int x, int y, uint a) | |||
{ | |||
return caca_put_attr(_c_cv, x, y, a); | |||
} | |||
[DllImport("libcaca.dll", CallingConvention=CallingConvention.Cdecl), | |||
SuppressUnmanagedCodeSecurity] | |||
private static extern int caca_set_color_ansi(IntPtr cv, | |||
byte fg, byte bg); | |||
public int setColorAnsi(uint fg, uint bg) | |||
{ | |||
return caca_set_color_ansi(_c_cv, (byte)fg, (byte)bg); | |||
} | |||
[DllImport("libcaca.dll", CallingConvention=CallingConvention.Cdecl), | |||
SuppressUnmanagedCodeSecurity] | |||
private static extern int caca_set_color_argb(IntPtr cv, | |||
uint fg, uint bg); | |||
public int setColorArgb(uint fg, uint bg) | |||
{ | |||
return caca_set_color_argb(_c_cv, fg, bg); | |||
} | |||
[DllImport("libcaca.dll", CallingConvention=CallingConvention.Cdecl), | |||
SuppressUnmanagedCodeSecurity] | |||
private static extern int caca_clear_canvas(IntPtr cv); | |||
public int Clear() | |||
{ | |||
return caca_clear_canvas(_c_cv); | |||
} | |||
[DllImport("libcaca.dll", CallingConvention=CallingConvention.Cdecl), | |||
SuppressUnmanagedCodeSecurity] | |||
private static extern int caca_set_canvas_handle(IntPtr cv, | |||
int x, int y); | |||
[DllImport("libcaca.dll", CallingConvention=CallingConvention.Cdecl), | |||
SuppressUnmanagedCodeSecurity] | |||
private static extern int caca_get_canvas_handle_x(IntPtr cv); | |||
[DllImport("libcaca.dll", CallingConvention=CallingConvention.Cdecl), | |||
SuppressUnmanagedCodeSecurity] | |||
private static extern int caca_get_canvas_handle_y(IntPtr cv); | |||
public Point Handle | |||
{ | |||
get { return new Point(caca_get_canvas_handle_x(_c_cv), | |||
caca_get_canvas_handle_y(_c_cv)); } | |||
set { caca_set_canvas_handle(_c_cv, value.X, value.Y); } | |||
} | |||
[DllImport("libcaca.dll", CallingConvention=CallingConvention.Cdecl), | |||
SuppressUnmanagedCodeSecurity] | |||
private static extern int caca_blit(IntPtr cv, int x, int y, | |||
IntPtr cv1, IntPtr cv2); | |||
public int Blit(Point p, CacaCanvas canvas) | |||
{ | |||
return caca_blit(_c_cv, p.X, p.Y, canvas._c_cv, IntPtr.Zero); | |||
} | |||
public int Blit(Point p, CacaCanvas cv, CacaCanvas mask) | |||
{ | |||
return caca_blit(_c_cv, p.X, p.Y, cv._c_cv, mask._c_cv); | |||
} | |||
public int Blit(int x, int y, CacaCanvas canvas) | |||
{ | |||
return caca_blit(_c_cv, x, y, canvas._c_cv, IntPtr.Zero); | |||
} | |||
public int Blit(int x, int y, CacaCanvas cv, CacaCanvas mask) | |||
{ | |||
return caca_blit(_c_cv, x, y, cv._c_cv, mask._c_cv); | |||
} | |||
[DllImport("libcaca.dll", CallingConvention=CallingConvention.Cdecl), | |||
SuppressUnmanagedCodeSecurity] | |||
private static extern int caca_set_canvas_boundaries(IntPtr cv, | |||
int x, int y, | |||
int h, int w); | |||
public int setBoundaries(Rectangle r) | |||
{ | |||
return caca_set_canvas_boundaries(_c_cv, r.X, r.Y, | |||
r.Width, r.Height); | |||
} | |||
public int setBoundaries(int x, int y, int w, int h) | |||
{ | |||
return caca_set_canvas_boundaries(_c_cv, x, y, w, h); | |||
} | |||
/* canvas transformation */ | |||
[DllImport("libcaca.dll", CallingConvention=CallingConvention.Cdecl), | |||
SuppressUnmanagedCodeSecurity] | |||
private static extern int caca_invert(IntPtr cv); | |||
public int Invert() | |||
{ | |||
return caca_invert(_c_cv); | |||
} | |||
[DllImport("libcaca.dll", CallingConvention=CallingConvention.Cdecl), | |||
SuppressUnmanagedCodeSecurity] | |||
private static extern int caca_flip(IntPtr cv); | |||
public int Flip() | |||
{ | |||
return caca_flip(_c_cv); | |||
} | |||
[DllImport("libcaca.dll", CallingConvention=CallingConvention.Cdecl), | |||
SuppressUnmanagedCodeSecurity] | |||
private static extern int caca_flop(IntPtr cv); | |||
public int Flop() | |||
{ | |||
return caca_flop(_c_cv); | |||
} | |||
[DllImport("libcaca.dll", CallingConvention=CallingConvention.Cdecl), | |||
SuppressUnmanagedCodeSecurity] | |||
private static extern int caca_rotate_180(IntPtr cv); | |||
public int Rotate180() | |||
{ | |||
return caca_rotate_180(_c_cv); | |||
} | |||
[DllImport("libcaca.dll", CallingConvention=CallingConvention.Cdecl), | |||
SuppressUnmanagedCodeSecurity] | |||
private static extern int caca_rotate_left(IntPtr cv); | |||
public int RotateLeft() | |||
{ | |||
return caca_rotate_left(_c_cv); | |||
} | |||
[DllImport("libcaca.dll", CallingConvention=CallingConvention.Cdecl), | |||
SuppressUnmanagedCodeSecurity] | |||
private static extern int caca_rotate_right(IntPtr cv); | |||
public int RotateRight() | |||
{ | |||
return caca_rotate_right(_c_cv); | |||
} | |||
[DllImport("libcaca.dll", CallingConvention=CallingConvention.Cdecl), | |||
SuppressUnmanagedCodeSecurity] | |||
private static extern int caca_stretch_left(IntPtr cv); | |||
public int StretchLeft() | |||
{ | |||
return caca_stretch_left(_c_cv); | |||
} | |||
[DllImport("libcaca.dll", CallingConvention=CallingConvention.Cdecl), | |||
SuppressUnmanagedCodeSecurity] | |||
private static extern int caca_stretch_right(IntPtr cv); | |||
public int StretchRight() | |||
{ | |||
return caca_stretch_right(_c_cv); | |||
} | |||
/* primitives drawing */ | |||
[DllImport("libcaca.dll", CallingConvention=CallingConvention.Cdecl), | |||
SuppressUnmanagedCodeSecurity] | |||
private static extern int caca_draw_line(IntPtr cv, int x1, int y1, | |||
int x2, int y2, uint c); | |||
public int drawLine(Point p1, Point p2, uint c) | |||
{ | |||
return caca_draw_line(_c_cv, p1.X, p1.Y, p2.X, p2.Y, c); | |||
} | |||
public int drawLine(int x1, int y1, int x2, int y2, uint c) | |||
{ | |||
return caca_draw_line(_c_cv, x1, y1, x2, y2, c); | |||
} | |||
[DllImport("libcaca.dll", CallingConvention=CallingConvention.Cdecl), | |||
SuppressUnmanagedCodeSecurity] | |||
private static extern int caca_draw_polyline(IntPtr cv, int[] x, | |||
int[] y, int n, uint c); | |||
public int drawPolyline(Point[] lp, uint c) | |||
{ | |||
int[] lx = new int[lp.Length]; | |||
int[] ly = new int[lp.Length]; | |||
for(int i = 0; i < lp.Length; i++) | |||
{ | |||
lx[i] = lp[i].X; | |||
ly[i] = lp[i].Y; | |||
} | |||
return caca_draw_polyline(_c_cv, lx, ly, lp.Length - 1, c); | |||
} | |||
public int drawPolyline(int[] lx, int[] ly, uint c) | |||
{ | |||
if(lx.Length != ly.Length) | |||
return -1; | |||
return caca_draw_polyline(_c_cv, lx, ly, lx.Length - 1, c); | |||
} | |||
[DllImport("libcaca.dll", CallingConvention=CallingConvention.Cdecl), | |||
SuppressUnmanagedCodeSecurity] | |||
private static extern int caca_draw_thin_line(IntPtr cv, int x1, | |||
int y1, int x2, int y2); | |||
public int drawThinLine(Point p1, Point p2) | |||
{ | |||
return caca_draw_thin_line(_c_cv, p1.X, p1.Y, p2.X, p2.Y); | |||
} | |||
public int drawThinLine(int x1, int y1, int x2, int y2) | |||
{ | |||
return caca_draw_thin_line(_c_cv, x1, y1, x2, y2); | |||
} | |||
[DllImport("libcaca.dll", CallingConvention=CallingConvention.Cdecl), | |||
SuppressUnmanagedCodeSecurity] | |||
private static extern int caca_draw_thin_polyline(IntPtr cv, int[] x, | |||
int[] y, int n); | |||
public int drawThinPolyline(Point[] lp) | |||
{ | |||
int[] lx = new int[lp.Length]; | |||
int[] ly = new int[lp.Length]; | |||
for(int i = 0; i < lp.Length; i++) | |||
{ | |||
lx[i] = lp[i].X; | |||
ly[i] = lp[i].Y; | |||
} | |||
return caca_draw_thin_polyline(_c_cv, lx, ly, lp.Length - 1); | |||
} | |||
public int drawThinPolyline(int[] lx, int[] ly) | |||
{ | |||
if(lx.Length != ly.Length) | |||
return -1; | |||
return caca_draw_thin_polyline(_c_cv, lx, ly, lx.Length - 1); | |||
} | |||
[DllImport("libcaca.dll", CallingConvention=CallingConvention.Cdecl), | |||
SuppressUnmanagedCodeSecurity] | |||
private static extern int caca_draw_circle(IntPtr cv, int x, int y, | |||
int r, uint c); | |||
public int drawCircle(Point p, int r, uint c) | |||
{ | |||
return caca_draw_circle(_c_cv, p.X, p.Y, r, c); | |||
} | |||
public int drawCircle(int x, int y, int r, uint c) | |||
{ | |||
return caca_draw_circle(_c_cv, x, y, r, c); | |||
} | |||
[DllImport("libcaca.dll", CallingConvention=CallingConvention.Cdecl), | |||
SuppressUnmanagedCodeSecurity] | |||
private static extern int caca_draw_ellipse(IntPtr cv, int x, int y, | |||
int a, int b, uint c); | |||
public int drawEllipse(Point p, int a, int b, uint c) | |||
{ | |||
return caca_draw_ellipse(_c_cv, p.X, p.Y, a, b, c); | |||
} | |||
public int drawEllipse(int x, int y, int a, int b, uint c) | |||
{ | |||
return caca_draw_ellipse(_c_cv, x, y, a, b, c); | |||
} | |||
[DllImport("libcaca.dll", CallingConvention=CallingConvention.Cdecl), | |||
SuppressUnmanagedCodeSecurity] | |||
private static extern int caca_draw_thin_ellipse(IntPtr cv, | |||
int x, int y, | |||
int a, int b); | |||
public int drawThinEllipse(Point p, int a, int b) | |||
{ | |||
return caca_draw_thin_ellipse(_c_cv, p.X, p.Y, a, b); | |||
} | |||
public int drawThinEllipse(int x, int y, int a, int b) | |||
{ | |||
return caca_draw_thin_ellipse(_c_cv, x, y, a, b); | |||
} | |||
[DllImport("libcaca.dll", CallingConvention=CallingConvention.Cdecl), | |||
SuppressUnmanagedCodeSecurity] | |||
private static extern int caca_fill_ellipse(IntPtr cv, int x, int y, | |||
int a, int b, uint c); | |||
public int fillEllipse(Point p, int a, int b, uint c) | |||
{ | |||
return caca_fill_ellipse(_c_cv, p.X, p.Y, a, b, c); | |||
} | |||
public int fillEllipse(int x, int y, int a, int b, uint c) | |||
{ | |||
return caca_fill_ellipse(_c_cv, x, y, a, b, c); | |||
} | |||
[DllImport("libcaca.dll", CallingConvention=CallingConvention.Cdecl), | |||
SuppressUnmanagedCodeSecurity] | |||
private static extern int caca_draw_box(IntPtr cv, int x, int y, | |||
int w, int h, uint c); | |||
public int drawBox(Rectangle r, uint c) | |||
{ | |||
return caca_draw_box(_c_cv, r.X, r.Y, r.Width, r.Height, c); | |||
} | |||
public int drawBox(int x, int y, int w, int h, uint c) | |||
{ | |||
return caca_draw_box(_c_cv, x, y, w, h, c); | |||
} | |||
[DllImport("libcaca.dll", CallingConvention=CallingConvention.Cdecl), | |||
SuppressUnmanagedCodeSecurity] | |||
private static extern int caca_draw_thin_box(IntPtr cv, int x, int y, | |||
int w, int h); | |||
public int drawThinBox(Rectangle r) | |||
{ | |||
return caca_draw_thin_box(_c_cv, r.X, r.Y, r.Width, r.Height); | |||
} | |||
public int drawThinBox(int x, int y, int w, int h) | |||
{ | |||
return caca_draw_thin_box(_c_cv, x, y, w, h); | |||
} | |||
[DllImport("libcaca.dll", CallingConvention=CallingConvention.Cdecl), | |||
SuppressUnmanagedCodeSecurity] | |||
private static extern int caca_draw_cp437_box(IntPtr cv, int x, int y, | |||
int w, int h); | |||
public int drawCp437Box(Rectangle r) | |||
{ | |||
return caca_draw_cp437_box(_c_cv, r.X, r.Y, r.Width, r.Height); | |||
} | |||
public int drawCp437Box(int x, int y, int w, int h) | |||
{ | |||
return caca_draw_cp437_box(_c_cv, x, y, w, h); | |||
} | |||
[DllImport("libcaca.dll", CallingConvention=CallingConvention.Cdecl), | |||
SuppressUnmanagedCodeSecurity] | |||
private static extern int caca_fill_box(IntPtr cv, int x, int y, | |||
int w, int h, uint c); | |||
public int fillBox(Rectangle r, uint c) | |||
{ | |||
return caca_fill_box(_c_cv, r.X, r.Y, r.Width, r.Height, c); | |||
} | |||
public int fillBox(int x, int y, int w, int h, uint c) | |||
{ | |||
return caca_fill_box(_c_cv, x, y, w, h, c); | |||
} | |||
[DllImport("libcaca.dll", CallingConvention=CallingConvention.Cdecl), | |||
SuppressUnmanagedCodeSecurity] | |||
private static extern int caca_draw_triangle(IntPtr cv, int x1, | |||
int y1, int x2, int y2, | |||
int x3, int y3, uint c); | |||
public int drawTriangle(Point p1, Point p2, Point p3, uint c) | |||
{ | |||
return caca_draw_triangle(_c_cv, p1.X, p1.Y, p2.X, p2.Y, | |||
p3.X, p3.Y, c); | |||
} | |||
public int drawTriangle(int x1, int y1, int x2, int y2, | |||
int x3, int y3, uint c) | |||
{ | |||
return caca_draw_triangle(_c_cv, x1, y1, x2, y2, x3, y3, c); | |||
} | |||
[DllImport("libcaca.dll", CallingConvention=CallingConvention.Cdecl), | |||
SuppressUnmanagedCodeSecurity] | |||
private static extern int caca_draw_thin_triangle(IntPtr cv, | |||
int x1, int y1, | |||
int x2, int y2, | |||
int x3, int y3); | |||
public int drawThinTriangle(Point p1, Point p2, Point p3) | |||
{ | |||
return caca_draw_thin_triangle(_c_cv, p1.X, p1.Y, p2.X, p2.Y, | |||
p3.X, p3.Y); | |||
} | |||
public int drawThinTriangle(int x1, int y1, int x2, int y2, | |||
int x3, int y3) | |||
{ | |||
return caca_draw_thin_triangle(_c_cv, x1, y1, x2, y2, x3, y3); | |||
} | |||
[DllImport("libcaca.dll", CallingConvention=CallingConvention.Cdecl), | |||
SuppressUnmanagedCodeSecurity] | |||
private static extern int caca_fill_triangle(IntPtr cv, int x1, | |||
int y1, int x2, int y2, | |||
int x3, int y3, uint c); | |||
public int fillTriangle(Point p1, Point p2, Point p3, uint c) | |||
{ | |||
return caca_fill_triangle(_c_cv, p1.X, p1.Y, p2.X, p2.Y, | |||
p3.X, p3.Y, c); | |||
} | |||
public int fillTriangle(int x1, int y1, int x2, int y2, | |||
int x3, int y3, uint c) | |||
{ | |||
return caca_fill_triangle(_c_cv, x1, y1, x2, y2, x3, y3, c); | |||
} | |||
/* frame handling */ | |||
[DllImport("libcaca.dll", CallingConvention=CallingConvention.Cdecl), | |||
SuppressUnmanagedCodeSecurity] | |||
private static extern int caca_get_frame_count(IntPtr cv); | |||
public int getFrameCount() | |||
{ | |||
return caca_get_frame_count(_c_cv); | |||
} | |||
[DllImport("libcaca.dll", CallingConvention=CallingConvention.Cdecl), | |||
SuppressUnmanagedCodeSecurity] | |||
private static extern int caca_set_frame(IntPtr cv, int f); | |||
public int setFrame(int f) | |||
{ | |||
return caca_set_frame(_c_cv, f); | |||
} | |||
[DllImport("libcaca.dll", CallingConvention=CallingConvention.Cdecl), | |||
SuppressUnmanagedCodeSecurity] | |||
private static extern string caca_get_frame_name(IntPtr cv); | |||
[DllImport("libcaca.dll", CallingConvention=CallingConvention.Cdecl), | |||
SuppressUnmanagedCodeSecurity] | |||
private static extern int caca_set_frame_name(IntPtr cv, string n); | |||
public string FrameName | |||
{ | |||
get { return caca_get_frame_name(_c_cv); } | |||
set { caca_set_frame_name(_c_cv, value); } | |||
} | |||
[DllImport("libcaca.dll", CallingConvention=CallingConvention.Cdecl), | |||
SuppressUnmanagedCodeSecurity] | |||
private static extern int caca_create_frame(IntPtr cv, int f); | |||
public int createFrame(int f) | |||
{ | |||
return caca_create_frame(_c_cv, f); | |||
} | |||
[DllImport("libcaca.dll", CallingConvention=CallingConvention.Cdecl), | |||
SuppressUnmanagedCodeSecurity] | |||
private static extern int caca_free_frame(IntPtr cv, int f); | |||
public int freeFrame(int f) | |||
{ | |||
return caca_free_frame(_c_cv, f); | |||
} | |||
/* bitmap dithering */ | |||
[DllImport("libcaca.dll", CallingConvention=CallingConvention.Cdecl), | |||
SuppressUnmanagedCodeSecurity] | |||
private static extern int caca_dither_bitmap(IntPtr c, int x, int y, | |||
int w, int h, | |||
IntPtr d, IntPtr data); | |||
public int ditherBitmap(Rectangle r, CacaDither d, object data) | |||
{ | |||
GCHandle gch = GCHandle.Alloc(data, GCHandleType.Pinned); | |||
int ret = caca_dither_bitmap(_c_cv, r.X, r.Y, r.Width, r.Height, | |||
d._dither, gch.AddrOfPinnedObject()); | |||
gch.Free(); | |||
return ret; | |||
} | |||
public int ditherBitmap(int x, int y, int w, int h, | |||
CacaDither d, object data) | |||
{ | |||
GCHandle gch = GCHandle.Alloc(data, GCHandleType.Pinned); | |||
int ret = caca_dither_bitmap(_c_cv, x, y, w, h, d._dither, | |||
gch.AddrOfPinnedObject()); | |||
gch.Free(); | |||
return ret; | |||
} | |||
} | |||
public class CacaAttr | |||
{ | |||
private uint _attr; | |||
public CacaAttr(uint attr) | |||
{ | |||
_attr = attr; | |||
} | |||
[DllImport("libcaca.dll", CallingConvention=CallingConvention.Cdecl), | |||
SuppressUnmanagedCodeSecurity] | |||
private static extern byte caca_attr_to_ansi(uint a); | |||
public byte toAnsi() | |||
{ | |||
return caca_attr_to_ansi(_attr); | |||
} | |||
[DllImport("libcaca.dll", CallingConvention=CallingConvention.Cdecl), | |||
SuppressUnmanagedCodeSecurity] | |||
private static extern byte caca_attr_to_ansi_fg(uint a); | |||
public byte toAnsiFg() | |||
{ | |||
return caca_attr_to_ansi_fg(_attr); | |||
} | |||
[DllImport("libcaca.dll", CallingConvention=CallingConvention.Cdecl), | |||
SuppressUnmanagedCodeSecurity] | |||
private static extern byte caca_attr_to_ansi_bg(uint a); | |||
public byte toAnsiBg() | |||
{ | |||
return caca_attr_to_ansi_bg(_attr); | |||
} | |||
} | |||
public class CacaDither : IDisposable | |||
{ | |||
public readonly IntPtr _dither; | |||
[DllImport("libcaca.dll", CallingConvention=CallingConvention.Cdecl), | |||
SuppressUnmanagedCodeSecurity] | |||
private static extern IntPtr caca_create_dither(int bpp, int w, | |||
int h, int pitch, | |||
uint rmask, | |||
uint gmask, | |||
uint bmask, | |||
uint amask); | |||
public CacaDither(int bpp, Size s, int pitch, | |||
uint rmask, uint gmask, uint bmask, uint amask) | |||
{ | |||
_dither = caca_create_dither(bpp, s.Width, s.Height, pitch, | |||
rmask, gmask, bmask, amask); | |||
} | |||
[DllImport("libcaca.dll", CallingConvention=CallingConvention.Cdecl), | |||
SuppressUnmanagedCodeSecurity] | |||
private static extern int caca_free_dither(IntPtr d); | |||
public void Dispose() | |||
{ | |||
caca_free_dither(_dither); | |||
GC.SuppressFinalize(this); | |||
} | |||
/* TODO: fix this shit */ | |||
[DllImport("libcaca.dll", CallingConvention=CallingConvention.Cdecl), | |||
SuppressUnmanagedCodeSecurity] | |||
private static extern int caca_set_dither_palette(IntPtr d, | |||
uint[] r, uint[] g, | |||
uint[] b, uint[] a); | |||
[DllImport("libcaca.dll", CallingConvention=CallingConvention.Cdecl), | |||
SuppressUnmanagedCodeSecurity] | |||
private static extern int caca_set_dither_brightness(IntPtr d, float b); | |||
[DllImport("libcaca.dll", CallingConvention=CallingConvention.Cdecl), | |||
SuppressUnmanagedCodeSecurity] | |||
private static extern int caca_set_dither_gamma(IntPtr d, float g); | |||
[DllImport("libcaca.dll", CallingConvention=CallingConvention.Cdecl), | |||
SuppressUnmanagedCodeSecurity] | |||
private static extern int caca_set_dither_contrast(IntPtr d, float c); | |||
[DllImport("libcaca.dll", CallingConvention=CallingConvention.Cdecl), | |||
SuppressUnmanagedCodeSecurity] | |||
private static extern int caca_set_dither_invert(IntPtr d, int i); | |||
[DllImport("libcaca.dll", CallingConvention=CallingConvention.Cdecl), | |||
SuppressUnmanagedCodeSecurity] | |||
private static extern int caca_set_dither_antialias(IntPtr d, string s); | |||
[DllImport("libcaca.dll", CallingConvention=CallingConvention.Cdecl), | |||
SuppressUnmanagedCodeSecurity] | |||
private static extern string[] caca_get_dither_antialias_list(IntPtr d); | |||
[DllImport("libcaca.dll", CallingConvention=CallingConvention.Cdecl), | |||
SuppressUnmanagedCodeSecurity] | |||
private static extern int caca_set_dither_color(IntPtr d, string s); | |||
[DllImport("libcaca.dll", CallingConvention=CallingConvention.Cdecl), | |||
SuppressUnmanagedCodeSecurity] | |||
private static extern string[] caca_get_dither_color_list(IntPtr d); | |||
[DllImport("libcaca.dll", CallingConvention=CallingConvention.Cdecl), | |||
SuppressUnmanagedCodeSecurity] | |||
private static extern int caca_set_dither_charset(IntPtr d, string s); | |||
[DllImport("libcaca.dll", CallingConvention=CallingConvention.Cdecl), | |||
SuppressUnmanagedCodeSecurity] | |||
private static extern string[] caca_get_dither_charset_list(IntPtr d); | |||
[DllImport("libcaca.dll", CallingConvention=CallingConvention.Cdecl), | |||
SuppressUnmanagedCodeSecurity] | |||
private static extern int caca_set_dither_mode(IntPtr d, string s); | |||
[DllImport("libcaca.dll", CallingConvention=CallingConvention.Cdecl), | |||
SuppressUnmanagedCodeSecurity] | |||
private static extern string[] caca_get_dither_mode_list(IntPtr d); | |||
public int setBrightness(float b) | |||
{ | |||
return caca_set_dither_brightness(_dither, b); | |||
} | |||
public int setGamma(float g) | |||
{ | |||
return caca_set_dither_gamma(_dither, g); | |||
} | |||
public int setContrast(float c) | |||
{ | |||
return caca_set_dither_contrast(_dither, c); | |||
} | |||
public int setInvert(int i) | |||
{ | |||
return caca_set_dither_invert(_dither, i); | |||
} | |||
public int setAntialias(string s) | |||
{ | |||
return caca_set_dither_antialias(_dither, s); | |||
} | |||
public int setColor(string s) | |||
{ | |||
return caca_set_dither_color(_dither, s); | |||
} | |||
public int setCharset(string s) | |||
{ | |||
return caca_set_dither_charset(_dither, s); | |||
} | |||
public int setMode(string s) | |||
{ | |||
return caca_set_dither_mode(_dither, s); | |||
} | |||
/* <FIXME> */ | |||
public string[] getAntialiasList() | |||
{ | |||
return caca_get_dither_antialias_list(_dither); | |||
} | |||
public string[] getColorList() | |||
{ | |||
return caca_get_dither_color_list(_dither); | |||
} | |||
public string[] getCharsetList() | |||
{ | |||
return caca_get_dither_charset_list(_dither); | |||
} | |||
public string[] getModeList() | |||
{ | |||
return caca_get_dither_mode_list(_dither); | |||
} | |||
/* </FIXME> */ | |||
} | |||
public class CacaFont : IDisposable | |||
{ | |||
private IntPtr _font; | |||
private GCHandle _gch; | |||
[DllImport("libcaca.dll", CallingConvention=CallingConvention.Cdecl), | |||
SuppressUnmanagedCodeSecurity] | |||
private static extern IntPtr caca_load_font(IntPtr data, uint len); | |||
public CacaFont(string s) | |||
{ | |||
IntPtr name = Marshal.StringToHGlobalAnsi(s); | |||
_font = caca_load_font(name, 0); | |||
Marshal.FreeHGlobal(name); | |||
} | |||
public CacaFont(byte[] buf) | |||
{ | |||
GCHandle _gch = GCHandle.Alloc(buf, GCHandleType.Pinned); | |||
_font = caca_load_font(_gch.AddrOfPinnedObject(), | |||
(uint)buf.Length); | |||
} | |||
[DllImport("libcaca.dll", CallingConvention=CallingConvention.Cdecl), | |||
SuppressUnmanagedCodeSecurity] | |||
private static extern int caca_free_font(IntPtr d); | |||
public void Dispose() | |||
{ | |||
caca_free_font(_font); | |||
_gch.Free(); | |||
GC.SuppressFinalize(this); | |||
} | |||
[DllImport("libcaca.dll", CallingConvention=CallingConvention.Cdecl), | |||
SuppressUnmanagedCodeSecurity] | |||
private static extern IntPtr caca_get_font_list(); | |||
public static string[] getList() | |||
{ | |||
IntPtr l = caca_get_font_list(); | |||
int size; | |||
for(size = 0; true; size++) | |||
if(Marshal.ReadIntPtr(l, IntPtr.Size * size) == IntPtr.Zero) | |||
break; | |||
string[] ret = new string[size]; | |||
for(int i = 0; i < size; i++) | |||
{ | |||
IntPtr s = Marshal.ReadIntPtr(l, IntPtr.Size * i); | |||
ret[i] = Marshal.PtrToStringAnsi(s); | |||
} | |||
return ret; | |||
} | |||
[DllImport("libcaca.dll", CallingConvention=CallingConvention.Cdecl), | |||
SuppressUnmanagedCodeSecurity] | |||
private static extern int caca_get_font_width(IntPtr font); | |||
[DllImport("libcaca.dll", CallingConvention=CallingConvention.Cdecl), | |||
SuppressUnmanagedCodeSecurity] | |||
private static extern int caca_get_font_height(IntPtr font); | |||
public Size Size | |||
{ | |||
get { return new Size(caca_get_font_width(_font), | |||
caca_get_font_height(_font)); } | |||
} | |||
[DllImport("libcaca.dll", CallingConvention=CallingConvention.Cdecl), | |||
SuppressUnmanagedCodeSecurity] | |||
private static extern IntPtr caca_get_font_blocks(IntPtr font); | |||
public int[,] getBlocks() | |||
{ | |||
IntPtr l = caca_get_font_blocks(_font); | |||
int size; | |||
for(size = 1; true; size += 2) | |||
if(Marshal.ReadIntPtr(l, IntPtr.Size * size) == IntPtr.Zero) | |||
break; | |||
int[,] ret = new int[size,2]; | |||
for(int i = 0; i < size; i++) | |||
{ | |||
ret[i,0] = (int)Marshal.ReadIntPtr(l, IntPtr.Size * i * 2); | |||
ret[i,1] = (int)Marshal.ReadIntPtr(l, IntPtr.Size * i * 2 + 1); | |||
} | |||
return ret; | |||
} | |||
[DllImport("libcaca.dll", CallingConvention=CallingConvention.Cdecl), | |||
SuppressUnmanagedCodeSecurity] | |||
private static extern int caca_render_canvas(IntPtr cv, IntPtr f, | |||
IntPtr buf, int w, int h, | |||
int pitch); | |||
public int Render(CacaCanvas cv, uint[,] buf, int pitch) | |||
{ | |||
GCHandle gch = GCHandle.Alloc(buf, GCHandleType.Pinned); | |||
int ret = caca_render_canvas(cv._c_cv, _font, | |||
gch.AddrOfPinnedObject(), | |||
buf.GetLength(0), buf.GetLength(1), | |||
pitch); | |||
gch.Free(); | |||
return ret; | |||
} | |||
} | |||
public class CacaEvent : IDisposable | |||
{ | |||
public IntPtr cevent; | |||
@@ -200,8 +1123,8 @@ namespace Caca | |||
public class CacaDisplay : IDisposable | |||
{ | |||
private CuculCanvas _cv; | |||
public CuculCanvas Canvas { get { return _cv; } } | |||
private CacaCanvas _cv; | |||
public CacaCanvas Canvas { get { return _cv; } } | |||
private IntPtr _c_cv; | |||
private IntPtr _c_dp; | |||
@@ -209,7 +1132,7 @@ namespace Caca | |||
[DllImport("libcaca.dll", CallingConvention=CallingConvention.Cdecl), | |||
SuppressUnmanagedCodeSecurity] | |||
private static extern IntPtr caca_create_display(IntPtr cv); | |||
public CacaDisplay(CuculCanvas cv) | |||
public CacaDisplay(CacaCanvas cv) | |||
{ | |||
_cv = cv; | |||
_c_cv = _cv._c_cv; | |||
@@ -219,9 +1142,9 @@ namespace Caca | |||
public CacaDisplay() | |||
{ | |||
/* XXX: we do not call caca_create_display() with a NULL | |||
* argument because it's then impossible to create a CuculCanvas | |||
* argument because it's then impossible to create a CacaCanvas | |||
* and I don't want to add a weird constructor */ | |||
_cv = new CuculCanvas(); | |||
_cv = new CacaCanvas(); | |||
_c_cv = _cv._c_cv; | |||
_c_dp = caca_create_display(_c_cv); | |||
} | |||
@@ -1,960 +0,0 @@ | |||
/* | |||
* libcucul .NET bindings for libcucul | |||
* Copyright (c) 2006 Jean-Yves Lamoureux <jylam@lnxscene.org> | |||
* 2007 Sam Hocevar <sam@zoy.org> | |||
* All Rights Reserved | |||
* | |||
* $Id$ | |||
* | |||
* This library is free software. It comes without any warranty, to | |||
* the extent permitted by applicable law. You can redistribute it | |||
* and/or modify it under the terms of the Do What The Fuck You Want | |||
* To Public License, Version 2, as published by Sam Hocevar. See | |||
* http://sam.zoy.org/wtfpl/COPYING for more details. | |||
*/ | |||
using System; | |||
using System.Runtime.InteropServices; | |||
using System.Security; | |||
using System.Drawing; | |||
namespace Cucul | |||
{ | |||
/* Static libcucul stuff that does not fit in any object */ | |||
public static class Libcucul | |||
{ | |||
[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 uint BLACK = 0x00, | |||
BLUE = 0x01, | |||
GREEN = 0x02, | |||
CYAN = 0x03, | |||
RED = 0x04, | |||
MAGENTA = 0x05, | |||
BROWN = 0x06, | |||
LIGHTGRAY = 0x07, | |||
DARKGRAY = 0x08, | |||
LIGHTBLUE = 0x09, | |||
LIGHTGREEN = 0x0a, | |||
LIGHTCYAN = 0x0b, | |||
LIGHTRED = 0x0c, | |||
LIGHTMAGENTA = 0x0d, | |||
YELLOW = 0x0e, | |||
WHITE = 0x0f, | |||
DEFAULT = 0x10, | |||
TRANSPARENT = 0x20; | |||
public const uint BOLD = 0x01, | |||
ITALICS = 0x02, | |||
UNDERLINE = 0x04, | |||
BLINK = 0x08; | |||
} | |||
public class CuculCanvas : IDisposable | |||
{ | |||
public readonly IntPtr _c_cv; | |||
/* libcucul basic functions */ | |||
[DllImport("libcucul.dll", CallingConvention=CallingConvention.Cdecl), | |||
SuppressUnmanagedCodeSecurity] | |||
private static extern IntPtr cucul_create_canvas(int w, int h); | |||
public CuculCanvas() | |||
{ | |||
_c_cv = cucul_create_canvas(0, 0); | |||
} | |||
public CuculCanvas(Size s) | |||
{ | |||
_c_cv = cucul_create_canvas(s.Width, s.Height); | |||
} | |||
public CuculCanvas(int w, int h) | |||
{ | |||
_c_cv = cucul_create_canvas(h, w); | |||
} | |||
[DllImport("libcucul.dll", CallingConvention=CallingConvention.Cdecl), | |||
SuppressUnmanagedCodeSecurity] | |||
private static extern int cucul_free_canvas(IntPtr cv); | |||
public void Dispose() | |||
{ | |||
/* FIXME: don't destroy ourselves if we're attached */ | |||
cucul_free_canvas(_c_cv); | |||
GC.SuppressFinalize(this); | |||
} | |||
[DllImport("libcucul.dll", CallingConvention=CallingConvention.Cdecl), | |||
SuppressUnmanagedCodeSecurity] | |||
private static extern int cucul_set_canvas_size(IntPtr cv, | |||
int w, int h); | |||
[DllImport("libcucul.dll", CallingConvention=CallingConvention.Cdecl), | |||
SuppressUnmanagedCodeSecurity] | |||
private static extern int cucul_get_canvas_width(IntPtr cv); | |||
[DllImport("libcucul.dll", CallingConvention=CallingConvention.Cdecl), | |||
SuppressUnmanagedCodeSecurity] | |||
private static extern int cucul_get_canvas_height(IntPtr cv); | |||
public Size Size | |||
{ | |||
get { return new Size(cucul_get_canvas_width(_c_cv), | |||
cucul_get_canvas_height(_c_cv)); } | |||
set { cucul_set_canvas_size(_c_cv, value.Width, value.Height); } | |||
} | |||
public Rectangle Rectangle | |||
{ | |||
get { return new Rectangle(0, 0, cucul_get_canvas_width(_c_cv), | |||
cucul_get_canvas_height(_c_cv)); } | |||
set { cucul_set_canvas_size(_c_cv, value.Width, value.Height); } | |||
} | |||
/* canvas drawing */ | |||
[DllImport("libcucul.dll", CallingConvention=CallingConvention.Cdecl), | |||
SuppressUnmanagedCodeSecurity] | |||
private static extern int cucul_gotoxy(IntPtr cv, int x, int y); | |||
[DllImport("libcucul.dll", CallingConvention=CallingConvention.Cdecl), | |||
SuppressUnmanagedCodeSecurity] | |||
private static extern int cucul_get_cursor_x(IntPtr cv); | |||
[DllImport("libcucul.dll", CallingConvention=CallingConvention.Cdecl), | |||
SuppressUnmanagedCodeSecurity] | |||
private static extern int cucul_get_cursor_y(IntPtr cv); | |||
public Point Cursor | |||
{ | |||
get { return new Point(cucul_get_cursor_x(_c_cv), | |||
cucul_get_cursor_y(_c_cv)); } | |||
set { cucul_gotoxy(_c_cv, value.X, value.Y); } | |||
} | |||
[DllImport("libcucul.dll", CallingConvention=CallingConvention.Cdecl), | |||
SuppressUnmanagedCodeSecurity] | |||
private static extern int cucul_put_char(IntPtr cv, | |||
int x, int y, uint c); | |||
public int putChar(Point p, uint c) | |||
{ | |||
return cucul_put_char(_c_cv, p.X, p.Y, c); | |||
} | |||
public int putChar(int x, int y, uint c) | |||
{ | |||
return cucul_put_char(_c_cv, x, y, c); | |||
} | |||
[DllImport("libcucul.dll", CallingConvention=CallingConvention.Cdecl), | |||
SuppressUnmanagedCodeSecurity] | |||
private static extern uint cucul_get_char(IntPtr cv, int x, int y); | |||
public uint getChar(Point p) | |||
{ | |||
return cucul_get_char(_c_cv, p.X, p.Y); | |||
} | |||
public uint getChar(int x, int y) | |||
{ | |||
return cucul_get_char(_c_cv, x, y); | |||
} | |||
[DllImport("libcucul.dll", CallingConvention=CallingConvention.Cdecl), | |||
SuppressUnmanagedCodeSecurity] | |||
private static extern int cucul_put_str(IntPtr cv, | |||
int x, int y, string c); | |||
public int putStr(Point p, string c) | |||
{ | |||
return cucul_put_str(_c_cv, p.X, p.Y, c); | |||
} | |||
public int putStr(int x, int y, string c) | |||
{ | |||
return cucul_put_str(_c_cv, x, y, c); | |||
} | |||
[DllImport("libcucul.dll", CallingConvention=CallingConvention.Cdecl), | |||
SuppressUnmanagedCodeSecurity] | |||
private static extern int cucul_get_attr(IntPtr cv, int x, int y); | |||
public int getAttr(Point p) | |||
{ | |||
return cucul_get_attr(_c_cv, p.X, p.Y); | |||
} | |||
public int getAttr(int x, int y) | |||
{ | |||
return cucul_get_attr(_c_cv, x, y); | |||
} | |||
[DllImport("libcucul.dll", CallingConvention=CallingConvention.Cdecl), | |||
SuppressUnmanagedCodeSecurity] | |||
private static extern int cucul_set_attr(IntPtr cv, uint a); | |||
public int setAttr(uint a) | |||
{ | |||
return cucul_set_attr(_c_cv, a); | |||
} | |||
[DllImport("libcucul.dll", CallingConvention=CallingConvention.Cdecl), | |||
SuppressUnmanagedCodeSecurity] | |||
private static extern int cucul_put_attr(IntPtr cv, | |||
int x, int y, uint a); | |||
public int putAttr(Point p, uint a) | |||
{ | |||
return cucul_put_attr(_c_cv, p.X, p.Y, a); | |||
} | |||
public int putAttr(int x, int y, uint a) | |||
{ | |||
return cucul_put_attr(_c_cv, x, y, a); | |||
} | |||
[DllImport("libcucul.dll", CallingConvention=CallingConvention.Cdecl), | |||
SuppressUnmanagedCodeSecurity] | |||
private static extern int cucul_set_color_ansi(IntPtr cv, | |||
byte fg, byte bg); | |||
public int setColorAnsi(uint fg, uint bg) | |||
{ | |||
return cucul_set_color_ansi(_c_cv, (byte)fg, (byte)bg); | |||
} | |||
[DllImport("libcucul.dll", CallingConvention=CallingConvention.Cdecl), | |||
SuppressUnmanagedCodeSecurity] | |||
private static extern int cucul_set_color_argb(IntPtr cv, | |||
uint fg, uint bg); | |||
public int setColorArgb(uint fg, uint bg) | |||
{ | |||
return cucul_set_color_argb(_c_cv, fg, bg); | |||
} | |||
[DllImport("libcucul.dll", CallingConvention=CallingConvention.Cdecl), | |||
SuppressUnmanagedCodeSecurity] | |||
private static extern int cucul_clear_canvas(IntPtr cv); | |||
public int Clear() | |||
{ | |||
return cucul_clear_canvas(_c_cv); | |||
} | |||
[DllImport("libcucul.dll", CallingConvention=CallingConvention.Cdecl), | |||
SuppressUnmanagedCodeSecurity] | |||
private static extern int cucul_set_canvas_handle(IntPtr cv, | |||
int x, int y); | |||
[DllImport("libcucul.dll", CallingConvention=CallingConvention.Cdecl), | |||
SuppressUnmanagedCodeSecurity] | |||
private static extern int cucul_get_canvas_handle_x(IntPtr cv); | |||
[DllImport("libcucul.dll", CallingConvention=CallingConvention.Cdecl), | |||
SuppressUnmanagedCodeSecurity] | |||
private static extern int cucul_get_canvas_handle_y(IntPtr cv); | |||
public Point Handle | |||
{ | |||
get { return new Point(cucul_get_canvas_handle_x(_c_cv), | |||
cucul_get_canvas_handle_y(_c_cv)); } | |||
set { cucul_set_canvas_handle(_c_cv, value.X, value.Y); } | |||
} | |||
[DllImport("libcucul.dll", CallingConvention=CallingConvention.Cdecl), | |||
SuppressUnmanagedCodeSecurity] | |||
private static extern int cucul_blit(IntPtr cv, int x, int y, | |||
IntPtr cv1, IntPtr cv2); | |||
public int Blit(Point p, CuculCanvas canvas) | |||
{ | |||
return cucul_blit(_c_cv, p.X, p.Y, canvas._c_cv, IntPtr.Zero); | |||
} | |||
public int Blit(Point p, CuculCanvas cv, CuculCanvas mask) | |||
{ | |||
return cucul_blit(_c_cv, p.X, p.Y, cv._c_cv, mask._c_cv); | |||
} | |||
public int Blit(int x, int y, CuculCanvas canvas) | |||
{ | |||
return cucul_blit(_c_cv, x, y, canvas._c_cv, IntPtr.Zero); | |||
} | |||
public int Blit(int x, int y, CuculCanvas cv, CuculCanvas mask) | |||
{ | |||
return cucul_blit(_c_cv, x, y, cv._c_cv, mask._c_cv); | |||
} | |||
[DllImport("libcucul.dll", CallingConvention=CallingConvention.Cdecl), | |||
SuppressUnmanagedCodeSecurity] | |||
private static extern int cucul_set_canvas_boundaries(IntPtr cv, | |||
int x, int y, | |||
int h, int w); | |||
public int setBoundaries(Rectangle r) | |||
{ | |||
return cucul_set_canvas_boundaries(_c_cv, r.X, r.Y, | |||
r.Width, r.Height); | |||
} | |||
public int setBoundaries(int x, int y, int w, int h) | |||
{ | |||
return cucul_set_canvas_boundaries(_c_cv, x, y, w, h); | |||
} | |||
/* canvas transformation */ | |||
[DllImport("libcucul.dll", CallingConvention=CallingConvention.Cdecl), | |||
SuppressUnmanagedCodeSecurity] | |||
private static extern int cucul_invert(IntPtr cv); | |||
public int Invert() | |||
{ | |||
return cucul_invert(_c_cv); | |||
} | |||
[DllImport("libcucul.dll", CallingConvention=CallingConvention.Cdecl), | |||
SuppressUnmanagedCodeSecurity] | |||
private static extern int cucul_flip(IntPtr cv); | |||
public int Flip() | |||
{ | |||
return cucul_flip(_c_cv); | |||
} | |||
[DllImport("libcucul.dll", CallingConvention=CallingConvention.Cdecl), | |||
SuppressUnmanagedCodeSecurity] | |||
private static extern int cucul_flop(IntPtr cv); | |||
public int Flop() | |||
{ | |||
return cucul_flop(_c_cv); | |||
} | |||
[DllImport("libcucul.dll", CallingConvention=CallingConvention.Cdecl), | |||
SuppressUnmanagedCodeSecurity] | |||
private static extern int cucul_rotate_180(IntPtr cv); | |||
public int Rotate180() | |||
{ | |||
return cucul_rotate_180(_c_cv); | |||
} | |||
[DllImport("libcucul.dll", CallingConvention=CallingConvention.Cdecl), | |||
SuppressUnmanagedCodeSecurity] | |||
private static extern int cucul_rotate_left(IntPtr cv); | |||
public int RotateLeft() | |||
{ | |||
return cucul_rotate_left(_c_cv); | |||
} | |||
[DllImport("libcucul.dll", CallingConvention=CallingConvention.Cdecl), | |||
SuppressUnmanagedCodeSecurity] | |||
private static extern int cucul_rotate_right(IntPtr cv); | |||
public int RotateRight() | |||
{ | |||
return cucul_rotate_right(_c_cv); | |||
} | |||
[DllImport("libcucul.dll", CallingConvention=CallingConvention.Cdecl), | |||
SuppressUnmanagedCodeSecurity] | |||
private static extern int cucul_stretch_left(IntPtr cv); | |||
public int StretchLeft() | |||
{ | |||
return cucul_stretch_left(_c_cv); | |||
} | |||
[DllImport("libcucul.dll", CallingConvention=CallingConvention.Cdecl), | |||
SuppressUnmanagedCodeSecurity] | |||
private static extern int cucul_stretch_right(IntPtr cv); | |||
public int StretchRight() | |||
{ | |||
return cucul_stretch_right(_c_cv); | |||
} | |||
/* primitives drawing */ | |||
[DllImport("libcucul.dll", CallingConvention=CallingConvention.Cdecl), | |||
SuppressUnmanagedCodeSecurity] | |||
private static extern int cucul_draw_line(IntPtr cv, int x1, int y1, | |||
int x2, int y2, uint c); | |||
public int drawLine(Point p1, Point p2, uint c) | |||
{ | |||
return cucul_draw_line(_c_cv, p1.X, p1.Y, p2.X, p2.Y, c); | |||
} | |||
public int drawLine(int x1, int y1, int x2, int y2, uint c) | |||
{ | |||
return cucul_draw_line(_c_cv, x1, y1, x2, y2, c); | |||
} | |||
[DllImport("libcucul.dll", CallingConvention=CallingConvention.Cdecl), | |||
SuppressUnmanagedCodeSecurity] | |||
private static extern int cucul_draw_polyline(IntPtr cv, int[] x, | |||
int[] y, int n, uint c); | |||
public int drawPolyline(Point[] lp, uint c) | |||
{ | |||
int[] lx = new int[lp.Length]; | |||
int[] ly = new int[lp.Length]; | |||
for(int i = 0; i < lp.Length; i++) | |||
{ | |||
lx[i] = lp[i].X; | |||
ly[i] = lp[i].Y; | |||
} | |||
return cucul_draw_polyline(_c_cv, lx, ly, lp.Length - 1, c); | |||
} | |||
public int drawPolyline(int[] lx, int[] ly, uint c) | |||
{ | |||
if(lx.Length != ly.Length) | |||
return -1; | |||
return cucul_draw_polyline(_c_cv, lx, ly, lx.Length - 1, c); | |||
} | |||
[DllImport("libcucul.dll", CallingConvention=CallingConvention.Cdecl), | |||
SuppressUnmanagedCodeSecurity] | |||
private static extern int cucul_draw_thin_line(IntPtr cv, int x1, | |||
int y1, int x2, int y2); | |||
public int drawThinLine(Point p1, Point p2) | |||
{ | |||
return cucul_draw_thin_line(_c_cv, p1.X, p1.Y, p2.X, p2.Y); | |||
} | |||
public int drawThinLine(int x1, int y1, int x2, int y2) | |||
{ | |||
return cucul_draw_thin_line(_c_cv, x1, y1, x2, y2); | |||
} | |||
[DllImport("libcucul.dll", CallingConvention=CallingConvention.Cdecl), | |||
SuppressUnmanagedCodeSecurity] | |||
private static extern int cucul_draw_thin_polyline(IntPtr cv, int[] x, | |||
int[] y, int n); | |||
public int drawThinPolyline(Point[] lp) | |||
{ | |||
int[] lx = new int[lp.Length]; | |||
int[] ly = new int[lp.Length]; | |||
for(int i = 0; i < lp.Length; i++) | |||
{ | |||
lx[i] = lp[i].X; | |||
ly[i] = lp[i].Y; | |||
} | |||
return cucul_draw_thin_polyline(_c_cv, lx, ly, lp.Length - 1); | |||
} | |||
public int drawThinPolyline(int[] lx, int[] ly) | |||
{ | |||
if(lx.Length != ly.Length) | |||
return -1; | |||
return cucul_draw_thin_polyline(_c_cv, lx, ly, lx.Length - 1); | |||
} | |||
[DllImport("libcucul.dll", CallingConvention=CallingConvention.Cdecl), | |||
SuppressUnmanagedCodeSecurity] | |||
private static extern int cucul_draw_circle(IntPtr cv, int x, int y, | |||
int r, uint c); | |||
public int drawCircle(Point p, int r, uint c) | |||
{ | |||
return cucul_draw_circle(_c_cv, p.X, p.Y, r, c); | |||
} | |||
public int drawCircle(int x, int y, int r, uint c) | |||
{ | |||
return cucul_draw_circle(_c_cv, x, y, r, c); | |||
} | |||
[DllImport("libcucul.dll", CallingConvention=CallingConvention.Cdecl), | |||
SuppressUnmanagedCodeSecurity] | |||
private static extern int cucul_draw_ellipse(IntPtr cv, int x, int y, | |||
int a, int b, uint c); | |||
public int drawEllipse(Point p, int a, int b, uint c) | |||
{ | |||
return cucul_draw_ellipse(_c_cv, p.X, p.Y, a, b, c); | |||
} | |||
public int drawEllipse(int x, int y, int a, int b, uint c) | |||
{ | |||
return cucul_draw_ellipse(_c_cv, x, y, a, b, c); | |||
} | |||
[DllImport("libcucul.dll", CallingConvention=CallingConvention.Cdecl), | |||
SuppressUnmanagedCodeSecurity] | |||
private static extern int cucul_draw_thin_ellipse(IntPtr cv, | |||
int x, int y, | |||
int a, int b); | |||
public int drawThinEllipse(Point p, int a, int b) | |||
{ | |||
return cucul_draw_thin_ellipse(_c_cv, p.X, p.Y, a, b); | |||
} | |||
public int drawThinEllipse(int x, int y, int a, int b) | |||
{ | |||
return cucul_draw_thin_ellipse(_c_cv, x, y, a, b); | |||
} | |||
[DllImport("libcucul.dll", CallingConvention=CallingConvention.Cdecl), | |||
SuppressUnmanagedCodeSecurity] | |||
private static extern int cucul_fill_ellipse(IntPtr cv, int x, int y, | |||
int a, int b, uint c); | |||
public int fillEllipse(Point p, int a, int b, uint c) | |||
{ | |||
return cucul_fill_ellipse(_c_cv, p.X, p.Y, a, b, c); | |||
} | |||
public int fillEllipse(int x, int y, int a, int b, uint c) | |||
{ | |||
return cucul_fill_ellipse(_c_cv, x, y, a, b, c); | |||
} | |||
[DllImport("libcucul.dll", CallingConvention=CallingConvention.Cdecl), | |||
SuppressUnmanagedCodeSecurity] | |||
private static extern int cucul_draw_box(IntPtr cv, int x, int y, | |||
int w, int h, uint c); | |||
public int drawBox(Rectangle r, uint c) | |||
{ | |||
return cucul_draw_box(_c_cv, r.X, r.Y, r.Width, r.Height, c); | |||
} | |||
public int drawBox(int x, int y, int w, int h, uint c) | |||
{ | |||
return cucul_draw_box(_c_cv, x, y, w, h, c); | |||
} | |||
[DllImport("libcucul.dll", CallingConvention=CallingConvention.Cdecl), | |||
SuppressUnmanagedCodeSecurity] | |||
private static extern int cucul_draw_thin_box(IntPtr cv, int x, int y, | |||
int w, int h); | |||
public int drawThinBox(Rectangle r) | |||
{ | |||
return cucul_draw_thin_box(_c_cv, r.X, r.Y, r.Width, r.Height); | |||
} | |||
public int drawThinBox(int x, int y, int w, int h) | |||
{ | |||
return cucul_draw_thin_box(_c_cv, x, y, w, h); | |||
} | |||
[DllImport("libcucul.dll", CallingConvention=CallingConvention.Cdecl), | |||
SuppressUnmanagedCodeSecurity] | |||
private static extern int cucul_draw_cp437_box(IntPtr cv, int x, int y, | |||
int w, int h); | |||
public int drawCp437Box(Rectangle r) | |||
{ | |||
return cucul_draw_cp437_box(_c_cv, r.X, r.Y, r.Width, r.Height); | |||
} | |||
public int drawCp437Box(int x, int y, int w, int h) | |||
{ | |||
return cucul_draw_cp437_box(_c_cv, x, y, w, h); | |||
} | |||
[DllImport("libcucul.dll", CallingConvention=CallingConvention.Cdecl), | |||
SuppressUnmanagedCodeSecurity] | |||
private static extern int cucul_fill_box(IntPtr cv, int x, int y, | |||
int w, int h, uint c); | |||
public int fillBox(Rectangle r, uint c) | |||
{ | |||
return cucul_fill_box(_c_cv, r.X, r.Y, r.Width, r.Height, c); | |||
} | |||
public int fillBox(int x, int y, int w, int h, uint c) | |||
{ | |||
return cucul_fill_box(_c_cv, x, y, w, h, c); | |||
} | |||
[DllImport("libcucul.dll", CallingConvention=CallingConvention.Cdecl), | |||
SuppressUnmanagedCodeSecurity] | |||
private static extern int cucul_draw_triangle(IntPtr cv, int x1, | |||
int y1, int x2, int y2, | |||
int x3, int y3, uint c); | |||
public int drawTriangle(Point p1, Point p2, Point p3, uint c) | |||
{ | |||
return cucul_draw_triangle(_c_cv, p1.X, p1.Y, p2.X, p2.Y, | |||
p3.X, p3.Y, c); | |||
} | |||
public int drawTriangle(int x1, int y1, int x2, int y2, | |||
int x3, int y3, uint c) | |||
{ | |||
return cucul_draw_triangle(_c_cv, x1, y1, x2, y2, x3, y3, c); | |||
} | |||
[DllImport("libcucul.dll", CallingConvention=CallingConvention.Cdecl), | |||
SuppressUnmanagedCodeSecurity] | |||
private static extern int cucul_draw_thin_triangle(IntPtr cv, | |||
int x1, int y1, | |||
int x2, int y2, | |||
int x3, int y3); | |||
public int drawThinTriangle(Point p1, Point p2, Point p3) | |||
{ | |||
return cucul_draw_thin_triangle(_c_cv, p1.X, p1.Y, p2.X, p2.Y, | |||
p3.X, p3.Y); | |||
} | |||
public int drawThinTriangle(int x1, int y1, int x2, int y2, | |||
int x3, int y3) | |||
{ | |||
return cucul_draw_thin_triangle(_c_cv, x1, y1, x2, y2, x3, y3); | |||
} | |||
[DllImport("libcucul.dll", CallingConvention=CallingConvention.Cdecl), | |||
SuppressUnmanagedCodeSecurity] | |||
private static extern int cucul_fill_triangle(IntPtr cv, int x1, | |||
int y1, int x2, int y2, | |||
int x3, int y3, uint c); | |||
public int fillTriangle(Point p1, Point p2, Point p3, uint c) | |||
{ | |||
return cucul_fill_triangle(_c_cv, p1.X, p1.Y, p2.X, p2.Y, | |||
p3.X, p3.Y, c); | |||
} | |||
public int fillTriangle(int x1, int y1, int x2, int y2, | |||
int x3, int y3, uint c) | |||
{ | |||
return cucul_fill_triangle(_c_cv, x1, y1, x2, y2, x3, y3, c); | |||
} | |||
/* frame handling */ | |||
[DllImport("libcucul.dll", CallingConvention=CallingConvention.Cdecl), | |||
SuppressUnmanagedCodeSecurity] | |||
private static extern int cucul_get_frame_count(IntPtr cv); | |||
public int getFrameCount() | |||
{ | |||
return cucul_get_frame_count(_c_cv); | |||
} | |||
[DllImport("libcucul.dll", CallingConvention=CallingConvention.Cdecl), | |||
SuppressUnmanagedCodeSecurity] | |||
private static extern int cucul_set_frame(IntPtr cv, int f); | |||
public int setFrame(int f) | |||
{ | |||
return cucul_set_frame(_c_cv, f); | |||
} | |||
[DllImport("libcucul.dll", CallingConvention=CallingConvention.Cdecl), | |||
SuppressUnmanagedCodeSecurity] | |||
private static extern string cucul_get_frame_name(IntPtr cv); | |||
[DllImport("libcucul.dll", CallingConvention=CallingConvention.Cdecl), | |||
SuppressUnmanagedCodeSecurity] | |||
private static extern int cucul_set_frame_name(IntPtr cv, string n); | |||
public string FrameName | |||
{ | |||
get { return cucul_get_frame_name(_c_cv); } | |||
set { cucul_set_frame_name(_c_cv, value); } | |||
} | |||
[DllImport("libcucul.dll", CallingConvention=CallingConvention.Cdecl), | |||
SuppressUnmanagedCodeSecurity] | |||
private static extern int cucul_create_frame(IntPtr cv, int f); | |||
public int createFrame(int f) | |||
{ | |||
return cucul_create_frame(_c_cv, f); | |||
} | |||
[DllImport("libcucul.dll", CallingConvention=CallingConvention.Cdecl), | |||
SuppressUnmanagedCodeSecurity] | |||
private static extern int cucul_free_frame(IntPtr cv, int f); | |||
public int freeFrame(int f) | |||
{ | |||
return cucul_free_frame(_c_cv, f); | |||
} | |||
/* bitmap dithering */ | |||
[DllImport("libcucul.dll", CallingConvention=CallingConvention.Cdecl), | |||
SuppressUnmanagedCodeSecurity] | |||
private static extern int cucul_dither_bitmap(IntPtr c, int x, int y, | |||
int w, int h, | |||
IntPtr d, IntPtr data); | |||
public int ditherBitmap(Rectangle r, CuculDither d, object data) | |||
{ | |||
GCHandle gch = GCHandle.Alloc(data, GCHandleType.Pinned); | |||
int ret = cucul_dither_bitmap(_c_cv, r.X, r.Y, r.Width, r.Height, | |||
d._dither, gch.AddrOfPinnedObject()); | |||
gch.Free(); | |||
return ret; | |||
} | |||
public int ditherBitmap(int x, int y, int w, int h, | |||
CuculDither d, object data) | |||
{ | |||
GCHandle gch = GCHandle.Alloc(data, GCHandleType.Pinned); | |||
int ret = cucul_dither_bitmap(_c_cv, x, y, w, h, d._dither, | |||
gch.AddrOfPinnedObject()); | |||
gch.Free(); | |||
return ret; | |||
} | |||
} | |||
public class CuculAttr | |||
{ | |||
private uint _attr; | |||
public CuculAttr(uint attr) | |||
{ | |||
_attr = attr; | |||
} | |||
[DllImport("libcucul.dll", CallingConvention=CallingConvention.Cdecl), | |||
SuppressUnmanagedCodeSecurity] | |||
private static extern byte cucul_attr_to_ansi(uint a); | |||
public byte toAnsi() | |||
{ | |||
return cucul_attr_to_ansi(_attr); | |||
} | |||
[DllImport("libcucul.dll", CallingConvention=CallingConvention.Cdecl), | |||
SuppressUnmanagedCodeSecurity] | |||
private static extern byte cucul_attr_to_ansi_fg(uint a); | |||
public byte toAnsiFg() | |||
{ | |||
return cucul_attr_to_ansi_fg(_attr); | |||
} | |||
[DllImport("libcucul.dll", CallingConvention=CallingConvention.Cdecl), | |||
SuppressUnmanagedCodeSecurity] | |||
private static extern byte cucul_attr_to_ansi_bg(uint a); | |||
public byte toAnsiBg() | |||
{ | |||
return cucul_attr_to_ansi_bg(_attr); | |||
} | |||
} | |||
public class CuculDither : IDisposable | |||
{ | |||
public readonly IntPtr _dither; | |||
[DllImport("libcucul.dll", CallingConvention=CallingConvention.Cdecl), | |||
SuppressUnmanagedCodeSecurity] | |||
private static extern IntPtr cucul_create_dither(int bpp, int w, | |||
int h, int pitch, | |||
uint rmask, | |||
uint gmask, | |||
uint bmask, | |||
uint amask); | |||
public CuculDither(int bpp, Size s, int pitch, | |||
uint rmask, uint gmask, uint bmask, uint amask) | |||
{ | |||
_dither = cucul_create_dither(bpp, s.Width, s.Height, pitch, | |||
rmask, gmask, bmask, amask); | |||
} | |||
[DllImport("libcucul.dll", CallingConvention=CallingConvention.Cdecl), | |||
SuppressUnmanagedCodeSecurity] | |||
private static extern int cucul_free_dither(IntPtr d); | |||
public void Dispose() | |||
{ | |||
cucul_free_dither(_dither); | |||
GC.SuppressFinalize(this); | |||
} | |||
/* TODO: fix this shit */ | |||
[DllImport("libcucul.dll", CallingConvention=CallingConvention.Cdecl), | |||
SuppressUnmanagedCodeSecurity] | |||
private static extern int cucul_set_dither_palette(IntPtr d, | |||
uint[] r, uint[] g, | |||
uint[] b, uint[] a); | |||
[DllImport("libcucul.dll", CallingConvention=CallingConvention.Cdecl), | |||
SuppressUnmanagedCodeSecurity] | |||
private static extern int cucul_set_dither_brightness(IntPtr d, float b); | |||
[DllImport("libcucul.dll", CallingConvention=CallingConvention.Cdecl), | |||
SuppressUnmanagedCodeSecurity] | |||
private static extern int cucul_set_dither_gamma(IntPtr d, float g); | |||
[DllImport("libcucul.dll", CallingConvention=CallingConvention.Cdecl), | |||
SuppressUnmanagedCodeSecurity] | |||
private static extern int cucul_set_dither_contrast(IntPtr d, float c); | |||
[DllImport("libcucul.dll", CallingConvention=CallingConvention.Cdecl), | |||
SuppressUnmanagedCodeSecurity] | |||
private static extern int cucul_set_dither_invert(IntPtr d, int i); | |||
[DllImport("libcucul.dll", CallingConvention=CallingConvention.Cdecl), | |||
SuppressUnmanagedCodeSecurity] | |||
private static extern int cucul_set_dither_antialias(IntPtr d, string s); | |||
[DllImport("libcucul.dll", CallingConvention=CallingConvention.Cdecl), | |||
SuppressUnmanagedCodeSecurity] | |||
private static extern string[] cucul_get_dither_antialias_list(IntPtr d); | |||
[DllImport("libcucul.dll", CallingConvention=CallingConvention.Cdecl), | |||
SuppressUnmanagedCodeSecurity] | |||
private static extern int cucul_set_dither_color(IntPtr d, string s); | |||
[DllImport("libcucul.dll", CallingConvention=CallingConvention.Cdecl), | |||
SuppressUnmanagedCodeSecurity] | |||
private static extern string[] cucul_get_dither_color_list(IntPtr d); | |||
[DllImport("libcucul.dll", CallingConvention=CallingConvention.Cdecl), | |||
SuppressUnmanagedCodeSecurity] | |||
private static extern int cucul_set_dither_charset(IntPtr d, string s); | |||
[DllImport("libcucul.dll", CallingConvention=CallingConvention.Cdecl), | |||
SuppressUnmanagedCodeSecurity] | |||
private static extern string[] cucul_get_dither_charset_list(IntPtr d); | |||
[DllImport("libcucul.dll", CallingConvention=CallingConvention.Cdecl), | |||
SuppressUnmanagedCodeSecurity] | |||
private static extern int cucul_set_dither_mode(IntPtr d, string s); | |||
[DllImport("libcucul.dll", CallingConvention=CallingConvention.Cdecl), | |||
SuppressUnmanagedCodeSecurity] | |||
private static extern string[] cucul_get_dither_mode_list(IntPtr d); | |||
public int setBrightness(float b) | |||
{ | |||
return cucul_set_dither_brightness(_dither, b); | |||
} | |||
public int setGamma(float g) | |||
{ | |||
return cucul_set_dither_gamma(_dither, g); | |||
} | |||
public int setContrast(float c) | |||
{ | |||
return cucul_set_dither_contrast(_dither, c); | |||
} | |||
public int setInvert(int i) | |||
{ | |||
return cucul_set_dither_invert(_dither, i); | |||
} | |||
public int setAntialias(string s) | |||
{ | |||
return cucul_set_dither_antialias(_dither, s); | |||
} | |||
public int setColor(string s) | |||
{ | |||
return cucul_set_dither_color(_dither, s); | |||
} | |||
public int setCharset(string s) | |||
{ | |||
return cucul_set_dither_charset(_dither, s); | |||
} | |||
public int setMode(string s) | |||
{ | |||
return cucul_set_dither_mode(_dither, s); | |||
} | |||
/* <FIXME> */ | |||
public string[] getAntialiasList() | |||
{ | |||
return cucul_get_dither_antialias_list(_dither); | |||
} | |||
public string[] getColorList() | |||
{ | |||
return cucul_get_dither_color_list(_dither); | |||
} | |||
public string[] getCharsetList() | |||
{ | |||
return cucul_get_dither_charset_list(_dither); | |||
} | |||
public string[] getModeList() | |||
{ | |||
return cucul_get_dither_mode_list(_dither); | |||
} | |||
/* </FIXME> */ | |||
} | |||
public class CuculFont : IDisposable | |||
{ | |||
private IntPtr _font; | |||
private GCHandle _gch; | |||
[DllImport("libcucul.dll", CallingConvention=CallingConvention.Cdecl), | |||
SuppressUnmanagedCodeSecurity] | |||
private static extern IntPtr cucul_load_font(IntPtr data, uint len); | |||
public CuculFont(string s) | |||
{ | |||
IntPtr name = Marshal.StringToHGlobalAnsi(s); | |||
_font = cucul_load_font(name, 0); | |||
Marshal.FreeHGlobal(name); | |||
} | |||
public CuculFont(byte[] buf) | |||
{ | |||
GCHandle _gch = GCHandle.Alloc(buf, GCHandleType.Pinned); | |||
_font = cucul_load_font(_gch.AddrOfPinnedObject(), | |||
(uint)buf.Length); | |||
} | |||
[DllImport("libcucul.dll", CallingConvention=CallingConvention.Cdecl), | |||
SuppressUnmanagedCodeSecurity] | |||
private static extern int cucul_free_font(IntPtr d); | |||
public void Dispose() | |||
{ | |||
cucul_free_font(_font); | |||
_gch.Free(); | |||
GC.SuppressFinalize(this); | |||
} | |||
[DllImport("libcucul.dll", CallingConvention=CallingConvention.Cdecl), | |||
SuppressUnmanagedCodeSecurity] | |||
private static extern IntPtr cucul_get_font_list(); | |||
public static string[] getList() | |||
{ | |||
IntPtr l = cucul_get_font_list(); | |||
int size; | |||
for(size = 0; true; size++) | |||
if(Marshal.ReadIntPtr(l, IntPtr.Size * size) == IntPtr.Zero) | |||
break; | |||
string[] ret = new string[size]; | |||
for(int i = 0; i < size; i++) | |||
{ | |||
IntPtr s = Marshal.ReadIntPtr(l, IntPtr.Size * i); | |||
ret[i] = Marshal.PtrToStringAnsi(s); | |||
} | |||
return ret; | |||
} | |||
[DllImport("libcucul.dll", CallingConvention=CallingConvention.Cdecl), | |||
SuppressUnmanagedCodeSecurity] | |||
private static extern int cucul_get_font_width(IntPtr font); | |||
[DllImport("libcucul.dll", CallingConvention=CallingConvention.Cdecl), | |||
SuppressUnmanagedCodeSecurity] | |||
private static extern int cucul_get_font_height(IntPtr font); | |||
public Size Size | |||
{ | |||
get { return new Size(cucul_get_font_width(_font), | |||
cucul_get_font_height(_font)); } | |||
} | |||
[DllImport("libcucul.dll", CallingConvention=CallingConvention.Cdecl), | |||
SuppressUnmanagedCodeSecurity] | |||
private static extern IntPtr cucul_get_font_blocks(IntPtr font); | |||
public int[,] getBlocks() | |||
{ | |||
IntPtr l = cucul_get_font_blocks(_font); | |||
int size; | |||
for(size = 1; true; size += 2) | |||
if(Marshal.ReadIntPtr(l, IntPtr.Size * size) == IntPtr.Zero) | |||
break; | |||
int[,] ret = new int[size,2]; | |||
for(int i = 0; i < size; i++) | |||
{ | |||
ret[i,0] = (int)Marshal.ReadIntPtr(l, IntPtr.Size * i * 2); | |||
ret[i,1] = (int)Marshal.ReadIntPtr(l, IntPtr.Size * i * 2 + 1); | |||
} | |||
return ret; | |||
} | |||
[DllImport("libcucul.dll", CallingConvention=CallingConvention.Cdecl), | |||
SuppressUnmanagedCodeSecurity] | |||
private static extern int cucul_render_canvas(IntPtr cv, IntPtr f, | |||
IntPtr buf, int w, int h, | |||
int pitch); | |||
public int Render(CuculCanvas cv, uint[,] buf, int pitch) | |||
{ | |||
GCHandle gch = GCHandle.Alloc(buf, GCHandleType.Pinned); | |||
int ret = cucul_render_canvas(cv._c_cv, _font, | |||
gch.AddrOfPinnedObject(), | |||
buf.GetLength(0), buf.GetLength(1), | |||
pitch); | |||
gch.Free(); | |||
return ret; | |||
} | |||
} | |||
} | |||
@@ -2,7 +2,7 @@ | |||
cacadir = $(libdir)/caca-sharp | |||
caca_sources = $(srcdir)/AssemblyInfo.cs $(srcdir)/Cucul.cs $(srcdir)/Caca.cs | |||
caca_sources = $(srcdir)/AssemblyInfo.cs $(srcdir)/Caca.cs | |||
if USE_CSHARP | |||
caca_DATA = caca-sharp.dll caca-sharp.dll.config | |||
@@ -1,3 +0,0 @@ | |||
<configuration> | |||
<dllmap dll="libcucul.dll" target="libcucul.so.@LT_MAJOR@" /> | |||
</configuration> |
@@ -18,16 +18,15 @@ using System; | |||
using System.Drawing; | |||
using System.Runtime.InteropServices; | |||
using Cucul; | |||
using Caca; | |||
class DemoCanvas : CuculCanvas | |||
class DemoCanvas : CacaCanvas | |||
{ | |||
private uint[,] image; | |||
private DateTime startTime; | |||
private CuculDither d; | |||
private CuculCanvas scroll; | |||
private CacaDither d; | |||
private CacaCanvas scroll; | |||
public DemoCanvas() | |||
{ | |||
@@ -35,15 +34,15 @@ class DemoCanvas : CuculCanvas | |||
string message = " --- POWERED BY LIBCACA --- OLDSCHOOL TEXT EFFECTS ARE 100% PURE WIN"; | |||
scroll = new CuculCanvas(new Size(message.Length, 1)); | |||
scroll.setColorAnsi(Libcucul.WHITE, Libcucul.TRANSPARENT); | |||
scroll = new CacaCanvas(new Size(message.Length, 1)); | |||
scroll.setColorAnsi(Libcaca.WHITE, Libcaca.TRANSPARENT); | |||
scroll.putStr(new Point(0, 0), message); | |||
CuculFont f = new CuculFont(CuculFont.getList()[1]); | |||
CacaFont f = new CacaFont(CacaFont.getList()[1]); | |||
int w = f.Size.Width * message.Length; | |||
int h = f.Size.Height; | |||
image = new uint[w, h]; | |||
d = new CuculDither(32, new Size(w, h), w * 4, | |||
d = new CacaDither(32, new Size(w, h), w * 4, | |||
0xff00, 0xff0000, 0xff000000, 0xff); | |||
f.Render(scroll, image, image.GetLength(0) * 4); | |||
} | |||
@@ -55,7 +54,7 @@ class DemoCanvas : CuculCanvas | |||
Clear(); | |||
setColorAnsi(Libcucul.WHITE, Libcucul.BLACK); | |||
setColorAnsi(Libcaca.WHITE, Libcaca.BLACK); | |||
for(int i = 0; i < barCount; i++) | |||
{ | |||
double v = ((Math.Sin((t / 500.0) | |||
@@ -63,7 +62,7 @@ class DemoCanvas : CuculCanvas | |||
Point p1 = new Point(0, (int)v); | |||
Point p2 = new Point(Size.Width - 1, (int)v); | |||
setColorAnsi((uint)(i + 9), Libcucul.BLACK); | |||
setColorAnsi((uint)(i + 9), Libcaca.BLACK); | |||
/* drawLine is already clipped, we don't care about overflows */ | |||
drawLine(p1 + new Size(0, -2), p2 + new Size(0, -2), '-'); | |||
drawLine(p1 + new Size(0, -1), p2 + new Size(0, -1), '*'); | |||
@@ -79,9 +78,9 @@ class DemoCanvas : CuculCanvas | |||
ditherBitmap(new Rectangle(- x, h / 2 - y, w * 12, y * 2), d, image); | |||
ditherBitmap(new Rectangle(12 * w - x, h / 2 - y, w * 12, y * 2), d, image); | |||
setColorAnsi(Libcucul.WHITE, Libcucul.BLUE); | |||
setColorAnsi(Libcaca.WHITE, Libcaca.BLUE); | |||
putStr(new Point(-30, -2) + Size, " -=[ Powered by libcaca ]=- "); | |||
setColorAnsi(Libcucul.WHITE, Libcucul.BLACK); | |||
setColorAnsi(Libcaca.WHITE, Libcaca.BLACK); | |||
} | |||
} | |||
@@ -121,7 +120,7 @@ class Test | |||
Console.WriteLine("libcaca {0} .NET test", Libcaca.getVersion()); | |||
Console.WriteLine("(c) 2006 Jean-Yves Lamoureux <jylam@lnxscene.org>"); | |||
/* Instanciate a cucul canvas */ | |||
/* Instanciate a caca canvas */ | |||
DemoCanvas cv = new DemoCanvas(); | |||
/* We have a proper canvas, let's display it using Caca */ | |||
@@ -129,7 +128,7 @@ class Test | |||
/* Random number. This is a static method, | |||
not to be used with previous instance */ | |||
Console.WriteLine("A random number: {0}", Libcucul.Rand(0, 1337)); | |||
Console.WriteLine("A random number: {0}", Libcaca.Rand(0, 1337)); | |||
dp.EventLoop(); | |||
} | |||
@@ -10,7 +10,7 @@ include_HEADERS = caca++.h | |||
lib_LTLIBRARIES = libcaca++.la | |||
endif | |||
libcaca___la_SOURCES = caca++.cpp cucul++.cpp caca++.h | |||
libcaca___la_SOURCES = caca++.cpp caca++.h | |||
libcaca___la_LDFLAGS = -no-undefined -version-number @LT_VERSION@ | |||
libcaca___la_LIBADD = ../caca/libcaca.la | |||
@@ -22,8 +22,405 @@ | |||
#include <iostream> | |||
#include <stdio.h> // BUFSIZ | |||
#include <stdarg.h> // va_* | |||
#include "caca++.h" | |||
uint32_t Charset::utf8ToUtf32(char const *s, size_t *read) | |||
{ | |||
return caca_utf8_to_utf32(s, read); | |||
} | |||
size_t Charset::utf32ToUtf8(char *buf, uint32_t ch) | |||
{ | |||
return caca_utf32_to_utf8(buf, ch); | |||
} | |||
uint8_t Charset::utf32ToCp437(uint32_t ch) | |||
{ | |||
return caca_utf32_to_cp437(ch); | |||
} | |||
uint32_t Charset::cp437ToUtf32(uint8_t ch) | |||
{ | |||
return caca_cp437_to_utf32(ch); | |||
} | |||
Canvas::Canvas() | |||
{ | |||
cv = caca_create_canvas(0, 0); | |||
if(!cv) | |||
throw -1; | |||
} | |||
Canvas::Canvas(int width, int height) | |||
{ | |||
cv = caca_create_canvas(width, height); | |||
if(!cv) throw -1; | |||
} | |||
Canvas::~Canvas() | |||
{ | |||
if(cv) | |||
caca_free_canvas(cv); | |||
} | |||
caca_canvas_t *Canvas::get_caca_canvas_t() | |||
{ | |||
return cv; | |||
} | |||
void Canvas::setSize(unsigned int width, unsigned int height) | |||
{ | |||
caca_set_canvas_size(cv, width, height); | |||
} | |||
unsigned int Canvas::getWidth(void) | |||
{ | |||
return caca_get_canvas_width(cv); | |||
} | |||
unsigned int Canvas::getHeight(void) | |||
{ | |||
return caca_get_canvas_height(cv); | |||
} | |||
int Canvas::setColorANSI(uint8_t f, uint8_t b) | |||
{ | |||
return caca_set_color_ansi(cv, f, b); | |||
} | |||
int Canvas::setColorARGB(unsigned int f, unsigned int b) | |||
{ | |||
return caca_set_color_argb(cv, f, b); | |||
} | |||
void Canvas::putChar(int x, int y, uint32_t ch) | |||
{ | |||
caca_put_char(cv, x, y, ch); | |||
} | |||
uint32_t Canvas::getChar(int x, int y) | |||
{ | |||
return caca_get_char(cv, x, y); | |||
} | |||
void Canvas::putStr(int x, int y, char *str) | |||
{ | |||
caca_put_str(cv, x, y, str); | |||
} | |||
void Canvas::Printf(int x, int y, char const * format, ...) | |||
{ | |||
char tmp[BUFSIZ]; | |||
char *buf = tmp; | |||
va_list args; | |||
va_start(args, format); | |||
#if defined(HAVE_VSNPRINTF) | |||
vsnprintf(buf, getWidth() - x + 1, format, args); | |||
#else | |||
vsprintf(buf, format, args); | |||
#endif | |||
buf[getWidth() - x] = '\0'; | |||
va_end(args); | |||
putStr(x, y, buf); | |||
} | |||
void Canvas::Clear(void) | |||
{ | |||
caca_clear_canvas(cv); | |||
} | |||
void Canvas::Blit(int x, int y, Canvas* c1, Canvas* c2) | |||
{ | |||
caca_blit(cv, x, y, c1->get_caca_canvas_t(), | |||
c2 ? c2->get_caca_canvas_t() : NULL); | |||
} | |||
void Canvas::Invert() | |||
{ | |||
caca_invert(cv); | |||
} | |||
void Canvas::Flip() | |||
{ | |||
caca_flip(cv); | |||
} | |||
void Canvas::Flop() | |||
{ | |||
caca_flop(cv); | |||
} | |||
void Canvas::Rotate180() | |||
{ | |||
caca_rotate_180(cv); | |||
} | |||
void Canvas::RotateLeft() | |||
{ | |||
caca_rotate_left(cv); | |||
} | |||
void Canvas::RotateRight() | |||
{ | |||
caca_rotate_right(cv); | |||
} | |||
void Canvas::drawLine(int x1, int y1, int x2, int y2, uint32_t ch) | |||
{ | |||
caca_draw_line(cv, x1, y1, x2, y2, ch); | |||
} | |||
void Canvas::drawPolyline(int const x[], int const y[], int f, uint32_t ch) | |||
{ | |||
caca_draw_polyline(cv, x, y, f, ch); | |||
} | |||
void Canvas::drawThinLine(int x1, int y1, int x2, int y2) | |||
{ | |||
caca_draw_thin_line(cv, x1, y1, x2, y2); | |||
} | |||
void Canvas::drawThinPolyline(int const x[], int const y[], int f) | |||
{ | |||
caca_draw_thin_polyline(cv, x, y, f); | |||
} | |||
void Canvas::drawCircle(int x, int y, int d, uint32_t ch) | |||
{ | |||
caca_draw_circle(cv, x, y, d, ch); | |||
} | |||
void Canvas::drawEllipse(int x, int y, int d1, int d2, uint32_t ch) | |||
{ | |||
caca_draw_ellipse(cv, x, y, d1, d2, ch); | |||
} | |||
void Canvas::drawThinEllipse(int x, int y, int d1, int d2) | |||
{ | |||
caca_draw_thin_ellipse(cv, x, y, d1, d2); | |||
} | |||
void Canvas::fillEllipse(int x, int y, int d1, int d2, uint32_t ch) | |||
{ | |||
caca_fill_ellipse(cv, x, y, d1, d2, ch); | |||
} | |||
void Canvas::drawBox(int x, int y, int w, int h, uint32_t ch) | |||
{ | |||
caca_draw_box(cv, x, y, w, h, ch); | |||
} | |||
void Canvas::drawThinBox(int x, int y, int w, int h) | |||
{ | |||
caca_draw_thin_box(cv, x, y, w, h); | |||
} | |||
void Canvas::drawCP437Box(int x, int y, int w, int h) | |||
{ | |||
caca_draw_cp437_box(cv, x, y, w, h); | |||
} | |||
void Canvas::fillBox(int x, int y, int w, int h, uint32_t ch) | |||
{ | |||
caca_fill_box(cv, x, y, w, h, ch); | |||
} | |||
void Canvas::drawTriangle(int x1, int y1, int x2, int y2, int x3, int y3, uint32_t ch) | |||
{ | |||
caca_draw_triangle(cv, x1, y1, x2, y2, x3, y3, ch); | |||
} | |||
void Canvas::drawThinTriangle(int x1, int y1, int x2, int y2, int x3, int y3) | |||
{ | |||
caca_draw_thin_triangle(cv, x1, y1, x2, y2, x3, y3); | |||
} | |||
void Canvas::fillTriangle(int x1, int y1, int x2, int y2, int x3, int y3, uint32_t ch) | |||
{ | |||
caca_fill_triangle(cv, x1, y1, x2, y2, x3, y3, ch); | |||
} | |||
int Canvas::Rand(int min, int max) | |||
{ | |||
return caca_rand(min, max); | |||
} | |||
const char * Canvas::getVersion() | |||
{ | |||
return caca_get_version(); | |||
} | |||
int Canvas::setAttr(uint32_t attr) | |||
{ | |||
return caca_set_attr(cv, attr); | |||
} | |||
uint32_t Canvas::getAttr(int x, int y) | |||
{ | |||
return caca_get_attr(cv, x, y); | |||
} | |||
int Canvas::setBoundaries(caca_canvas_t *, int x, int y, | |||
unsigned int w, unsigned int h) | |||
{ | |||
return caca_set_canvas_boundaries(cv, x, y, h, w); | |||
} | |||
unsigned int Canvas::getFrameCount() | |||
{ | |||
return caca_get_frame_count(cv); | |||
} | |||
int Canvas::setFrame(unsigned int f) | |||
{ | |||
return caca_set_frame(cv, f); | |||
} | |||
int Canvas::createFrame(unsigned int f) | |||
{ | |||
return caca_create_frame(cv, f); | |||
} | |||
int Canvas::freeFrame(unsigned int f) | |||
{ | |||
return caca_create_frame(cv, f); | |||
} | |||
char const *const * Canvas::getImportList(void) | |||
{ | |||
return caca_get_import_list(); | |||
} | |||
long int Canvas::importMemory(void const *buf, size_t len, char const *fmt) | |||
{ | |||
return caca_import_memory(cv, buf, len, fmt); | |||
} | |||
long int Canvas::importFile(char const *file, char const *fmt) | |||
{ | |||
return caca_import_file(cv, file, fmt); | |||
} | |||
char const *const * Canvas::getExportList(void) | |||
{ | |||
return caca_get_export_list(); | |||
} | |||
void *Canvas::exportMemory(char const *fmt, size_t *len) | |||
{ | |||
return caca_export_memory(cv, fmt, len); | |||
} | |||
Dither::Dither(unsigned int v1, unsigned int v2, unsigned int v3, unsigned int v4, unsigned int v5, unsigned int v6, unsigned int v7, unsigned int v8) | |||
{ | |||
dither = caca_create_dither(v1, v2, v3, v4, v5, v6, v7, v8); | |||
} | |||
Dither::~Dither() | |||
{ | |||
caca_free_dither(dither); | |||
} | |||
void Dither::setPalette(uint32_t r[], uint32_t g[], uint32_t b[], uint32_t a[]) | |||
{ | |||
caca_set_dither_palette(dither, r, g, b, a); | |||
} | |||
void Dither::setBrightness(float f) | |||
{ | |||
caca_set_dither_brightness(dither, f); | |||
} | |||
void Dither::setGamma(float f) | |||
{ | |||
caca_set_dither_gamma(dither, f); | |||
} | |||
void Dither::setContrast(float f) | |||
{ | |||
caca_set_dither_contrast(dither, f); | |||
} | |||
void Dither::setAntialias(char const *cv) | |||
{ | |||
caca_set_dither_antialias(dither, cv); | |||
} | |||
char const *const * Dither::getAntialiasList() | |||
{ | |||
return caca_get_dither_antialias_list(dither); | |||
} | |||
void Dither::setColor(char const *cv) | |||
{ | |||
caca_set_dither_color(dither, cv); | |||
} | |||
char const *const * Dither::getColorList() | |||
{ | |||
return caca_get_dither_color_list(dither); | |||
} | |||
void Dither::setCharset(char const *cv) | |||
{ | |||
caca_set_dither_charset(dither, cv); | |||
} | |||
char const *const * Dither::getCharsetList() | |||
{ | |||
return caca_get_dither_charset_list(dither); | |||
} | |||
void Dither::setMode(char const *cv) | |||
{ | |||
caca_set_dither_algorithm(dither, cv); | |||
} | |||
char const *const * Dither::getModeList(void) | |||
{ | |||
return caca_get_dither_algorithm_list(dither); | |||
} | |||
void Dither::Bitmap(Canvas *cv, int x, int y, int w, int h, void *v) | |||
{ | |||
caca_dither_bitmap(cv->get_caca_canvas_t(), x, y, w, h, dither, v); | |||
} | |||
Font::Font(void const *s, unsigned int v) | |||
{ | |||
font = caca_load_font(s, v); | |||
if(!font) throw -1; | |||
} | |||
char const *const * Font::getList(void) | |||
{ | |||
return caca_get_font_list(); | |||
} | |||
unsigned int Font::getWidth() | |||
{ | |||
return caca_get_font_width(font); | |||
} | |||
unsigned int Font::getHeight() | |||
{ | |||
return caca_get_font_height(font); | |||
} | |||
void Font::renderCanvas(Canvas *cv, uint8_t *buf, unsigned int x, unsigned int y, unsigned int w) | |||
{ | |||
caca_render_canvas(cv->get_caca_canvas_t(), font, buf, x, y, w); | |||
} | |||
uint32_t const *Font::getBlocks() | |||
{ | |||
return caca_get_font_blocks(font); | |||
} | |||
Font::~Font() | |||
{ | |||
caca_free_font(font); | |||
} | |||
Caca::Caca(Canvas *cv) | |||
{ | |||
dp = caca_create_display(cv->get_caca_canvas_t()); | |||
@@ -24,8 +24,6 @@ | |||
#define _CACA_PP_H | |||
#include <caca.h> | |||
#include <caca++.h> | |||
#include <cucul++.h> | |||
#undef __class | |||
#if defined(_WIN32) && defined(__LIBCACA_PP__) | |||
@@ -34,6 +32,126 @@ | |||
# define __class class | |||
#endif | |||
class Canvas; | |||
__class Charset | |||
{ | |||
public: | |||
uint32_t utf8ToUtf32(char const *, size_t *); | |||
size_t utf32ToUtf8(char *, uint32_t); | |||
uint8_t utf32ToCp437(uint32_t); | |||
uint32_t cp437ToUtf32(uint8_t); | |||
}; | |||
/* Ugly, I know */ | |||
__class Font | |||
{ | |||
public: | |||
~Font(); | |||
Font(void const *, unsigned int); | |||
char const *const * getList(void); | |||
unsigned int getWidth(); | |||
unsigned int getHeight(); | |||
void renderCanvas(Canvas *, uint8_t *, unsigned int, | |||
unsigned int, unsigned int); | |||
uint32_t const *getBlocks(); | |||
private: | |||
caca_font *font; | |||
}; | |||
__class Dither | |||
{ | |||
public: | |||
Dither(unsigned int, unsigned int, unsigned int, unsigned int, | |||
unsigned int, unsigned int, unsigned int, unsigned int); | |||
~Dither(); | |||
void setPalette(uint32_t r[], uint32_t g[], | |||
uint32_t b[], uint32_t a[]); | |||
void setBrightness(float); | |||
void setGamma(float); | |||
void setContrast(float); | |||
void setAntialias(char const *); | |||
char const *const * getAntialiasList(); | |||
void setColor(char const *); | |||
char const *const * getColorList(); | |||
void setCharset(char const *); | |||
char const *const * getCharsetList(); | |||
void setMode(char const *); | |||
char const *const * getModeList(); | |||
void Bitmap(Canvas *, int, int, int, int, void *); | |||
private: | |||
caca_dither *dither; | |||
}; | |||
__class Canvas | |||
{ | |||
friend class Caca; | |||
friend class Dither; | |||
friend class Font; | |||
public: | |||
Canvas(); | |||
Canvas(int width, int height); | |||
~Canvas(); | |||
void setSize(unsigned int w, unsigned int h); | |||
unsigned int getWidth(void); | |||
unsigned int getHeight(void); | |||
uint32_t getAttr(int, int); | |||
int setAttr(uint32_t); | |||
int setColorANSI(uint8_t f, uint8_t b); | |||
int setColorARGB(unsigned int f, unsigned int b); | |||
void Printf(int x, int y , char const * format, ...); | |||
void putChar(int x, int y, uint32_t ch); | |||
uint32_t getChar(int, int); | |||
void putStr(int x, int y, char *str); | |||
void Clear(void); | |||
void Blit(int, int, Canvas* c1, Canvas* c2); | |||
void Invert(); | |||
void Flip(); | |||
void Flop(); | |||
void Rotate180(); | |||
void RotateLeft(); | |||
void RotateRight(); | |||
void drawLine(int, int, int, int, uint32_t); | |||
void drawPolyline(int const x[], int const y[], int, uint32_t); | |||
void drawThinLine(int, int, int, int); | |||
void drawThinPolyline(int const x[], int const y[], int); | |||
void drawCircle(int, int, int, uint32_t); | |||
void drawEllipse(int, int, int, int, uint32_t); | |||
void drawThinEllipse(int, int, int, int); | |||
void fillEllipse(int, int, int, int, uint32_t); | |||
void drawBox(int, int, int, int, uint32_t); | |||
void drawThinBox(int, int, int, int); | |||
void drawCP437Box(int, int, int, int); | |||
void fillBox(int, int, int, int, uint32_t); | |||
void drawTriangle(int, int, int, int, int, int, uint32_t); | |||
void drawThinTriangle(int, int, int, int, int, int); | |||
void fillTriangle(int, int, int, int, int, int, uint32_t); | |||
int setBoundaries(caca_canvas_t *, int, int, unsigned int, unsigned int); | |||
unsigned int getFrameCount(); | |||
int setFrame(unsigned int); | |||
int createFrame(unsigned int); | |||
int freeFrame(unsigned int); | |||
char const * const * getImportList(void); | |||
long int importMemory(void const *, size_t, char const *); | |||
long int importFile(char const *, char const *); | |||
char const * const * getExportList(void); | |||
void *exportMemory(char const *, size_t *); | |||
static int Rand(int, int); | |||
static char const * getVersion(); | |||
protected: | |||
caca_canvas_t *get_caca_canvas_t(); | |||
private: | |||
caca_canvas_t *cv; | |||
}; | |||
__class Event | |||
{ | |||
friend class Caca; | |||
@@ -1,421 +0,0 @@ | |||
/* | |||
* libcaca++ C++ bindings for libcaca | |||
* Copyright (c) 2006 Jean-Yves Lamoureux <jylam@lnxscene.org> | |||
* All Rights Reserved | |||
* | |||
* $Id$ | |||
* | |||
* This library is free software. It comes without any warranty, to | |||
* the extent permitted by applicable law. You can redistribute it | |||
* and/or modify it under the terms of the Do What The Fuck You Want | |||
* To Public License, Version 2, as published by Sam Hocevar. See | |||
* http://sam.zoy.org/wtfpl/COPYING for more details. | |||
*/ | |||
/* | |||
* This file contains the main functions used by \e libcaca++ applications | |||
* to initialise a drawing context. | |||
*/ | |||
#include "config.h" | |||
#include <stdio.h> // BUFSIZ | |||
#include <stdarg.h> // va_* | |||
#include "caca++.h" | |||
uint32_t Charset::utf8ToUtf32(char const *s, size_t *read) | |||
{ | |||
return caca_utf8_to_utf32(s, read); | |||
} | |||
size_t Charset::utf32ToUtf8(char *buf, uint32_t ch) | |||
{ | |||
return caca_utf32_to_utf8(buf, ch); | |||
} | |||
uint8_t Charset::utf32ToCp437(uint32_t ch) | |||
{ | |||
return caca_utf32_to_cp437(ch); | |||
} | |||
uint32_t Charset::cp437ToUtf32(uint8_t ch) | |||
{ | |||
return caca_cp437_to_utf32(ch); | |||
} | |||
Canvas::Canvas() | |||
{ | |||
cv = caca_create_canvas(0, 0); | |||
if(!cv) | |||
throw -1; | |||
} | |||
Canvas::Canvas(int width, int height) | |||
{ | |||
cv = caca_create_canvas(width, height); | |||
if(!cv) throw -1; | |||
} | |||
Canvas::~Canvas() | |||
{ | |||
if(cv) | |||
caca_free_canvas(cv); | |||
} | |||
caca_canvas_t *Canvas::get_caca_canvas_t() | |||
{ | |||
return cv; | |||
} | |||
void Canvas::setSize(unsigned int width, unsigned int height) | |||
{ | |||
caca_set_canvas_size(cv, width, height); | |||
} | |||
unsigned int Canvas::getWidth(void) | |||
{ | |||
return caca_get_canvas_width(cv); | |||
} | |||
unsigned int Canvas::getHeight(void) | |||
{ | |||
return caca_get_canvas_height(cv); | |||
} | |||
int Canvas::setColorANSI(uint8_t f, uint8_t b) | |||
{ | |||
return caca_set_color_ansi(cv, f, b); | |||
} | |||
int Canvas::setColorARGB(unsigned int f, unsigned int b) | |||
{ | |||
return caca_set_color_argb(cv, f, b); | |||
} | |||
void Canvas::putChar(int x, int y, uint32_t ch) | |||
{ | |||
caca_put_char(cv, x, y, ch); | |||
} | |||
uint32_t Canvas::getChar(int x, int y) | |||
{ | |||
return caca_get_char(cv, x, y); | |||
} | |||
void Canvas::putStr(int x, int y, char *str) | |||
{ | |||
caca_put_str(cv, x, y, str); | |||
} | |||
void Canvas::Printf(int x, int y, char const * format, ...) | |||
{ | |||
char tmp[BUFSIZ]; | |||
char *buf = tmp; | |||
va_list args; | |||
va_start(args, format); | |||
#if defined(HAVE_VSNPRINTF) | |||
vsnprintf(buf, getWidth() - x + 1, format, args); | |||
#else | |||
vsprintf(buf, format, args); | |||
#endif | |||
buf[getWidth() - x] = '\0'; | |||
va_end(args); | |||
putStr(x, y, buf); | |||
} | |||
void Canvas::Clear(void) | |||
{ | |||
caca_clear_canvas(cv); | |||
} | |||
void Canvas::Blit(int x, int y, Canvas* c1, Canvas* c2) | |||
{ | |||
caca_blit(cv, x, y, c1->get_caca_canvas_t(), | |||
c2 ? c2->get_caca_canvas_t() : NULL); | |||
} | |||
void Canvas::Invert() | |||
{ | |||
caca_invert(cv); | |||
} | |||
void Canvas::Flip() | |||
{ | |||
caca_flip(cv); | |||
} | |||
void Canvas::Flop() | |||
{ | |||
caca_flop(cv); | |||
} | |||
void Canvas::Rotate180() | |||
{ | |||
caca_rotate_180(cv); | |||
} | |||
void Canvas::RotateLeft() | |||
{ | |||
caca_rotate_left(cv); | |||
} | |||
void Canvas::RotateRight() | |||
{ | |||
caca_rotate_right(cv); | |||
} | |||
void Canvas::drawLine(int x1, int y1, int x2, int y2, uint32_t ch) | |||
{ | |||
caca_draw_line(cv, x1, y1, x2, y2, ch); | |||
} | |||
void Canvas::drawPolyline(int const x[], int const y[], int f, uint32_t ch) | |||
{ | |||
caca_draw_polyline(cv, x, y, f, ch); | |||
} | |||
void Canvas::drawThinLine(int x1, int y1, int x2, int y2) | |||
{ | |||
caca_draw_thin_line(cv, x1, y1, x2, y2); | |||
} | |||
void Canvas::drawThinPolyline(int const x[], int const y[], int f) | |||
{ | |||
caca_draw_thin_polyline(cv, x, y, f); | |||
} | |||
void Canvas::drawCircle(int x, int y, int d, uint32_t ch) | |||
{ | |||
caca_draw_circle(cv, x, y, d, ch); | |||
} | |||
void Canvas::drawEllipse(int x, int y, int d1, int d2, uint32_t ch) | |||
{ | |||
caca_draw_ellipse(cv, x, y, d1, d2, ch); | |||
} | |||
void Canvas::drawThinEllipse(int x, int y, int d1, int d2) | |||
{ | |||
caca_draw_thin_ellipse(cv, x, y, d1, d2); | |||
} | |||
void Canvas::fillEllipse(int x, int y, int d1, int d2, uint32_t ch) | |||
{ | |||
caca_fill_ellipse(cv, x, y, d1, d2, ch); | |||
} | |||
void Canvas::drawBox(int x, int y, int w, int h, uint32_t ch) | |||
{ | |||
caca_draw_box(cv, x, y, w, h, ch); | |||
} | |||
void Canvas::drawThinBox(int x, int y, int w, int h) | |||
{ | |||
caca_draw_thin_box(cv, x, y, w, h); | |||
} | |||
void Canvas::drawCP437Box(int x, int y, int w, int h) | |||
{ | |||
caca_draw_cp437_box(cv, x, y, w, h); | |||
} | |||
void Canvas::fillBox(int x, int y, int w, int h, uint32_t ch) | |||
{ | |||
caca_fill_box(cv, x, y, w, h, ch); | |||
} | |||
void Canvas::drawTriangle(int x1, int y1, int x2, int y2, int x3, int y3, uint32_t ch) | |||
{ | |||
caca_draw_triangle(cv, x1, y1, x2, y2, x3, y3, ch); | |||
} | |||
void Canvas::drawThinTriangle(int x1, int y1, int x2, int y2, int x3, int y3) | |||
{ | |||
caca_draw_thin_triangle(cv, x1, y1, x2, y2, x3, y3); | |||
} | |||
void Canvas::fillTriangle(int x1, int y1, int x2, int y2, int x3, int y3, uint32_t ch) | |||
{ | |||
caca_fill_triangle(cv, x1, y1, x2, y2, x3, y3, ch); | |||
} | |||
int Canvas::Rand(int min, int max) | |||
{ | |||
return caca_rand(min, max); | |||
} | |||
const char * Canvas::getVersion() | |||
{ | |||
return caca_get_version(); | |||
} | |||
int Canvas::setAttr(uint32_t attr) | |||
{ | |||
return caca_set_attr(cv, attr); | |||
} | |||
uint32_t Canvas::getAttr(int x, int y) | |||
{ | |||
return caca_get_attr(cv, x, y); | |||
} | |||
int Canvas::setBoundaries(caca_canvas_t *, int x, int y, | |||
unsigned int w, unsigned int h) | |||
{ | |||
return caca_set_canvas_boundaries(cv, x, y, h, w); | |||
} | |||
unsigned int Canvas::getFrameCount() | |||
{ | |||
return caca_get_frame_count(cv); | |||
} | |||
int Canvas::setFrame(unsigned int f) | |||
{ | |||
return caca_set_frame(cv, f); | |||
} | |||
int Canvas::createFrame(unsigned int f) | |||
{ | |||
return caca_create_frame(cv, f); | |||
} | |||
int Canvas::freeFrame(unsigned int f) | |||
{ | |||
return caca_create_frame(cv, f); | |||
} | |||
char const *const * Canvas::getImportList(void) | |||
{ | |||
return caca_get_import_list(); | |||
} | |||
long int Canvas::importMemory(void const *buf, size_t len, char const *fmt) | |||
{ | |||
return caca_import_memory(cv, buf, len, fmt); | |||
} | |||
long int Canvas::importFile(char const *file, char const *fmt) | |||
{ | |||
return caca_import_file(cv, file, fmt); | |||
} | |||
char const *const * Canvas::getExportList(void) | |||
{ | |||
return caca_get_export_list(); | |||
} | |||
void *Canvas::exportMemory(char const *fmt, size_t *len) | |||
{ | |||
return caca_export_memory(cv, fmt, len); | |||
} | |||
Dither::Dither(unsigned int v1, unsigned int v2, unsigned int v3, unsigned int v4, unsigned int v5, unsigned int v6, unsigned int v7, unsigned int v8) | |||
{ | |||
dither = caca_create_dither(v1, v2, v3, v4, v5, v6, v7, v8); | |||
} | |||
Dither::~Dither() | |||
{ | |||
caca_free_dither(dither); | |||
} | |||
void Dither::setPalette(uint32_t r[], uint32_t g[], uint32_t b[], uint32_t a[]) | |||
{ | |||
caca_set_dither_palette(dither, r, g, b, a); | |||
} | |||
void Dither::setBrightness(float f) | |||
{ | |||
caca_set_dither_brightness(dither, f); | |||
} | |||
void Dither::setGamma(float f) | |||
{ | |||
caca_set_dither_gamma(dither, f); | |||
} | |||
void Dither::setContrast(float f) | |||
{ | |||
caca_set_dither_contrast(dither, f); | |||
} | |||
void Dither::setAntialias(char const *cv) | |||
{ | |||
caca_set_dither_antialias(dither, cv); | |||
} | |||
char const *const * Dither::getAntialiasList() | |||
{ | |||
return caca_get_dither_antialias_list(dither); | |||
} | |||
void Dither::setColor(char const *cv) | |||
{ | |||
caca_set_dither_color(dither, cv); | |||
} | |||
char const *const * Dither::getColorList() | |||
{ | |||
return caca_get_dither_color_list(dither); | |||
} | |||
void Dither::setCharset(char const *cv) | |||
{ | |||
caca_set_dither_charset(dither, cv); | |||
} | |||
char const *const * Dither::getCharsetList() | |||
{ | |||
return caca_get_dither_charset_list(dither); | |||
} | |||
void Dither::setMode(char const *cv) | |||
{ | |||
caca_set_dither_algorithm(dither, cv); | |||
} | |||
char const *const * Dither::getModeList(void) | |||
{ | |||
return caca_get_dither_algorithm_list(dither); | |||
} | |||
void Dither::Bitmap(Canvas *cv, int x, int y, int w, int h, void *v) | |||
{ | |||
caca_dither_bitmap(cv->get_caca_canvas_t(), x, y, w, h, dither, v); | |||
} | |||
Font::Font(void const *s, unsigned int v) | |||
{ | |||
font = caca_load_font(s, v); | |||
if(!font) throw -1; | |||
} | |||
char const *const * Font::getList(void) | |||
{ | |||
return caca_get_font_list(); | |||
} | |||
unsigned int Font::getWidth() | |||
{ | |||
return caca_get_font_width(font); | |||
} | |||
unsigned int Font::getHeight() | |||
{ | |||
return caca_get_font_height(font); | |||
} | |||
void Font::renderCanvas(Canvas *cv, uint8_t *buf, unsigned int x, unsigned int y, unsigned int w) | |||
{ | |||
caca_render_canvas(cv->get_caca_canvas_t(), font, buf, x, y, w); | |||
} | |||
uint32_t const *Font::getBlocks() | |||
{ | |||
return caca_get_font_blocks(font); | |||
} | |||
Font::~Font() | |||
{ | |||
caca_free_font(font); | |||
} | |||
@@ -1,156 +0,0 @@ | |||
/* | |||
* libcaca++ C++ bindings for libcaca | |||
* Copyright (c) 2006 Jean-Yves Lamoureux <jylam@lnxscene.org> | |||
* All Rights Reserved | |||
* | |||
* $Id$ | |||
* | |||
* This library is free software. It comes without any warranty, to | |||
* the extent permitted by applicable law. You can redistribute it | |||
* and/or modify it under the terms of the Do What The Fuck You Want | |||
* To Public License, Version 2, as published by Sam Hocevar. See | |||
* http://sam.zoy.org/wtfpl/COPYING for more details. | |||
*/ | |||
/** \file caca++.h | |||
* \version \$Id$ | |||
* \author Jean-Yves Lamoureux <jylam@lnxscene.org> | |||
* \brief The \e libcaca++ public header. | |||
* | |||
* This header contains the public types and functions that applications | |||
* using \e libcaca++ may use. | |||
*/ | |||
#ifndef _CUCUL_PP_H | |||
#define _CUCUL_PP_H | |||
#include <caca.h> | |||
#undef __class | |||
#if defined(_WIN32) && defined(__LIBCACA_PP__) | |||
# define __class class __declspec(dllexport) | |||
#else | |||
# define __class class | |||
#endif | |||
class Canvas; | |||
__class Charset | |||
{ | |||
public: | |||
uint32_t utf8ToUtf32(char const *, size_t *); | |||
size_t utf32ToUtf8(char *, uint32_t); | |||
uint8_t utf32ToCp437(uint32_t); | |||
uint32_t cp437ToUtf32(uint8_t); | |||
}; | |||
/* Ugly, I know */ | |||
__class Font | |||
{ | |||
public: | |||
~Font(); | |||
Font(void const *, unsigned int); | |||
char const *const * getList(void); | |||
unsigned int getWidth(); | |||
unsigned int getHeight(); | |||
void renderCanvas(Canvas *, uint8_t *, unsigned int, | |||
unsigned int, unsigned int); | |||
uint32_t const *getBlocks(); | |||
private: | |||
caca_font *font; | |||
}; | |||
__class Dither | |||
{ | |||
public: | |||
Dither(unsigned int, unsigned int, unsigned int, unsigned int, | |||
unsigned int, unsigned int, unsigned int, unsigned int); | |||
~Dither(); | |||
void setPalette(uint32_t r[], uint32_t g[], | |||
uint32_t b[], uint32_t a[]); | |||
void setBrightness(float); | |||
void setGamma(float); | |||
void setContrast(float); | |||
void setAntialias(char const *); | |||
char const *const * getAntialiasList(); | |||
void setColor(char const *); | |||
char const *const * getColorList(); | |||
void setCharset(char const *); | |||
char const *const * getCharsetList(); | |||
void setMode(char const *); | |||
char const *const * getModeList(); | |||
void Bitmap(Canvas *, int, int, int, int, void *); | |||
private: | |||
caca_dither *dither; | |||
}; | |||
__class Canvas | |||
{ | |||
friend class Caca; | |||
friend class Dither; | |||
friend class Font; | |||
public: | |||
Canvas(); | |||
Canvas(int width, int height); | |||
~Canvas(); | |||
void setSize(unsigned int w, unsigned int h); | |||
unsigned int getWidth(void); | |||
unsigned int getHeight(void); | |||
uint32_t getAttr(int, int); | |||
int setAttr(uint32_t); | |||
int setColorANSI(uint8_t f, uint8_t b); | |||
int setColorARGB(unsigned int f, unsigned int b); | |||
void Printf(int x, int y , char const * format, ...); | |||
void putChar(int x, int y, uint32_t ch); | |||
uint32_t getChar(int, int); | |||
void putStr(int x, int y, char *str); | |||
void Clear(void); | |||
void Blit(int, int, Canvas* c1, Canvas* c2); | |||
void Invert(); | |||
void Flip(); | |||
void Flop(); | |||
void Rotate180(); | |||
void RotateLeft(); | |||
void RotateRight(); | |||
void drawLine(int, int, int, int, uint32_t); | |||
void drawPolyline(int const x[], int const y[], int, uint32_t); | |||
void drawThinLine(int, int, int, int); | |||
void drawThinPolyline(int const x[], int const y[], int); | |||
void drawCircle(int, int, int, uint32_t); | |||
void drawEllipse(int, int, int, int, uint32_t); | |||
void drawThinEllipse(int, int, int, int); | |||
void fillEllipse(int, int, int, int, uint32_t); | |||
void drawBox(int, int, int, int, uint32_t); | |||
void drawThinBox(int, int, int, int); | |||
void drawCP437Box(int, int, int, int); | |||
void fillBox(int, int, int, int, uint32_t); | |||
void drawTriangle(int, int, int, int, int, int, uint32_t); | |||
void drawThinTriangle(int, int, int, int, int, int); | |||
void fillTriangle(int, int, int, int, int, int, uint32_t); | |||
int setBoundaries(caca_canvas_t *, int, int, unsigned int, unsigned int); | |||
unsigned int getFrameCount(); | |||
int setFrame(unsigned int); | |||
int createFrame(unsigned int); | |||
int freeFrame(unsigned int); | |||
char const * const * getImportList(void); | |||
long int importMemory(void const *, size_t, char const *); | |||
long int importFile(char const *, char const *); | |||
char const * const * getExportList(void); | |||
void *exportMemory(char const *, size_t *); | |||
static int Rand(int, int); | |||
static char const * getVersion(); | |||
protected: | |||
caca_canvas_t *get_caca_canvas_t(); | |||
private: | |||
caca_canvas_t *cv; | |||
}; | |||
#endif /* _CUCUL_PP_H */ |
@@ -1,12 +0,0 @@ | |||
prefix=@prefix@ | |||
exec_prefix=@exec_prefix@ | |||
libdir=@libdir@ | |||
includedir=@includedir@ | |||
Name: cucul++ | |||
Description: Canvas for ultrafast compositing of Unicode letters C++ binding | |||
Version: @VERSION@ | |||
Requires: | |||
Conflicts: | |||
Libs: -L${libdir} -lcucul++ | |||
Cflags: -I${includedir} |
@@ -15,7 +15,6 @@ | |||
#include <iostream> | |||
#include <cstring> | |||
#include <cucul++.h> | |||
#include <caca++.h> | |||
using namespace std; | |||
@@ -37,12 +37,6 @@ | |||
<Compile Include="..\csharp\Caca.cs" /> | |||
<Compile Include="..\csharp\AssemblyInfo.cs" /> | |||
</ItemGroup> | |||
<ItemGroup> | |||
<ProjectReference Include="cucul-sharp.csproj"> | |||
<Project>{C05C1521-F4E2-48D8-BD83-786EF345A887}</Project> | |||
<Name>cucul-sharp</Name> | |||
</ProjectReference> | |||
</ItemGroup> | |||
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" /> | |||
<!-- To modify your build process, add your task inside one of the targets below and uncomment it. | |||
Other similar extension points exist, see Microsoft.Common.targets. | |||
@@ -51,4 +45,4 @@ | |||
<Target Name="AfterBuild"> | |||
</Target> | |||
--> | |||
</Project> | |||
</Project> |
@@ -1,46 +0,0 @@ | |||
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> | |||
<PropertyGroup> | |||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> | |||
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> | |||
<ProductVersion>8.0.50727</ProductVersion> | |||
<SchemaVersion>2.0</SchemaVersion> | |||
<ProjectGuid>{C05C1521-F4E2-48D8-BD83-786EF345A887}</ProjectGuid> | |||
<OutputType>Library</OutputType> | |||
<AppDesignerFolder>Properties</AppDesignerFolder> | |||
<RootNamespace>cucul_sharp.vsproj</RootNamespace> | |||
<AssemblyName>cucul-sharp.vsproj</AssemblyName> | |||
</PropertyGroup> | |||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "> | |||
<DebugSymbols>true</DebugSymbols> | |||
<DebugType>full</DebugType> | |||
<Optimize>false</Optimize> | |||
<OutputPath>Debug\</OutputPath> | |||
<DefineConstants>DEBUG;TRACE</DefineConstants> | |||
<ErrorReport>prompt</ErrorReport> | |||
<WarningLevel>4</WarningLevel> | |||
</PropertyGroup> | |||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' "> | |||
<DebugType>pdbonly</DebugType> | |||
<Optimize>true</Optimize> | |||
<OutputPath>Release\</OutputPath> | |||
<DefineConstants>TRACE</DefineConstants> | |||
<ErrorReport>prompt</ErrorReport> | |||
<WarningLevel>4</WarningLevel> | |||
</PropertyGroup> | |||
<ItemGroup> | |||
<Reference Include="System" /> | |||
<Reference Include="System.Drawing" /> | |||
</ItemGroup> | |||
<ItemGroup> | |||
<Compile Include="..\csharp\Cucul.cs" /> | |||
<Compile Include="..\csharp\AssemblyInfo.cs" /> | |||
</ItemGroup> | |||
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" /> | |||
<!-- To modify your build process, add your task inside one of the targets below and uncomment it. | |||
Other similar extension points exist, see Microsoft.Common.targets. | |||
<Target Name="BeforeBuild"> | |||
</Target> | |||
<Target Name="AfterBuild"> | |||
</Target> | |||
--> | |||
</Project> |
@@ -38,7 +38,7 @@ | |||
<Tool | |||
Name="VCCLCompilerTool" | |||
Optimization="0" | |||
AdditionalIncludeDirectories="..\msvc;..\cucul;..\caca;..\cxx" | |||
AdditionalIncludeDirectories="..\msvc;..\caca;..\cxx" | |||
PreprocessorDefinitions="WIN32;_DEBUG;_LIB;__LIBCACA_PP__" | |||
MinimalRebuild="true" | |||
BasicRuntimeChecks="3" | |||
@@ -114,7 +114,7 @@ | |||
/> | |||
<Tool | |||
Name="VCCLCompilerTool" | |||
AdditionalIncludeDirectories="..\msvc;..\cucul;..\caca;..\cxx" | |||
AdditionalIncludeDirectories="..\msvc;..\caca;..\cxx" | |||
PreprocessorDefinitions="WIN32;NDEBUG;_LIB;__LIBCACA_PP__" | |||
RuntimeLibrary="2" | |||
WarningLevel="3" | |||
@@ -38,7 +38,7 @@ | |||
<Tool | |||
Name="VCCLCompilerTool" | |||
Optimization="0" | |||
AdditionalIncludeDirectories="..\msvc;..\cucul" | |||
AdditionalIncludeDirectories="..\msvc" | |||
PreprocessorDefinitions="WIN32;_DEBUG;_LIB;__LIBCACA__" | |||
MinimalRebuild="true" | |||
BasicRuntimeChecks="3" | |||
@@ -114,7 +114,7 @@ | |||
/> | |||
<Tool | |||
Name="VCCLCompilerTool" | |||
AdditionalIncludeDirectories="..\msvc;..\cucul" | |||
AdditionalIncludeDirectories="..\msvc" | |||
PreprocessorDefinitions="WIN32;NDEBUG;_LIB;__LIBCACA__" | |||
RuntimeLibrary="2" | |||
WarningLevel="3" | |||
@@ -177,6 +177,74 @@ | |||
RelativePath="..\caca\caca.c" | |||
> | |||
</File> | |||
<File | |||
RelativePath="..\caca\attr.c" | |||
> | |||
</File> | |||
<File | |||
RelativePath="..\caca\box.c" | |||
> | |||
</File> | |||
<File | |||
RelativePath="..\caca\string.c" | |||
> | |||
</File> | |||
<File | |||
RelativePath="..\caca\charset.c" | |||
> | |||
</File> | |||
<File | |||
RelativePath="..\caca\conic.c" | |||
> | |||
</File> | |||
<File | |||
RelativePath="..\caca\canvas.c" | |||
> | |||
</File> | |||
<File | |||
RelativePath="..\caca\dither.c" | |||
> | |||
</File> | |||
<File | |||
RelativePath="..\caca\export.c" | |||
> | |||
</File> | |||
<File | |||
RelativePath="..\caca\figfont.c" | |||
> | |||
</File> | |||
<File | |||
RelativePath="..\caca\file.c" | |||
> | |||
</File> | |||
<File | |||
RelativePath="..\caca\font.c" | |||
> | |||
</File> | |||
<File | |||
RelativePath="..\caca\frame.c" | |||
> | |||
</File> | |||
<File | |||
RelativePath="..\caca\import.c" | |||
> | |||
</File> | |||
<File | |||
RelativePath="..\caca\line.c" | |||
> | |||
</File> | |||
<File | |||
RelativePath="..\caca\transform.c" | |||
> | |||
</File> | |||
<File | |||
RelativePath="..\caca\triangle.c" | |||
> | |||
</File> | |||
<File | |||
RelativePath="..\caca\legacy.c" | |||
> | |||
</File> | |||
<File | |||
RelativePath="..\caca\driver_conio.c" | |||
> | |||
@@ -238,6 +306,14 @@ | |||
RelativePath="..\caca\caca_internals.h" | |||
> | |||
</File> | |||
<File | |||
RelativePath="..\caca\caca_types.h" | |||
> | |||
</File> | |||
<File | |||
RelativePath="..\stubs.h" | |||
> | |||
</File> | |||
<File | |||
RelativePath=".\config.h" | |||
> | |||
@@ -1,199 +0,0 @@ | |||
<?xml version="1.0" encoding="Windows-1252"?> | |||
<VisualStudioProject | |||
ProjectType="Visual C++" | |||
Version="8.00" | |||
Name="libcucul++" | |||
ProjectGUID="{9A5CF69C-8C9D-4186-B68D-ED73633A9B67}" | |||
> | |||
<Platforms> | |||
<Platform | |||
Name="Win32" | |||
/> | |||
</Platforms> | |||
<ToolFiles> | |||
</ToolFiles> | |||
<Configurations> | |||
<Configuration | |||
Name="Debug|Win32" | |||
OutputDirectory="$(SolutionDir)$(ConfigurationName)" | |||
IntermediateDirectory="$(ConfigurationName)" | |||
ConfigurationType="2" | |||
CharacterSet="2" | |||
> | |||
<Tool | |||
Name="VCPreBuildEventTool" | |||
/> | |||
<Tool | |||
Name="VCCustomBuildTool" | |||
/> | |||
<Tool | |||
Name="VCXMLDataGeneratorTool" | |||
/> | |||
<Tool | |||
Name="VCWebServiceProxyGeneratorTool" | |||
/> | |||
<Tool | |||
Name="VCMIDLTool" | |||
/> | |||
<Tool | |||
Name="VCCLCompilerTool" | |||
Optimization="0" | |||
AdditionalIncludeDirectories="..\msvc;..\cucul" | |||
PreprocessorDefinitions="WIN32;_DEBUG;_LIB;__LIBCUCUL_PP__" | |||
MinimalRebuild="true" | |||
BasicRuntimeChecks="3" | |||
RuntimeLibrary="3" | |||
WarningLevel="3" | |||
Detect64BitPortabilityProblems="true" | |||
DebugInformationFormat="4" | |||
CompileAs="2" | |||
DisableSpecificWarnings="4996;4142" | |||
/> | |||
<Tool | |||
Name="VCManagedResourceCompilerTool" | |||
/> | |||
<Tool | |||
Name="VCResourceCompilerTool" | |||
/> | |||
<Tool | |||
Name="VCPreLinkEventTool" | |||
/> | |||
<Tool | |||
Name="VCLinkerTool" | |||
ModuleDefinitionFile=".\libcucul++.def" | |||
GenerateDebugInformation="true" | |||
TargetMachine="1" | |||
/> | |||
<Tool | |||
Name="VCALinkTool" | |||
/> | |||
<Tool | |||
Name="VCManifestTool" | |||
/> | |||
<Tool | |||
Name="VCXDCMakeTool" | |||
/> | |||
<Tool | |||
Name="VCBscMakeTool" | |||
/> | |||
<Tool | |||
Name="VCFxCopTool" | |||
/> | |||
<Tool | |||
Name="VCAppVerifierTool" | |||
/> | |||
<Tool | |||
Name="VCWebDeploymentTool" | |||
/> | |||
<Tool | |||
Name="VCPostBuildEventTool" | |||
/> | |||
</Configuration> | |||
<Configuration | |||
Name="Release|Win32" | |||
OutputDirectory="$(SolutionDir)$(ConfigurationName)" | |||
IntermediateDirectory="$(ConfigurationName)" | |||
ConfigurationType="2" | |||
CharacterSet="2" | |||
WholeProgramOptimization="1" | |||
> | |||
<Tool | |||
Name="VCPreBuildEventTool" | |||
/> | |||
<Tool | |||
Name="VCCustomBuildTool" | |||
/> | |||
<Tool | |||
Name="VCXMLDataGeneratorTool" | |||
/> | |||
<Tool | |||
Name="VCWebServiceProxyGeneratorTool" | |||
/> | |||
<Tool | |||
Name="VCMIDLTool" | |||
/> | |||
<Tool | |||
Name="VCCLCompilerTool" | |||
AdditionalIncludeDirectories="..\msvc;..\cucul" | |||
PreprocessorDefinitions="WIN32;NDEBUG;_LIB;__LIBCUCUL_PP__" | |||
RuntimeLibrary="2" | |||
WarningLevel="3" | |||
Detect64BitPortabilityProblems="true" | |||
DebugInformationFormat="3" | |||
CompileAs="2" | |||
DisableSpecificWarnings="4996;4142" | |||
/> | |||
<Tool | |||
Name="VCManagedResourceCompilerTool" | |||
/> | |||
<Tool | |||
Name="VCResourceCompilerTool" | |||
/> | |||
<Tool | |||
Name="VCPreLinkEventTool" | |||
/> | |||
<Tool | |||
Name="VCLinkerTool" | |||
ModuleDefinitionFile=".\libcucul++.def" | |||
GenerateDebugInformation="true" | |||
OptimizeReferences="2" | |||
EnableCOMDATFolding="2" | |||
TargetMachine="1" | |||
/> | |||
<Tool | |||
Name="VCALinkTool" | |||
/> | |||
<Tool | |||
Name="VCManifestTool" | |||
/> | |||
<Tool | |||
Name="VCXDCMakeTool" | |||
/> | |||
<Tool | |||
Name="VCBscMakeTool" | |||
/> | |||
<Tool | |||
Name="VCFxCopTool" | |||
/> | |||
<Tool | |||
Name="VCAppVerifierTool" | |||
/> | |||
<Tool | |||
Name="VCWebDeploymentTool" | |||
/> | |||
<Tool | |||
Name="VCPostBuildEventTool" | |||
/> | |||
</Configuration> | |||
</Configurations> | |||
<References> | |||
</References> | |||
<Files> | |||
<Filter | |||
Name="Source Files" | |||
Filter="cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx" | |||
UniqueIdentifier="{4FC737F1-C7A5-4376-A066-2A32D752A2FF}" | |||
> | |||
<File | |||
RelativePath="..\cxx\cucul++.cpp" | |||
> | |||
</File> | |||
<File | |||
RelativePath=".\libcucul++.def" | |||
> | |||
</File> | |||
</Filter> | |||
<Filter | |||
Name="Header Files" | |||
Filter="h;hpp;hxx;hm;inl;inc;xsd" | |||
UniqueIdentifier="{93995380-89BD-4b04-88EB-625FBE52EBFB}" | |||
> | |||
<File | |||
RelativePath="..\cxx\cucul++.h" | |||
> | |||
</File> | |||
</Filter> | |||
</Files> | |||
<Globals> | |||
</Globals> | |||
</VisualStudioProject> |
@@ -1,281 +0,0 @@ | |||
<?xml version="1.0" encoding="Windows-1252"?> | |||
<VisualStudioProject | |||
ProjectType="Visual C++" | |||
Version="8,00" | |||
Name="libcucul" | |||
ProjectGUID="{44303C1F-BB6A-4C4B-BB19-7D475348F151}" | |||
> | |||
<Platforms> | |||
<Platform | |||
Name="Win32" | |||
/> | |||
</Platforms> | |||
<ToolFiles> | |||
</ToolFiles> | |||
<Configurations> | |||
<Configuration | |||
Name="Debug|Win32" | |||
OutputDirectory="$(SolutionDir)$(ConfigurationName)" | |||
IntermediateDirectory="$(ConfigurationName)" | |||
ConfigurationType="2" | |||
CharacterSet="2" | |||
> | |||
<Tool | |||
Name="VCPreBuildEventTool" | |||
/> | |||
<Tool | |||
Name="VCCustomBuildTool" | |||
/> | |||
<Tool | |||
Name="VCXMLDataGeneratorTool" | |||
/> | |||
<Tool | |||
Name="VCWebServiceProxyGeneratorTool" | |||
/> | |||
<Tool | |||
Name="VCMIDLTool" | |||
/> | |||
<Tool | |||
Name="VCCLCompilerTool" | |||
Optimization="0" | |||
AdditionalIncludeDirectories="..\msvc" | |||
PreprocessorDefinitions="WIN32;_DEBUG;_LIB;__LIBCUCUL__" | |||
MinimalRebuild="true" | |||
BasicRuntimeChecks="3" | |||
RuntimeLibrary="3" | |||
WarningLevel="3" | |||
Detect64BitPortabilityProblems="true" | |||
DebugInformationFormat="4" | |||
CompileAs="1" | |||
DisableSpecificWarnings="4996;4142" | |||
/> | |||
<Tool | |||
Name="VCManagedResourceCompilerTool" | |||
/> | |||
<Tool | |||
Name="VCResourceCompilerTool" | |||
/> | |||
<Tool | |||
Name="VCPreLinkEventTool" | |||
/> | |||
<Tool | |||
Name="VCLinkerTool" | |||
OutputFile="$(OutDir)\$(ProjectName).dll" | |||
ModuleDefinitionFile=".\libcucul.def" | |||
GenerateDebugInformation="true" | |||
TargetMachine="1" | |||
/> | |||
<Tool | |||
Name="VCALinkTool" | |||
/> | |||
<Tool | |||
Name="VCManifestTool" | |||
/> | |||
<Tool | |||
Name="VCXDCMakeTool" | |||
/> | |||
<Tool | |||
Name="VCBscMakeTool" | |||
/> | |||
<Tool | |||
Name="VCFxCopTool" | |||
/> | |||
<Tool | |||
Name="VCAppVerifierTool" | |||
/> | |||
<Tool | |||
Name="VCWebDeploymentTool" | |||
/> | |||
<Tool | |||
Name="VCPostBuildEventTool" | |||
/> | |||
</Configuration> | |||
<Configuration | |||
Name="Release|Win32" | |||
OutputDirectory="$(SolutionDir)$(ConfigurationName)" | |||
IntermediateDirectory="$(ConfigurationName)" | |||
ConfigurationType="2" | |||
CharacterSet="2" | |||
WholeProgramOptimization="1" | |||
> | |||
<Tool | |||
Name="VCPreBuildEventTool" | |||
/> | |||
<Tool | |||
Name="VCCustomBuildTool" | |||
/> | |||
<Tool | |||
Name="VCXMLDataGeneratorTool" | |||
/> | |||
<Tool | |||
Name="VCWebServiceProxyGeneratorTool" | |||
/> | |||
<Tool | |||
Name="VCMIDLTool" | |||
/> | |||
<Tool | |||
Name="VCCLCompilerTool" | |||
AdditionalIncludeDirectories="..\msvc" | |||
PreprocessorDefinitions="WIN32;NDEBUG;_LIB;__LIBCUCUL__" | |||
RuntimeLibrary="2" | |||
WarningLevel="3" | |||
Detect64BitPortabilityProblems="true" | |||
DebugInformationFormat="3" | |||
CompileAs="1" | |||
DisableSpecificWarnings="4996;4142" | |||
/> | |||
<Tool | |||
Name="VCManagedResourceCompilerTool" | |||
/> | |||
<Tool | |||
Name="VCResourceCompilerTool" | |||
/> | |||
<Tool | |||
Name="VCPreLinkEventTool" | |||
/> | |||
<Tool | |||
Name="VCLinkerTool" | |||
OutputFile="$(OutDir)\$(ProjectName).dll" | |||
ModuleDefinitionFile=".\libcucul.def" | |||
GenerateDebugInformation="true" | |||
OptimizeReferences="2" | |||
EnableCOMDATFolding="2" | |||
TargetMachine="1" | |||
/> | |||
<Tool | |||
Name="VCALinkTool" | |||
/> | |||
<Tool | |||
Name="VCManifestTool" | |||
/> | |||
<Tool | |||
Name="VCXDCMakeTool" | |||
/> | |||
<Tool | |||
Name="VCBscMakeTool" | |||
/> | |||
<Tool | |||
Name="VCFxCopTool" | |||
/> | |||
<Tool | |||
Name="VCAppVerifierTool" | |||
/> | |||
<Tool | |||
Name="VCWebDeploymentTool" | |||
/> | |||
<Tool | |||
Name="VCPostBuildEventTool" | |||
/> | |||
</Configuration> | |||
</Configurations> | |||
<References> | |||
</References> | |||
<Files> | |||
<Filter | |||
Name="Source Files" | |||
Filter="cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx" | |||
UniqueIdentifier="{4FC737F1-C7A5-4376-A066-2A32D752A2FF}" | |||
> | |||
<File | |||
RelativePath="..\cucul\attr.c" | |||
> | |||
</File> | |||
<File | |||
RelativePath="..\cucul\box.c" | |||
> | |||
</File> | |||
<File | |||
RelativePath="..\cucul\canvas.c" | |||
> | |||
</File> | |||
<File | |||
RelativePath="..\cucul\charset.c" | |||
> | |||
</File> | |||
<File | |||
RelativePath="..\cucul\conic.c" | |||
> | |||
</File> | |||
<File | |||
RelativePath="..\cucul\cucul.c" | |||
> | |||
</File> | |||
<File | |||
RelativePath="..\cucul\dither.c" | |||
> | |||
</File> | |||
<File | |||
RelativePath="..\cucul\export.c" | |||
> | |||
</File> | |||
<File | |||
RelativePath="..\cucul\figfont.c" | |||
> | |||
</File> | |||
<File | |||
RelativePath="..\cucul\file.c" | |||
> | |||
</File> | |||
<File | |||
RelativePath="..\cucul\font.c" | |||
> | |||
</File> | |||
<File | |||
RelativePath="..\cucul\frame.c" | |||
> | |||
</File> | |||
<File | |||
RelativePath="..\cucul\import.c" | |||
> | |||
</File> | |||
<File | |||
RelativePath="..\cucul\legacy.c" | |||
> | |||
</File> | |||
<File | |||
RelativePath=".\libcucul.def" | |||
> | |||
</File> | |||
<File | |||
RelativePath="..\cucul\line.c" | |||
> | |||
</File> | |||
<File | |||
RelativePath="..\cucul\transform.c" | |||
> | |||
</File> | |||
<File | |||
RelativePath="..\cucul\triangle.c" | |||
> | |||
</File> | |||
</Filter> | |||
<Filter | |||
Name="Header Files" | |||
Filter="h;hpp;hxx;hm;inl;inc;xsd" | |||
UniqueIdentifier="{93995380-89BD-4b04-88EB-625FBE52EBFB}" | |||
> | |||
<File | |||
RelativePath=".\config.h" | |||
> | |||
</File> | |||
<File | |||
RelativePath="..\cucul\cucul.h" | |||
> | |||
</File> | |||
<File | |||
RelativePath="..\cucul\cucul_internals.h" | |||
> | |||
</File> | |||
<File | |||
RelativePath="..\cucul\cucul_types.h" | |||
> | |||
</File> | |||
<File | |||
RelativePath="..\cucul\stubs.h" | |||
> | |||
</File> | |||
</Filter> | |||
</Files> | |||
<Globals> | |||
</Globals> | |||
</VisualStudioProject> |
@@ -30,7 +30,6 @@ caca_la_LIBADD = ../caca/libcaca.la | |||
EXTRA_DIST = ruby.dox \ | |||
ruby-caca.dox \ | |||
ruby-cucul.dox \ | |||
lib/caca.rb \ | |||
t/tc_canvas.rb \ | |||
t/tc_dither.rb \ | |||
@@ -1,4 +1,4 @@ | |||
This a Ruby binding for libcucul and libcaca. | |||
This a Ruby binding for libcaca. | |||
You can play with it by doing require 'caca' or require 'cucul' and looking at | |||
the Cucul and Caca modules, or maybe read the documentation :) | |||
You can play with it by doing require 'caca' and looking at | |||
the Caca module, or maybe read the documentation :) |
@@ -211,7 +211,7 @@ static VALUE blit(int argc, VALUE* argv, VALUE self) { | |||
if(CLASS_OF(src) != cCanvas) | |||
{ | |||
rb_raise(rb_eArgError, "src is not a Cucul::Canvas"); | |||
rb_raise(rb_eArgError, "src is not a Caca::Canvas"); | |||
} | |||
Data_Get_Struct(src, caca_canvas_t, csrc); | |||
@@ -219,7 +219,7 @@ static VALUE blit(int argc, VALUE* argv, VALUE self) { | |||
{ | |||
if(CLASS_OF(mask) != cCanvas) | |||
{ | |||
rb_raise(rb_eArgError, "mask is not a Cucul::Canvas"); | |||
rb_raise(rb_eArgError, "mask is not a Caca::Canvas"); | |||
} | |||
Data_Get_Struct(mask, caca_canvas_t, cmask); | |||
} | |||
@@ -447,7 +447,7 @@ static VALUE fill_triangle(VALUE self, VALUE x1, VALUE y1, VALUE x2, VALUE y2, V | |||
static VALUE dither_bitmap(VALUE self, VALUE x, VALUE y, VALUE w, VALUE h, VALUE d, VALUE pixels) | |||
{ | |||
if(CLASS_OF(d) != cDither) | |||
rb_raise(rb_eArgError, "d is not a Cucul::Dither"); | |||
rb_raise(rb_eArgError, "d is not a Caca::Dither"); | |||
Check_Type(pixels, T_STRING); | |||
caca_dither_bitmap(_SELF, NUM2INT(x), NUM2INT(y), NUM2INT(w), NUM2INT(h), DATA_PTR(d), StringValuePtr(pixels)); | |||
@@ -517,7 +517,7 @@ static VALUE render_canvas(VALUE self, VALUE font, VALUE width, VALUE height, VA | |||
if(CLASS_OF(font) != cFont) | |||
{ | |||
rb_raise(rb_eArgError, "First argument is not a Cucul::Font"); | |||
rb_raise(rb_eArgError, "First argument is not a Caca::Font"); | |||
} | |||
buf = malloc(width*height*4); | |||
@@ -570,9 +570,9 @@ get_singleton_double_list(import) | |||
/****/ | |||
void Init_caca_canvas(VALUE mCucul) | |||
void Init_caca_canvas(VALUE mCaca) | |||
{ | |||
cCanvas = rb_define_class_under(mCucul, "Canvas", rb_cObject); | |||
cCanvas = rb_define_class_under(mCaca, "Canvas", rb_cObject); | |||
rb_define_alloc_func(cCanvas, canvas_alloc); | |||
rb_define_method(cCanvas, "initialize", canvas_initialize, 2); | |||
@@ -45,7 +45,7 @@ static VALUE display_initialize(int argc, VALUE* argv, VALUE self) | |||
cv = arg1; | |||
if(CLASS_OF(arg2) == cCanvas) | |||
{ | |||
rb_raise(rb_eArgError, "Only one argument can be a Cucul::Canvas"); | |||
rb_raise(rb_eArgError, "Only one argument can be a Caca::Canvas"); | |||
} | |||
} | |||
else if(CLASS_OF(arg2) == cCanvas) | |||
@@ -179,9 +179,9 @@ get_set_str_from_list(color) | |||
get_set_str_from_list(charset) | |||
get_set_str_from_list(algorithm) | |||
void Init_caca_dither(VALUE mCucul) | |||
void Init_caca_dither(VALUE mCaca) | |||
{ | |||
cDither = rb_define_class_under(mCucul, "Dither", rb_cObject); | |||
cDither = rb_define_class_under(mCaca, "Dither", rb_cObject); | |||
rb_define_alloc_func(cDither, dither_alloc); | |||
rb_define_method(cDither, "initialize", dither_initialize, 8); | |||
@@ -85,9 +85,9 @@ static VALUE get_font_blocks(VALUE self) | |||
return ary; | |||
} | |||
void Init_caca_font(VALUE mCucul) | |||
void Init_caca_font(VALUE mCaca) | |||
{ | |||
cFont = rb_define_class_under(mCucul, "Font", rb_cObject); | |||
cFont = rb_define_class_under(mCaca, "Font", rb_cObject); | |||
rb_define_alloc_func(cFont, font_alloc); | |||
rb_define_method(cFont, "initialize", font_initialize, 1); | |||
@@ -1,4 +1,3 @@ | |||
require 'cucul' | |||
require 'caca.so' | |||
module Caca | |||
@@ -1,90 +1,176 @@ | |||
/* $Id$ */ /** \page libcaca-ruby-api Libcaca Ruby API | |||
/*$Id$ */ /** \page libcaca-ruby-api Libcaca Ruby API | |||
The classes available for libcaca are : | |||
Theclasses available for libcaca are : | |||
\li \b Caca::Display | |||
\li \b Caca::Event | |||
\li \b Caca::Event::Key | |||
\li \b Caca::Event::Key::Press | |||
\li \b Caca::Event::Key::Release | |||
\li \b Caca::Event::Mouse | |||
\li \b Caca::Event::Mouse::Press | |||
\li \b Caca::Event::Mouse::Release | |||
\li \b Caca::Event::Mouse::Motion | |||
\li \b Caca::Event::Resize | |||
\li \b Caca::Event::Quit | |||
\li\b Caca::Canvas : functions that have a caca_canvas_t* as first argument | |||
\li\b Caca::Dither : functions that have a caca_dither_t* as first argument | |||
\li\b Caca::Font : functions that have a caca_font_t* as first argument | |||
(The constructor can currently only accept the name of a builtin font) | |||
\li\b Caca::Display | |||
\li\b Caca::Event | |||
\li\b Caca::Event::Key | |||
\li\b Caca::Event::Key::Press | |||
\li\b Caca::Event::Key::Release | |||
\li\b Caca::Event::Mouse | |||
\li\b Caca::Event::Mouse::Press | |||
\li\b Caca::Event::Mouse::Release | |||
\li\b Caca::Event::Mouse::Motion | |||
\li\b Caca::Event::Resize | |||
\li\b Caca::Event::Quit | |||
Thecharacter set conversion functions are not available yet in the binding. | |||
\code | |||
$irb -rcaca | |||
irb(main):001:0>class Object | |||
irb(main):002:1>def Object.my_instance_methods | |||
irb(main):003:2>instance_methods.sort - ancestors[1].instance_methods | |||
irb(main):004:2>end | |||
irb(main):005:1>def Object.my_methods | |||
irb(main):006:2>methods.sort - ancestors[1].methods | |||
irb(main):007:2>end | |||
irb(main):008:1>end | |||
\endcode | |||
\code | |||
irb(main):009:0>Caca.constants | |||
=>["BROWN", "BOLD", "GREEN", "LIGHTMAGENTA", "LIGHTBLUE", "BLINK", | |||
"MAGENTA","DEFAULT", "TRANSPARENT", "BLUE", "LIGHTRED", "DARKGRAY", | |||
"UNDERLINE","RED", "WHITE", "BLACK", "LIGHTCYAN", "LIGHTGRAY", | |||
"ITALICS","CYAN", "YELLOW", "LIGHTGREEN", "Canvas", "Dither", "Font"] | |||
\endcode | |||
\code | |||
irb(main):010:0>Caca.my_methods | |||
=>["version"] | |||
\endcode | |||
\code | |||
irb(main):011:0>Caca::Canvas.my_methods | |||
=>["export_list", "import_list"] | |||
\endcode | |||
\code | |||
irb(main):012:0>Caca::Canvas.my_instance_methods | |||
=>["attr=", "blit", "clear", "create_frame", "cursor_x", "cursor_y", | |||
"dither_bitmap","draw_box", "draw_circle", "draw_cp437_box", "draw_ellipse", | |||
"draw_line","draw_polyline", "draw_thin_box", "draw_thin_ellipse", | |||
"draw_thin_line","draw_thin_polyline", "draw_thin_triangle", | |||
"draw_triangle","export_memory", "fill_box", "fill_ellipse", | |||
"fill_triangle","flip", "flop", "frame=", "frame_count", "frame_name", | |||
"frame_name=","free_frame", "get_attr", "get_char", "gotoxy", | |||
"handle_x","handle_y", "height", "height=", "import_file", | |||
"import_memory","invert", "printf", "put_attr", "put_char", "put_str", | |||
"rotate_180","rotate_left", "rotate_right", "set_attr", | |||
"set_boundaries","set_color_ansi", "set_color_argb", "set_frame", | |||
"set_frame_name","set_handle", "set_height", "set_size", "set_width", | |||
"stretch_left","stretch_right", "width", "width="] | |||
\endcode | |||
\code | |||
irb(main):013:0>Caca::Font.my_methods | |||
=>["list"] | |||
\endcode | |||
\code | |||
$ irb -rcaca | |||
irb(main):001:0> class Object | |||
irb(main):002:1> def Object.my_instance_methods | |||
irb(main):003:2> instance_methods.sort - ancestors[1].instance_methods | |||
irb(main):004:2> end | |||
irb(main):005:1> def Object.my_methods | |||
irb(main):006:2> methods.sort - ancestors[1].methods | |||
irb(main):007:2> end | |||
irb(main):008:1> end | |||
irb(main):014:0>Caca::Font.my_instance_methods | |||
=>["blocks", "height", "width"] | |||
\endcode | |||
\code | |||
irb(main):009:0> Caca.my_methods | |||
=> ["version"] | |||
irb(main):015:0>Caca::Dither.my_instance_methods | |||
=>["algorithm=", "algorithm_list", "antialias=", "antialias_list", | |||
"brightness=","charset=", "charset_list", "color=", "color_list", | |||
"contrast=","gamma=", "palette=", "set_algorithm", "set_antialias", | |||
"set_brightness","set_charset", "set_color", "set_contrast", | |||
"set_gamma","set_palette"] | |||
\endcode | |||
\code | |||
irb(main):010:0> Caca::Display.my_instance_methods | |||
=> ["canvas", "get_event", "height", "mouse=", "mouse_x", "mouse_y", "refresh", | |||
"set_mouse", "set_time", "set_title", "time", "time=", "title=", "width"] | |||
irb(main):010:0>Caca::Display.my_instance_methods | |||
=>["canvas", "get_event", "height", "mouse=", "mouse_x", "mouse_y", "refresh", | |||
"set_mouse","set_time", "set_title", "time", "time=", "title=", "width"] | |||
\endcode | |||
\code | |||
irb(main):011:0> Caca::Event.constants | |||
=> ["Key", "Quit", "TYPE", "Mouse", "Resize"] | |||
irb(main):011:0>Caca::Event.constants | |||
=>["Key", "Quit", "TYPE", "Mouse", "Resize"] | |||
\endcode | |||
\code | |||
irb(main):012:0> Caca::Event.my_instance_methods | |||
=> ["quit?"] | |||
irb(main):012:0>Caca::Event.my_instance_methods | |||
=>["quit?"] | |||
\endcode | |||
\code | |||
irb(main):013:0> Caca::Event::Key.my_instance_methods | |||
=> ["ch", "utf32", "utf8"] | |||
irb(main):013:0>Caca::Event::Key.my_instance_methods | |||
=>["ch", "utf32", "utf8"] | |||
\endcode | |||
\code | |||
irb(main):014:0> Caca::Event::Mouse.my_instance_methods | |||
=> ["button", "x", "y"] | |||
irb(main):014:0>Caca::Event::Mouse.my_instance_methods | |||
=>["button", "x", "y"] | |||
\endcode | |||
\code | |||
irb(main):015:0> Caca::Event::Resize.my_instance_methods | |||
=> ["w", "h"] | |||
irb(main):015:0>Caca::Event::Resize.my_instance_methods | |||
=>["w", "h"] | |||
\endcode | |||
\section Samples | |||
\sectionSamples | |||
\code | |||
$ruby -rcaca -e 'c=Caca::Canvas.new(6, 3).fill_box(0,0,2,2,"#"[0]); | |||
c2=Caca::Canvas.new(1,1).put_str(0,0,"x"); c.blit(1,1,c2); puts | |||
c.export_memory("irc")' | |||
### | |||
#x# | |||
### | |||
\endcode | |||
\code | |||
require 'caca' | |||
c = Cucul::Canvas.new(20,10) | |||
c.put_str(2, 3, "plop!") | |||
c.draw_thin_polyline([[0,0], [0,2], [5,2], [0,0]]) | |||
d = Caca::Display.new(c) | |||
d.title = "Test !" | |||
$ruby -e 'puts Caca::Canvas.new(6,3).draw_thin_polyline([[0,0], [0,2], | |||
[5,2],[0,0]]).export_memory("irc")' | |||
-. | |||
|`. | |||
----`- | |||
\endcode | |||
\code | |||
$ruby -rcaca -e 'p Caca::Canvas.export_list' | |||
[["caca","native libcaca format"], ["ansi", "ANSI"], ["utf8", "UTF-8 | |||
withANSI escape codes"], ["utf8cr", "UTF-8 with ANSI escape codes and | |||
MS-DOS\\r"], ["html", "HTML"], ["html3", "backwards-compatible HTML"], | |||
["irc","IRC with mIRC colours"], ["ps", "PostScript document"], ["svg", | |||
"SVGvector image"], ["tga", "TGA image"]] | |||
\endcode | |||
\code | |||
$ruby -rcaca -e 'p Caca::Font.list' | |||
["Monospace9", "Monospace Bold 12"] | |||
\endcode | |||
\code | |||
require'caca' | |||
c= Caca::Canvas.new(20,10) | |||
c.put_str(2,3, "plop!") | |||
c.draw_thin_polyline([[0,0],[0,2], [5,2], [0,0]]) | |||
d= Caca::Display.new(c) | |||
d.title= "Test !" | |||
d.refresh | |||
# Redefine Event::Key#quit? so that q, Q, and Esc become exit keys | |||
module Caca | |||
class Event::Key | |||
def quit? | |||
"qQ^[".split('').member?(@ch.chr) | |||
end | |||
end | |||
#Redefine Event::Key#quit? so that q, Q, and Esc become exit keys | |||
moduleCaca | |||
class Event::Key | |||
def quit? | |||
"qQ^[".split('').member?(@ch.chr) | |||
end | |||
end | |||
end | |||
while((e = d.get_event(Caca::Event, -1)) && ! e.quit?) | |||
p e | |||
d.refresh | |||
while((e= d.get_event(Caca::Event, -1)) && ! e.quit?) | |||
p e | |||
d.refresh | |||
end | |||
\endcode | |||
@@ -1,112 +0,0 @@ | |||
/* $Id$ */ /** \page libcucul-ruby-api Libcucul Ruby API | |||
The classes available for libcucul are : | |||
\li \b Cucul::Canvas : functions that have a cucul_canvas_t* as first argument | |||
\li \b Cucul::Dither : functions that have a cucul_dither_t* as first argument | |||
\li \b Cucul::Font : functions that have a cucul_font_t* as first argument | |||
(The constructor can currently only accept the name of a builtin font) | |||
The character set conversion functions are not available yet in the binding. | |||
\code | |||
$ irb -rcucul | |||
irb(main):001:0> class Object | |||
irb(main):002:1> def Object.my_instance_methods | |||
irb(main):003:2> instance_methods.sort - ancestors[1].instance_methods | |||
irb(main):004:2> end | |||
irb(main):005:1> def Object.my_methods | |||
irb(main):006:2> methods.sort - ancestors[1].methods | |||
irb(main):007:2> end | |||
irb(main):008:1> end | |||
\endcode | |||
\code | |||
irb(main):009:0> Cucul.constants | |||
=> ["BROWN", "BOLD", "GREEN", "LIGHTMAGENTA", "LIGHTBLUE", "BLINK", | |||
"MAGENTA", "DEFAULT", "TRANSPARENT", "BLUE", "LIGHTRED", "DARKGRAY", | |||
"UNDERLINE", "RED", "WHITE", "BLACK", "LIGHTCYAN", "LIGHTGRAY", | |||
"ITALICS", "CYAN", "YELLOW", "LIGHTGREEN", "Canvas", "Dither", "Font"] | |||
\endcode | |||
\code | |||
irb(main):010:0> Cucul.my_methods | |||
=> ["version"] | |||
\endcode | |||
\code | |||
irb(main):011:0> Cucul::Canvas.my_methods | |||
=> ["export_list", "import_list"] | |||
\endcode | |||
\code | |||
irb(main):012:0> Cucul::Canvas.my_instance_methods | |||
=> ["attr=", "blit", "clear", "create_frame", "cursor_x", "cursor_y", | |||
"dither_bitmap", "draw_box", "draw_circle", "draw_cp437_box", "draw_ellipse", | |||
"draw_line", "draw_polyline", "draw_thin_box", "draw_thin_ellipse", | |||
"draw_thin_line", "draw_thin_polyline", "draw_thin_triangle", | |||
"draw_triangle", "export_memory", "fill_box", "fill_ellipse", | |||
"fill_triangle", "flip", "flop", "frame=", "frame_count", "frame_name", | |||
"frame_name=", "free_frame", "get_attr", "get_char", "gotoxy", | |||
"handle_x", "handle_y", "height", "height=", "import_file", | |||
"import_memory", "invert", "printf", "put_attr", "put_char", "put_str", | |||
"rotate_180", "rotate_left", "rotate_right", "set_attr", | |||
"set_boundaries", "set_color_ansi", "set_color_argb", "set_frame", | |||
"set_frame_name", "set_handle", "set_height", "set_size", "set_width", | |||
"stretch_left", "stretch_right", "width", "width="] | |||
\endcode | |||
\code | |||
irb(main):013:0> Cucul::Font.my_methods | |||
=> ["list"] | |||
\endcode | |||
\code | |||
irb(main):014:0> Cucul::Font.my_instance_methods | |||
=> ["blocks", "height", "width"] | |||
\endcode | |||
\code | |||
irb(main):015:0> Cucul::Dither.my_instance_methods | |||
=> ["algorithm=", "algorithm_list", "antialias=", "antialias_list", | |||
"brightness=", "charset=", "charset_list", "color=", "color_list", | |||
"contrast=", "gamma=", "palette=", "set_algorithm", "set_antialias", | |||
"set_brightness", "set_charset", "set_color", "set_contrast", | |||
"set_gamma", "set_palette"] | |||
\endcode | |||
\section Samples | |||
\code | |||
$ ruby -rcucul -e 'c=Cucul::Canvas.new(6, 3).fill_box(0,0,2,2,"#"[0]); | |||
c2=Cucul::Canvas.new(1, 1).put_str(0,0,"x"); c.blit(1,1,c2); puts | |||
c.export_memory("irc")' | |||
### | |||
#x# | |||
### | |||
\endcode | |||
\code | |||
$ ruby -e 'puts Cucul::Canvas.new(6,3).draw_thin_polyline([[0,0], [0,2], | |||
[5,2],[0,0]]).export_memory("irc")' | |||
-. | |||
| `. | |||
----`- | |||
\endcode | |||
\code | |||
$ ruby -rcucul -e 'p Cucul::Canvas.export_list' | |||
[["caca", "native libcaca format"], ["ansi", "ANSI"], ["utf8", "UTF-8 | |||
with ANSI escape codes"], ["utf8cr", "UTF-8 with ANSI escape codes and | |||
MS-DOS \\r"], ["html", "HTML"], ["html3", "backwards-compatible HTML"], | |||
["irc", "IRC with mIRC colours"], ["ps", "PostScript document"], ["svg", | |||
"SVG vector image"], ["tga", "TGA image"]] | |||
\endcode | |||
\code | |||
$ ruby -rcucul -e 'p Cucul::Font.list' | |||
["Monospace 9", "Monospace Bold 12"] | |||
\endcode | |||
*/ |
@@ -1,12 +1,12 @@ | |||
require 'test/unit' | |||
require 'cucul' | |||
require 'caca' | |||
class TC_Canvas < Test::Unit::TestCase | |||
def setup | |||
@c = Cucul::Canvas.new(3, 3) | |||
@c = Caca::Canvas.new(3, 3) | |||
end | |||
def test_create | |||
c = Cucul::Canvas.new(3, 3) | |||
c = Caca::Canvas.new(3, 3) | |||
assert_not_nil(c, 'Canvas creation failed') | |||
assert(c.width == 3 && c.height == 3, 'Wrong size for new canvas') | |||
end | |||
@@ -45,13 +45,13 @@ class TC_Canvas < Test::Unit::TestCase | |||
assert_equal(42, @c.get_char(1,1)) | |||
end | |||
def test_render | |||
c = Cucul::Canvas.new(4,4) | |||
c = Caca::Canvas.new(4,4) | |||
c.put_str(0,0,"plop") | |||
f = Cucul::Font.new(Cucul::Font.list[0]) | |||
f = Caca::Font.new(Caca::Font.list[0]) | |||
assert_not_nil(c.render(f, c.width*f.width, c.height*f.height, c.width*f.width*4)) | |||
end | |||
def test_fail_render | |||
c = Cucul::Canvas.new(4,4) | |||
c = Caca::Canvas.new(4,4) | |||
assert_raise(ArgumentError) { | |||
c.render(nil, c.width, c.height, c.width*4) | |||
} | |||
@@ -14,17 +14,17 @@ class TC_Canvas < Test::Unit::TestCase | |||
assert_raise(RuntimeError){Caca::Display.new("plop")} | |||
driver = Caca::Display.driver_list[0] | |||
assert_raise(ArgumentError){Caca::Display.new(driver, driver)} | |||
c = Cucul::Canvas.new(3, 3) | |||
c = Caca::Canvas.new(3, 3) | |||
assert_raise(ArgumentError){Caca::Display.new(c, c)} | |||
end | |||
def test_create_from_canvas | |||
c = Cucul::Canvas.new(3, 3) | |||
c = Caca::Canvas.new(3, 3) | |||
d = Caca::Display.new(c) | |||
assert_not_nil(d, 'Display creation failed') | |||
assert_equal(d.canvas, c, 'Wrong canvas') | |||
end | |||
def test_set_title | |||
c = Cucul::Canvas.new(3, 3) | |||
c = Caca::Canvas.new(3, 3) | |||
d = Caca::Display.new(c) | |||
d.title = "Test !" | |||
end | |||
@@ -1,50 +1,50 @@ | |||
require 'test/unit' | |||
require 'cucul' | |||
require 'caca' | |||
class TC_Canvas < Test::Unit::TestCase | |||
def test_create | |||
assert_nothing_raised { | |||
d = Cucul::Dither.new(8, 32, 32, 32, 0, 0, 0, 0) | |||
d = Caca::Dither.new(8, 32, 32, 32, 0, 0, 0, 0) | |||
} | |||
end | |||
def test_fail_create | |||
assert_raise(RuntimeError) { | |||
d = Cucul::Dither.new(-1, 32, 32, 32, 0, 0, 0, 0) | |||
d = Caca::Dither.new(-1, 32, 32, 32, 0, 0, 0, 0) | |||
} | |||
end | |||
def test_set_palette | |||
assert_nothing_raised { | |||
d = Cucul::Dither.new(8, 32, 32, 32, 0, 0, 0, 0) | |||
d = Caca::Dither.new(8, 32, 32, 32, 0, 0, 0, 0) | |||
d.palette=[[0xfff, 0xfff, 0xfff, 0xfff]]*256 | |||
} | |||
end | |||
def test_fail_set_palette | |||
assert_raise(ArgumentError) { | |||
d = Cucul::Dither.new(8, 32, 32, 32, 0, 0, 0, 0) | |||
d = Caca::Dither.new(8, 32, 32, 32, 0, 0, 0, 0) | |||
d.palette=[] | |||
} | |||
end | |||
def test_fail_set_palette2 | |||
assert_raise(RuntimeError) { | |||
d = Cucul::Dither.new(8, 32, 32, 32, 0, 0, 0, 0) | |||
d = Caca::Dither.new(8, 32, 32, 32, 0, 0, 0, 0) | |||
d.palette=[[0xffff, 0, 0, 0]]*256 | |||
} | |||
end | |||
def test_set_brightness | |||
assert_nothing_raised { | |||
d = Cucul::Dither.new(8, 32, 32, 32, 0, 0, 0, 0) | |||
d = Caca::Dither.new(8, 32, 32, 32, 0, 0, 0, 0) | |||
d.brightness=0.5 | |||
} | |||
end | |||
def test_set_gamma | |||
assert_nothing_raised { | |||
d = Cucul::Dither.new(8, 32, 32, 32, 0, 0, 0, 0) | |||
d = Caca::Dither.new(8, 32, 32, 32, 0, 0, 0, 0) | |||
d.gamma=0.5 | |||
} | |||
end | |||
def test_set_contrast | |||
assert_nothing_raised { | |||
d = Cucul::Dither.new(8, 32, 32, 32, 0, 0, 0, 0) | |||
d = Caca::Dither.new(8, 32, 32, 32, 0, 0, 0, 0) | |||
d.contrast=0.5 | |||
} | |||
end | |||
@@ -1,13 +1,13 @@ | |||
require 'test/unit' | |||
require 'cucul' | |||
require 'caca' | |||
class TC_Canvas < Test::Unit::TestCase | |||
def test_list | |||
assert_not_nil(Cucul::Font.list) | |||
assert_not_nil(Caca::Font.list) | |||
end | |||
def test_load | |||
Cucul::Font.list.each{|f| | |||
font = Cucul::Font.new(f) | |||
Caca::Font.list.each{|f| | |||
font = Caca::Font.new(f) | |||
assert_not_nil(font) | |||
assert_not_nil(font.width) | |||
assert_not_nil(font.height) | |||
@@ -16,7 +16,7 @@ class TC_Canvas < Test::Unit::TestCase | |||
end | |||
def test_fail_load | |||
assert_raise(RuntimeError) { | |||
Cucul::Font.new("This font should not exist") | |||
Caca::Font.new("This font should not exist") | |||
} | |||
end | |||
end |
@@ -1,9 +1,9 @@ | |||
require 'test/unit' | |||
require 'cucul' | |||
require 'caca' | |||
class TC_Frame < Test::Unit::TestCase | |||
def setup | |||
@c = Cucul::Canvas.new(3, 3) | |||
@c = Caca::Canvas.new(3, 3) | |||
end | |||
def test_create | |||
f = @c.create_frame(1) | |||