Вы не можете выбрать более 25 тем Темы должны начинаться с буквы или цифры, могут содержать дефисы(-) и должны содержать не более 35 символов.

16 лет назад
16 лет назад
16 лет назад
16 лет назад
16 лет назад
16 лет назад
16 лет назад
16 лет назад
16 лет назад
16 лет назад
16 лет назад
16 лет назад
16 лет назад
16 лет назад
16 лет назад
16 лет назад
16 лет назад
16 лет назад
16 лет назад
16 лет назад
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367
  1. <?php
  2. /*
  3. * php-caca Php binding for Libcaca
  4. * caca.php object layer for caca-php
  5. * Copyright (c) 2008 Vion Nicolas <nico@picapo.net>
  6. *
  7. *
  8. * This library is free software. It comes without any warranty, to
  9. * the extent permitted by applicable law. You can redistribute it
  10. * and/or modify it under the terms of the Do What The Fuck You Want
  11. * To Public License, Version 2, as published by Sam Hocevar. See
  12. * http://sam.zoy.org/wtfpl/COPYING for more details.
  13. */
  14. class Canvas {
  15. private $cv;
  16. function putFigchar($char) {
  17. return caca_put_figchar($this->cv, $char);
  18. }
  19. function setFigfont($path) {
  20. return caca_canvas_set_figfont($this->cv, $path);
  21. }
  22. function getFrameCount() {
  23. return caca_get_frame_count($this->cv);
  24. }
  25. function putAttr($attr) {
  26. return caca_put_attr($this->cv, $attr);
  27. }
  28. function stretchRight() {
  29. return caca_stretch_right($this->cv);
  30. }
  31. function stretchLeft() {
  32. return caca_stretch_left($this->cv);
  33. }
  34. function setBoundaries($width, $height) {
  35. return caca_set_canvas_boundaries($this->cv, $width, $height);
  36. }
  37. function setHandle($x, $y) {
  38. return caca_set_canvas_handle($this->cv, $x, $y);
  39. }
  40. function getHandleX() {
  41. return caca_get_canvas_handle_x($this->cv);
  42. }
  43. function getHandleY() {
  44. return caca_get_canvas_handle_y($this->cv);
  45. }
  46. function getCursorX() {
  47. return caca_get_cursor_x($this->cv);
  48. }
  49. function getCursorY() {
  50. return caca_get_cursor_y($this->cv);
  51. }
  52. function getChars() {
  53. return caca_get_canvas_chars($this->cv);
  54. }
  55. function getAttrs() {
  56. return caca_get_canvas_attrs($this->cv);
  57. }
  58. function setSize($width, $height) {
  59. return caca_set_canvas_size($this->cv, $width, $height);
  60. }
  61. function getWidth() {
  62. return caca_get_canvas_width($this->cv);
  63. }
  64. function getHeight() {
  65. return caca_get_canvas_height($this->cv);
  66. }
  67. function getAttr($x, $y) {
  68. return caca_get_attr($this->cv, $x, $y);
  69. }
  70. function setAttr($attr) {
  71. return caca_set_attr($this->cv, $x, $y, $attr);
  72. }
  73. function setColorANSI($foreground, $background) {
  74. return caca_set_color_ansi($this->cv, $foreground, $background);
  75. }
  76. function setColorARGB($foreground, $background) {
  77. return caca_set_color_argb($this->cv, $foreground, $background);
  78. }
  79. function putChar($x, $y, $c) {
  80. return caca_put_char($this->cv, $x, $y, $c);
  81. }
  82. function getChar($x, $y) {
  83. return caca_get_char($this->cv, $x, $y);
  84. }
  85. function putStr($x, $y, $str) {
  86. return caca_put_str($this->cv, $x, $y, $str);
  87. }
  88. function Clear() {
  89. return caca_clear_canvas($this->cv);
  90. }
  91. function Blit($x, $y, $canvas, $mask = false) {
  92. return caca_blit($this->cv, $x, $y, $canvas->get_resource(), ($mask != false) ? $mask->get_resource() : false );
  93. }
  94. function Invert() {
  95. return caca_invert($this->cv);
  96. }
  97. function Flip() {
  98. return caca_flip($this->cv);
  99. }
  100. function Flop() {
  101. return caca_flop($this->cv);
  102. }
  103. function Rotate180() {
  104. return caca_rotate_180($this->cv);
  105. }
  106. function RotateLeft() {
  107. return caca_rotate_left($this->cv);
  108. }
  109. function RotateRight() {
  110. return caca_rotate_right($this->cv);
  111. }
  112. function drawLine($x1, $y1, $x2, $y2, $char) {
  113. return caca_draw_line($this->cv, $x1, $y1, $x2, $y2, $color);
  114. }
  115. function drawPolyline($points, $char) {
  116. return caca_draw_polyline($this->cv, $points, $char);
  117. }
  118. function drawThinLine($x1, $y1, $x2, $y2) {
  119. return caca_draw_thin_line($this->cv, $x1, $y1, $x2, $y2);
  120. }
  121. function drawThinPolyline($points) {
  122. return caca_draw_thin_polyline($this->cv, $points);
  123. }
  124. function drawCircle($x, $y, $radius, $char) {
  125. return caca_draw_circle($this->cv, $x, $y, $radius, $char);
  126. }
  127. function drawEllipse($x1, $y1, $x2, $y2, $char) {
  128. return caca_draw_ellipse($this->cv, $x1, $y1, $x2, $y2, $char);
  129. }
  130. function drawThinEllipse($x1, $y1, $x2, $y2) {
  131. return caca_draw_thin_ellipse($this->cv, $x1, $y1, $x2, $y2);
  132. }
  133. function fillEllipse($x1, $y1, $x2, $y2, $char) {
  134. return caca_fill_ellipse($this->cv, $x1, $y1, $x2, $y2, $char);
  135. }
  136. function drawBox($x1, $y1, $x2, $y2, $char) {
  137. return caca_draw_box($this->cv, $x1, $y1, $x2, $y2, $char);
  138. }
  139. function drawThinBox($x1, $y1, $x2, $y2) {
  140. return caca_draw_thin_box($this->cv, $x1, $y1, $x2, $y2);
  141. }
  142. function drawCP437Box($x1, $y1, $x2, $y2) {
  143. return caca_draw_cp437_box($this->cv, $x1, $y1, $x2, $y2);
  144. }
  145. function fillBox($x1, $y1, $x2, $y2, $char) {
  146. return caca_fill_box($this->cv, $x1, $y1, $x2, $y2, $char);
  147. }
  148. function drawTriangle($x1, $y1, $x2, $y2, $x3, $y3, $char) {
  149. return caca_draw_triangle($this->cv, $x1, $y1, $x2, $y2, $x3, $y3, $char);
  150. }
  151. function drawThinTriangle($x1, $y1, $x2, $y2, $x3, $y3) {
  152. return caca_draw_thin_triangle($this->cv, $x1, $y1, $x2, $y2, $x3, $y3);
  153. }
  154. function fillTriangle($x1, $y1, $x2, $y2, $x3, $y3, $char) {
  155. return caca_fill_triangle($this->cv, $x1, $y1, $x2, $y2, $x3, $y3, $char);
  156. }
  157. function __construct($width = 0, $height = 0) {
  158. $this->cv = caca_create_canvas($width, $height);
  159. }
  160. function get_resource() {
  161. return $this->cv;
  162. }
  163. }
  164. class Display {
  165. private $dp;
  166. function refresh() {
  167. return caca_refresh_display($this->dp);
  168. }
  169. function getDriver() {
  170. return caca_get_display_driver($this->dp);
  171. }
  172. function setDriver($name) {
  173. return caca_set_display_driver($this->dp, $name);
  174. }
  175. function setDisplayTime($time) {
  176. return caca_set_display_time($this->dp, $time);
  177. }
  178. function getDisplayTime() {
  179. return caca_get_display_time($this->dp);
  180. }
  181. function getWidth() {
  182. return caca_get_display_width($this->dp);
  183. }
  184. function getHeight() {
  185. return caca_get_display_height($this->dp);
  186. }
  187. function setTitle($title) {
  188. return caca_set_display_title($this->dp, $title);
  189. }
  190. function gotoXY($x, $y) {
  191. return caca_gotoxy($this->dp, $x, $y);
  192. }
  193. function getMouseX() {
  194. return caca_get_mouse_x($this->dp);
  195. }
  196. function getMouseY() {
  197. return caca_get_mouse_y($this->dp);
  198. }
  199. function setMouse($state) {
  200. return caca_set_mouse($this->dp, $state);
  201. }
  202. function __construct($canvas, $driver = false) {
  203. if ($driver)
  204. $this->dp = caca_create_display_with_driver($canvas->get_resource(), $driver);
  205. else
  206. $this->dp = caca_create_display($canvas->get_resource());
  207. }
  208. function get_resource() {
  209. return $this->dp;
  210. }
  211. }
  212. class Dither {
  213. private $dt;
  214. private $img;
  215. function setPalette($colors) {
  216. return caca_set_dither_palette($this->dt, $colors);
  217. }
  218. function setBrightness($value) {
  219. return caca_set_dither_brightness($this->dt, $value);
  220. }
  221. function getBrightness() {
  222. return caca_get_dither_brightness($this->dt);
  223. }
  224. function setGamme($value) {
  225. return caca_set_dither_gamma($this->dt, $value);
  226. }
  227. function getGamma() {
  228. return caca_get_dither_gamma($this->dt);
  229. }
  230. function setContrast($value) {
  231. return caca_set_dither_contrast($this->dt, $value);
  232. }
  233. function getContrast() {
  234. return caca_get_dither_contrast($this->dt);
  235. }
  236. function setAntialias($value) {
  237. return caca_set_dither_antialias($this->dt, $value);
  238. }
  239. function getAntialiasList() {
  240. return caca_get_dither_antialias_list($this->dt);
  241. }
  242. function getAntialias() {
  243. return caca_get_dither_antialias($this->dt);
  244. }
  245. function setColor($color) {
  246. return caca_set_dither_color($this->dt, $color);
  247. }
  248. function getColorList() {
  249. return caca_get_dither_color_list($this->dt);
  250. }
  251. function getColor() {
  252. return caca_get_dither_color($this->dt);
  253. }
  254. function setCharset($value) {
  255. return caca_set_dither_charset($this->dt, $value);
  256. }
  257. function getCharsetList() {
  258. return caca_get_dither_charset_list($this->dt);
  259. }
  260. function getCharset() {
  261. return caca_get_dither_charset($this->dt);
  262. }
  263. function setAlgorithm($name) {
  264. return caca_set_dither_algorithm($this->dt, $name);
  265. }
  266. function getAlgorithmList() {
  267. return caca_get_dither_algorithm_list($this->dt);
  268. }
  269. function getAlgorithm() {
  270. return caca_get_dither_algorithm($this->dt);
  271. }
  272. function bitmap($canvas, $x, $y, $width, $height, $load_palette = true) {
  273. return caca_dither_bitmap($canvas, $x, $y, $width, $height, $this->dt, $this->img, $load_palette);
  274. }
  275. function __construct($image) {
  276. $this->dt = caca_create_dither($image);
  277. $this->img = $image;
  278. }
  279. }