334 行
7.0 KiB

  1. #include "cucul++.h"
  2. Cucul::Cucul()
  3. {
  4. qq = cucul_create(0,0);
  5. if(!qq) throw -1;
  6. }
  7. Cucul::Cucul(int width, int height)
  8. {
  9. qq = cucul_create(width, height);
  10. if(!qq) throw -1;
  11. }
  12. Cucul::~Cucul()
  13. {
  14. if(qq) {
  15. cucul_free(qq);
  16. }
  17. }
  18. cucul_t *Cucul::get_cucul_t()
  19. {
  20. return qq;
  21. }
  22. void Cucul::set_size(unsigned int width, unsigned int height)
  23. {
  24. cucul_set_size (qq, width, height);
  25. }
  26. unsigned int Cucul::get_width(void)
  27. {
  28. return cucul_get_width (qq);
  29. }
  30. unsigned int Cucul::get_height(void)
  31. {
  32. return cucul_get_height (qq);
  33. }
  34. void Cucul::set_color(unsigned int f, unsigned int b)
  35. {
  36. cucul_set_color (qq, f, b);
  37. }
  38. char const * Cucul::get_color_name (unsigned int color)
  39. {
  40. return cucul_get_color_name (color);
  41. }
  42. void Cucul::putchar (int x, int y, char c)
  43. {
  44. cucul_putchar (qq, x, y, c);
  45. }
  46. void Cucul::putstr (int x, int y, char *str)
  47. {
  48. cucul_putstr(qq, x, y, str);
  49. }
  50. //void Cucul::printf ( int, int, char const *,...)
  51. void Cucul::clear ()
  52. {
  53. cucul_clear(qq);
  54. }
  55. void Cucul::blit ( int x, int y, Cucul* c1, Cucul* c2)
  56. {
  57. cucul_blit(qq, x, y, c1->get_cucul_t(), c2->get_cucul_t());
  58. }
  59. void Cucul::invert ()
  60. {
  61. cucul_invert(qq);
  62. }
  63. void Cucul::flip ()
  64. {
  65. cucul_flip(qq);
  66. }
  67. void Cucul::flop ()
  68. {
  69. cucul_flop(qq);
  70. }
  71. void Cucul::rotate ()
  72. {
  73. cucul_rotate(qq);
  74. }
  75. void Cucul::draw_line (int x1 , int y1, int x2, int y2, char const *c)
  76. {
  77. cucul_draw_line(qq, x1,y1,x2,y2, c);
  78. }
  79. void Cucul::draw_polyline (int const x[], int const y[], int f, char const *c)
  80. {
  81. cucul_draw_polyline(qq, x, y, f, c);
  82. }
  83. void Cucul::draw_thin_line (int x1 , int y1, int x2, int y2)
  84. {
  85. cucul_draw_thin_line(qq, x1, y1, x2, y2);
  86. }
  87. void Cucul::draw_thin_polyline ( int const x[], int const y[], int f)
  88. {
  89. cucul_draw_thin_polyline(qq, x, y, f);
  90. }
  91. void Cucul::draw_circle ( int x, int y, int d, char const *c)
  92. {
  93. cucul_draw_circle(qq, x, y, d, c);
  94. }
  95. void Cucul::draw_ellipse ( int x, int y, int d1, int d2, char const *c)
  96. {
  97. cucul_draw_ellipse(qq, x, y, d1, d2, c);
  98. }
  99. void Cucul::draw_thin_ellipse ( int x, int y, int d1, int d2)
  100. {
  101. cucul_draw_thin_ellipse(qq, x, y, d1, d2);
  102. }
  103. void Cucul::fill_ellipse ( int x, int y, int d1, int d2, char const *c)
  104. {
  105. cucul_fill_ellipse(qq, x, y, d1, d2, c);
  106. }
  107. void Cucul::draw_box ( int x, int y, int w, int h, char const *c)
  108. {
  109. cucul_draw_box(qq, x, y, w, h, c);
  110. }
  111. void Cucul::draw_thin_box ( int x, int y, int w, int h)
  112. {
  113. cucul_draw_thin_box(qq, x, y, w, h);
  114. }
  115. void Cucul::fill_box ( int x, int y, int w, int h, char const *c)
  116. {
  117. cucul_fill_box(qq, x, y, w, h, c);
  118. }
  119. void Cucul::draw_triangle ( int x1, int y1, int x2, int y2, int x3, int y3, char const *c)
  120. {
  121. cucul_draw_triangle(qq, x1, y1, x2, y2, x3, y3, c);
  122. }
  123. void Cucul::draw_thin_triangle ( int x1, int y1, int x2, int y2, int x3, int y3)
  124. {
  125. cucul_draw_thin_triangle(qq, x1, y1, x2, y2, x3, y3);
  126. }
  127. void Cucul::fill_triangle ( int x1, int y1, int x2, int y2, int x3, int y3, const char *c)
  128. {
  129. cucul_fill_triangle(qq, x1, y1, x2, y2, x3, y3, c);
  130. }
  131. int Cucul::rand (int min, int max)
  132. {
  133. return cucul_rand(min, max);
  134. }
  135. unsigned int Cucul::sqrt (unsigned int v)
  136. {
  137. return cucul_sqrt(v);
  138. }
  139. Cucul::Sprite * Cucul::load_sprite (char const *f)
  140. {
  141. Cucul::Sprite *s = new Cucul::Sprite();
  142. s->sprite = cucul_load_sprite(f);
  143. return s;
  144. }
  145. int Cucul::get_sprite_frames (Cucul::Sprite const *s)
  146. {
  147. return cucul_get_sprite_frames(s->sprite);
  148. }
  149. int Cucul::get_sprite_width (Cucul::Sprite const *s, int v)
  150. {
  151. return cucul_get_sprite_width(s->sprite, v);
  152. }
  153. int Cucul::get_sprite_height (Cucul::Sprite const *s, int v)
  154. {
  155. return cucul_get_sprite_height(s->sprite, v);
  156. }
  157. int Cucul::get_sprite_dx (Cucul::Sprite const *s, int v)
  158. {
  159. return cucul_get_sprite_dx(s->sprite, v);
  160. }
  161. int Cucul::get_sprite_dy (Cucul::Sprite const *s, int v)
  162. {
  163. return cucul_get_sprite_dy(s->sprite, v);
  164. }
  165. void Cucul::draw_sprite ( int x, int y, Cucul::Sprite const *s, int v)
  166. {
  167. cucul_draw_sprite(qq, x, y, s->sprite, v);
  168. }
  169. void Cucul::free_sprite (Cucul::Sprite *s)
  170. {
  171. cucul_free_sprite(s->sprite);
  172. }
  173. Cucul::Dither * Cucul::create_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)
  174. {
  175. Cucul::Dither *d = new Dither();
  176. d->dither = cucul_create_dither(v1,v2,v3,v4,v5,v6,v7,v8);
  177. return d;
  178. }
  179. void Cucul::set_dither_palette (Cucul::Dither *d, unsigned int r[], unsigned int g[], unsigned int b[], unsigned int a[])
  180. {
  181. cucul_set_dither_palette(d->dither, r, g, b, a);
  182. }
  183. void Cucul::set_dither_brightness (Cucul::Dither *d, float f)
  184. {
  185. cucul_set_dither_brightness(d->dither, f);
  186. }
  187. void Cucul::set_dither_gamma (Cucul::Dither *d, float f)
  188. {
  189. cucul_set_dither_gamma(d->dither, f);
  190. }
  191. void Cucul::set_dither_contrast ( Cucul::Dither *d, float f)
  192. {
  193. cucul_set_dither_contrast(d->dither, f);
  194. }
  195. void Cucul::set_dither_invert ( Cucul::Dither *d, int i)
  196. {
  197. cucul_set_dither_invert(d->dither, i);
  198. }
  199. void Cucul::set_dither_antialias ( Cucul::Dither *d, char const *c)
  200. {
  201. cucul_set_dither_antialias(d->dither, c);
  202. }
  203. char const *const * Cucul::get_dither_antialias_list ( Cucul::Dither const *d)
  204. {
  205. return cucul_get_dither_antialias_list(d->dither);
  206. }
  207. void Cucul::set_dither_color ( Cucul::Dither *d, char const *c)
  208. {
  209. cucul_set_dither_color(d->dither, c);
  210. }
  211. char const *const * Cucul::get_dither_color_list ( Cucul::Dither const *d)
  212. {
  213. return cucul_get_dither_color_list(d->dither);
  214. }
  215. void Cucul::set_dither_charset ( Cucul::Dither *d, char const *c)
  216. {
  217. cucul_set_dither_charset(d->dither, c);
  218. }
  219. char const *const * Cucul::get_dither_charset_list ( Cucul::Dither const *d)
  220. {
  221. return cucul_get_dither_charset_list(d->dither);
  222. }
  223. void Cucul::set_dither_mode ( Cucul::Dither *d, char const *c)
  224. {
  225. cucul_set_dither_mode(d->dither, c);
  226. }
  227. char const *const * Cucul::get_dither_mode_list ( Cucul::Dither const *d)
  228. {
  229. return cucul_get_dither_mode_list(d->dither);
  230. }
  231. void Cucul::dither_bitmap ( int x, int y, int w, int h, Cucul::Dither const *d, void *v)
  232. {
  233. cucul_dither_bitmap(qq, x, y, w, h, d->dither, v);
  234. }
  235. void Cucul::free_dither ( Cucul::Dither *d)
  236. {
  237. cucul_free_dither(d->dither);
  238. }
  239. Cucul::Font * Cucul::load_font (void const *s, unsigned int v)
  240. {
  241. Cucul::Font *f = new Cucul::Font();
  242. f->font = cucul_load_font(s, v);
  243. return f;
  244. }
  245. char const *const * Cucul::get_font_list (void)
  246. {
  247. return cucul_get_font_list();
  248. }
  249. unsigned int Cucul::get_font_width ( Cucul::Font *f)
  250. {
  251. return cucul_get_font_width(f->font);
  252. }
  253. unsigned int Cucul::get_font_height ( Cucul::Font *f)
  254. {
  255. return cucul_get_font_height(f->font);
  256. }
  257. void Cucul::render_canvas (Cucul::Font *f, unsigned char *c, unsigned int x, unsigned int y, unsigned int w)
  258. {
  259. cucul_render_canvas(qq, f->font, c, x,y,w);
  260. }
  261. void Cucul::free_font ( Cucul::Font *f)
  262. {
  263. cucul_free_font(f->font);
  264. }
  265. Cucul::Buffer * Cucul::create_export (char const *c)
  266. {
  267. Cucul::Buffer *b = new Cucul::Buffer();
  268. b->buffer = cucul_create_export(qq, c);
  269. return b;
  270. }
  271. char const *const * Cucul::get_export_list (void)
  272. {
  273. return cucul_get_export_list();
  274. }