No puede seleccionar más de 25 temas Los temas deben comenzar con una letra o número, pueden incluir guiones ('-') y pueden tener hasta 35 caracteres de largo.

cucul++.cpp 7.4 KiB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350
  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 x , int y , char const * format,...)
  51. {
  52. char tmp[BUFSIZ];
  53. char *buf = tmp;
  54. va_list args;
  55. va_start(args, format);
  56. #if defined(HAVE_VSNPRINTF)
  57. vsnprintf(buf, get_width() - x + 1, format, args);
  58. #else
  59. vsprintf(buf, format, args);
  60. #endif
  61. buf[get_width() - x] = '\0';
  62. va_end(args);
  63. putstr(x, y, buf);
  64. }
  65. void Cucul::clear ()
  66. {
  67. cucul_clear(qq);
  68. }
  69. void Cucul::blit ( int x, int y, Cucul* c1, Cucul* c2)
  70. {
  71. cucul_blit(qq, x, y, c1->get_cucul_t(), c2->get_cucul_t());
  72. }
  73. void Cucul::invert ()
  74. {
  75. cucul_invert(qq);
  76. }
  77. void Cucul::flip ()
  78. {
  79. cucul_flip(qq);
  80. }
  81. void Cucul::flop ()
  82. {
  83. cucul_flop(qq);
  84. }
  85. void Cucul::rotate ()
  86. {
  87. cucul_rotate(qq);
  88. }
  89. void Cucul::draw_line (int x1 , int y1, int x2, int y2, char const *c)
  90. {
  91. cucul_draw_line(qq, x1,y1,x2,y2, c);
  92. }
  93. void Cucul::draw_polyline (int const x[], int const y[], int f, char const *c)
  94. {
  95. cucul_draw_polyline(qq, x, y, f, c);
  96. }
  97. void Cucul::draw_thin_line (int x1 , int y1, int x2, int y2)
  98. {
  99. cucul_draw_thin_line(qq, x1, y1, x2, y2);
  100. }
  101. void Cucul::draw_thin_polyline ( int const x[], int const y[], int f)
  102. {
  103. cucul_draw_thin_polyline(qq, x, y, f);
  104. }
  105. void Cucul::draw_circle ( int x, int y, int d, char const *c)
  106. {
  107. cucul_draw_circle(qq, x, y, d, c);
  108. }
  109. void Cucul::draw_ellipse ( int x, int y, int d1, int d2, char const *c)
  110. {
  111. cucul_draw_ellipse(qq, x, y, d1, d2, c);
  112. }
  113. void Cucul::draw_thin_ellipse ( int x, int y, int d1, int d2)
  114. {
  115. cucul_draw_thin_ellipse(qq, x, y, d1, d2);
  116. }
  117. void Cucul::fill_ellipse ( int x, int y, int d1, int d2, char const *c)
  118. {
  119. cucul_fill_ellipse(qq, x, y, d1, d2, c);
  120. }
  121. void Cucul::draw_box ( int x, int y, int w, int h, char const *c)
  122. {
  123. cucul_draw_box(qq, x, y, w, h, c);
  124. }
  125. void Cucul::draw_thin_box ( int x, int y, int w, int h)
  126. {
  127. cucul_draw_thin_box(qq, x, y, w, h);
  128. }
  129. void Cucul::fill_box ( int x, int y, int w, int h, char const *c)
  130. {
  131. cucul_fill_box(qq, x, y, w, h, c);
  132. }
  133. void Cucul::draw_triangle ( int x1, int y1, int x2, int y2, int x3, int y3, char const *c)
  134. {
  135. cucul_draw_triangle(qq, x1, y1, x2, y2, x3, y3, c);
  136. }
  137. void Cucul::draw_thin_triangle ( int x1, int y1, int x2, int y2, int x3, int y3)
  138. {
  139. cucul_draw_thin_triangle(qq, x1, y1, x2, y2, x3, y3);
  140. }
  141. void Cucul::fill_triangle ( int x1, int y1, int x2, int y2, int x3, int y3, const char *c)
  142. {
  143. cucul_fill_triangle(qq, x1, y1, x2, y2, x3, y3, c);
  144. }
  145. int Cucul::rand (int min, int max)
  146. {
  147. return cucul_rand(min, max);
  148. }
  149. unsigned int Cucul::sqrt (unsigned int v)
  150. {
  151. return cucul_sqrt(v);
  152. }
  153. Cucul::Sprite * Cucul::load_sprite (char const *f)
  154. {
  155. Cucul::Sprite *s = new Cucul::Sprite();
  156. s->sprite = cucul_load_sprite(f);
  157. return s;
  158. }
  159. int Cucul::get_sprite_frames (Cucul::Sprite const *s)
  160. {
  161. return cucul_get_sprite_frames(s->sprite);
  162. }
  163. int Cucul::get_sprite_width (Cucul::Sprite const *s, int v)
  164. {
  165. return cucul_get_sprite_width(s->sprite, v);
  166. }
  167. int Cucul::get_sprite_height (Cucul::Sprite const *s, int v)
  168. {
  169. return cucul_get_sprite_height(s->sprite, v);
  170. }
  171. int Cucul::get_sprite_dx (Cucul::Sprite const *s, int v)
  172. {
  173. return cucul_get_sprite_dx(s->sprite, v);
  174. }
  175. int Cucul::get_sprite_dy (Cucul::Sprite const *s, int v)
  176. {
  177. return cucul_get_sprite_dy(s->sprite, v);
  178. }
  179. void Cucul::draw_sprite ( int x, int y, Cucul::Sprite const *s, int v)
  180. {
  181. cucul_draw_sprite(qq, x, y, s->sprite, v);
  182. }
  183. void Cucul::free_sprite (Cucul::Sprite *s)
  184. {
  185. cucul_free_sprite(s->sprite);
  186. }
  187. 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)
  188. {
  189. Cucul::Dither *d = new Dither();
  190. d->dither = cucul_create_dither(v1,v2,v3,v4,v5,v6,v7,v8);
  191. return d;
  192. }
  193. void Cucul::set_dither_palette (Cucul::Dither *d, unsigned int r[], unsigned int g[], unsigned int b[], unsigned int a[])
  194. {
  195. cucul_set_dither_palette(d->dither, r, g, b, a);
  196. }
  197. void Cucul::set_dither_brightness (Cucul::Dither *d, float f)
  198. {
  199. cucul_set_dither_brightness(d->dither, f);
  200. }
  201. void Cucul::set_dither_gamma (Cucul::Dither *d, float f)
  202. {
  203. cucul_set_dither_gamma(d->dither, f);
  204. }
  205. void Cucul::set_dither_contrast ( Cucul::Dither *d, float f)
  206. {
  207. cucul_set_dither_contrast(d->dither, f);
  208. }
  209. void Cucul::set_dither_invert ( Cucul::Dither *d, int i)
  210. {
  211. cucul_set_dither_invert(d->dither, i);
  212. }
  213. void Cucul::set_dither_antialias ( Cucul::Dither *d, char const *c)
  214. {
  215. cucul_set_dither_antialias(d->dither, c);
  216. }
  217. char const *const * Cucul::get_dither_antialias_list ( Cucul::Dither const *d)
  218. {
  219. return cucul_get_dither_antialias_list(d->dither);
  220. }
  221. void Cucul::set_dither_color ( Cucul::Dither *d, char const *c)
  222. {
  223. cucul_set_dither_color(d->dither, c);
  224. }
  225. char const *const * Cucul::get_dither_color_list ( Cucul::Dither const *d)
  226. {
  227. return cucul_get_dither_color_list(d->dither);
  228. }
  229. void Cucul::set_dither_charset ( Cucul::Dither *d, char const *c)
  230. {
  231. cucul_set_dither_charset(d->dither, c);
  232. }
  233. char const *const * Cucul::get_dither_charset_list ( Cucul::Dither const *d)
  234. {
  235. return cucul_get_dither_charset_list(d->dither);
  236. }
  237. void Cucul::set_dither_mode ( Cucul::Dither *d, char const *c)
  238. {
  239. cucul_set_dither_mode(d->dither, c);
  240. }
  241. char const *const * Cucul::get_dither_mode_list ( Cucul::Dither const *d)
  242. {
  243. return cucul_get_dither_mode_list(d->dither);
  244. }
  245. void Cucul::dither_bitmap ( int x, int y, int w, int h, Cucul::Dither const *d, void *v)
  246. {
  247. cucul_dither_bitmap(qq, x, y, w, h, d->dither, v);
  248. }
  249. void Cucul::free_dither ( Cucul::Dither *d)
  250. {
  251. cucul_free_dither(d->dither);
  252. }
  253. Cucul::Font * Cucul::load_font (void const *s, unsigned int v)
  254. {
  255. Cucul::Font *f = new Cucul::Font();
  256. f->font = cucul_load_font(s, v);
  257. return f;
  258. }
  259. char const *const * Cucul::get_font_list (void)
  260. {
  261. return cucul_get_font_list();
  262. }
  263. unsigned int Cucul::get_font_width ( Cucul::Font *f)
  264. {
  265. return cucul_get_font_width(f->font);
  266. }
  267. unsigned int Cucul::get_font_height ( Cucul::Font *f)
  268. {
  269. return cucul_get_font_height(f->font);
  270. }
  271. void Cucul::render_canvas (Cucul::Font *f, unsigned char *c, unsigned int x, unsigned int y, unsigned int w)
  272. {
  273. cucul_render_canvas(qq, f->font, c, x,y,w);
  274. }
  275. void Cucul::free_font ( Cucul::Font *f)
  276. {
  277. cucul_free_font(f->font);
  278. }
  279. Cucul::Buffer * Cucul::create_export (char const *c)
  280. {
  281. Cucul::Buffer *b = new Cucul::Buffer();
  282. b->buffer = cucul_create_export(qq, c);
  283. return b;
  284. }
  285. char const *const * Cucul::get_export_list (void)
  286. {
  287. return cucul_get_export_list();
  288. }