[3192] | 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 | |
---|
[3293] | 15 | class Libcaca |
---|
| 16 | { |
---|
| 17 | static function Rand($min, $max) |
---|
| 18 | { |
---|
| 19 | return caca_rand($min, $max); |
---|
| 20 | } |
---|
| 21 | |
---|
| 22 | static function getVersion() |
---|
| 23 | { |
---|
| 24 | return caca_get_version(); |
---|
| 25 | } |
---|
| 26 | } |
---|
| 27 | |
---|
[3292] | 28 | class AnsiColor |
---|
| 29 | { |
---|
| 30 | const BLACK = CACA_BLACK; |
---|
| 31 | const BLUE = CACA_BLUE; |
---|
| 32 | const GREEN = CACA_GREEN; |
---|
| 33 | const CYAN = CACA_CYAN; |
---|
| 34 | const RED = CACA_RED; |
---|
| 35 | const MAGENTA = CACA_MAGENTA; |
---|
| 36 | const BROWN = CACA_BROWN; |
---|
| 37 | const LIGHTGRAY = CACA_LIGHTGRAY; |
---|
| 38 | const DARKGRAY = CACA_DARKGRAY; |
---|
| 39 | const LIGHTBLUE = CACA_LIGHTBLUE; |
---|
| 40 | const LIGHTGREEN = CACA_LIGHTGREEN; |
---|
| 41 | const LIGHTCYAN = CACA_LIGHTCYAN; |
---|
| 42 | const LIGHTRED = CACA_LIGHTRED; |
---|
| 43 | const LIGHTMAGENTA = CACA_LIGHTMAGENTA; |
---|
| 44 | const YELLOW = CACA_YELLOW; |
---|
| 45 | const WHITE = CACA_WHITE; |
---|
| 46 | /* NOTE: We can't call this one DEFAULT because that's a reserved |
---|
| 47 | * token in PHP. */ |
---|
| 48 | const DEFAULTCOLOR = CACA_DEFAULT; |
---|
| 49 | const TRANSPARENT = CACA_TRANSPARENT; |
---|
| 50 | } |
---|
[3192] | 51 | |
---|
| 52 | class Canvas { |
---|
[3195] | 53 | private $cv; |
---|
[3192] | 54 | |
---|
[3253] | 55 | function importFile($path, $codec) { |
---|
| 56 | return caca_import_file($this->cv, $path, $codec); |
---|
| 57 | } |
---|
| 58 | |
---|
[3294] | 59 | function importString($str, $codec) { |
---|
| 60 | return caca_import_string($this->cv, $str, $codec); |
---|
[3253] | 61 | } |
---|
| 62 | |
---|
| 63 | function exportString($codec) { |
---|
| 64 | return caca_export_string($this->cv, $codec); |
---|
| 65 | } |
---|
| 66 | |
---|
| 67 | function freeFrame($id) { |
---|
| 68 | return caca_free_frame($this->cv, $id); |
---|
| 69 | } |
---|
| 70 | |
---|
| 71 | function frameCount() { |
---|
| 72 | return caca_get_frame_count($this->cv); |
---|
| 73 | } |
---|
| 74 | |
---|
| 75 | function createFrame($id) { |
---|
| 76 | return caca_create_frame($this->cv, $id); |
---|
| 77 | } |
---|
| 78 | |
---|
| 79 | function setFrameName($name) { |
---|
| 80 | return caca_set_frame_name($this->cv, $name); |
---|
| 81 | } |
---|
| 82 | |
---|
| 83 | function setFrame($id) { |
---|
| 84 | return caca_set_frame($this->cv, $id); |
---|
| 85 | } |
---|
| 86 | |
---|
[3225] | 87 | function putFigchar($char) { |
---|
| 88 | return caca_put_figchar($this->cv, $char); |
---|
| 89 | } |
---|
| 90 | |
---|
| 91 | function setFigfont($path) { |
---|
| 92 | return caca_canvas_set_figfont($this->cv, $path); |
---|
| 93 | } |
---|
| 94 | |
---|
| 95 | function putAttr($attr) { |
---|
[3293] | 96 | return caca_put_attr($this->cv, $attr); |
---|
[3225] | 97 | } |
---|
| 98 | |
---|
| 99 | function stretchRight() { |
---|
[3293] | 100 | return caca_stretch_right($this->cv); |
---|
[3225] | 101 | } |
---|
| 102 | |
---|
| 103 | function stretchLeft() { |
---|
[3293] | 104 | return caca_stretch_left($this->cv); |
---|
[3225] | 105 | } |
---|
| 106 | |
---|
| 107 | function setBoundaries($width, $height) { |
---|
| 108 | return caca_set_canvas_boundaries($this->cv, $width, $height); |
---|
| 109 | } |
---|
| 110 | |
---|
| 111 | function setHandle($x, $y) { |
---|
| 112 | return caca_set_canvas_handle($this->cv, $x, $y); |
---|
| 113 | } |
---|
| 114 | |
---|
| 115 | function getHandleX() { |
---|
[3293] | 116 | return caca_get_canvas_handle_x($this->cv); |
---|
[3225] | 117 | } |
---|
| 118 | |
---|
| 119 | function getHandleY() { |
---|
[3293] | 120 | return caca_get_canvas_handle_y($this->cv); |
---|
[3225] | 121 | } |
---|
| 122 | |
---|
[3587] | 123 | function whereX() { |
---|
| 124 | return caca_wherex($this->cv); |
---|
[3225] | 125 | } |
---|
| 126 | |
---|
[3587] | 127 | function whereY() { |
---|
| 128 | return caca_wherey($this->cv); |
---|
[3225] | 129 | } |
---|
| 130 | |
---|
| 131 | function getChars() { |
---|
[3293] | 132 | return caca_get_canvas_chars($this->cv); |
---|
[3225] | 133 | } |
---|
| 134 | |
---|
| 135 | function getAttrs() { |
---|
[3293] | 136 | return caca_get_canvas_attrs($this->cv); |
---|
[3225] | 137 | } |
---|
| 138 | |
---|
[3192] | 139 | function setSize($width, $height) { |
---|
[3225] | 140 | return caca_set_canvas_size($this->cv, $width, $height); |
---|
[3192] | 141 | } |
---|
| 142 | |
---|
| 143 | function getWidth() { |
---|
| 144 | return caca_get_canvas_width($this->cv); |
---|
| 145 | } |
---|
| 146 | |
---|
| 147 | function getHeight() { |
---|
| 148 | return caca_get_canvas_height($this->cv); |
---|
| 149 | } |
---|
[3293] | 150 | |
---|
[3193] | 151 | function getAttr($x, $y) { |
---|
| 152 | return caca_get_attr($this->cv, $x, $y); |
---|
[3192] | 153 | } |
---|
| 154 | |
---|
[3193] | 155 | function setAttr($attr) { |
---|
| 156 | return caca_set_attr($this->cv, $x, $y, $attr); |
---|
[3192] | 157 | } |
---|
| 158 | |
---|
| 159 | function setColorANSI($foreground, $background) { |
---|
| 160 | return caca_set_color_ansi($this->cv, $foreground, $background); |
---|
| 161 | } |
---|
| 162 | |
---|
| 163 | function setColorARGB($foreground, $background) { |
---|
[3193] | 164 | return caca_set_color_argb($this->cv, $foreground, $background); |
---|
[3192] | 165 | } |
---|
| 166 | |
---|
| 167 | function putChar($x, $y, $c) { |
---|
| 168 | return caca_put_char($this->cv, $x, $y, $c); |
---|
| 169 | } |
---|
| 170 | |
---|
| 171 | function getChar($x, $y) { |
---|
| 172 | return caca_get_char($this->cv, $x, $y); |
---|
| 173 | } |
---|
| 174 | |
---|
| 175 | function putStr($x, $y, $str) { |
---|
| 176 | return caca_put_str($this->cv, $x, $y, $str); |
---|
| 177 | } |
---|
| 178 | |
---|
| 179 | function Clear() { |
---|
[3225] | 180 | return caca_clear_canvas($this->cv); |
---|
[3192] | 181 | } |
---|
| 182 | |
---|
[3294] | 183 | function Blit($x, $y, $canvas, $mask = NULL) { |
---|
| 184 | if($mask) |
---|
| 185 | return caca_blit($this->cv, $x, $y, $canvas->get_resource(), $mask->get_resource()); |
---|
| 186 | return caca_blit($this->cv, $x, $y, $canvas->get_resource()); |
---|
[3192] | 187 | } |
---|
| 188 | |
---|
| 189 | function Invert() { |
---|
| 190 | return caca_invert($this->cv); |
---|
| 191 | } |
---|
| 192 | |
---|
| 193 | function Flip() { |
---|
| 194 | return caca_flip($this->cv); |
---|
| 195 | } |
---|
| 196 | |
---|
| 197 | function Flop() { |
---|
| 198 | return caca_flop($this->cv); |
---|
| 199 | } |
---|
| 200 | |
---|
| 201 | function Rotate180() { |
---|
| 202 | return caca_rotate_180($this->cv); |
---|
| 203 | } |
---|
| 204 | |
---|
| 205 | function RotateLeft() { |
---|
| 206 | return caca_rotate_left($this->cv); |
---|
| 207 | } |
---|
| 208 | |
---|
| 209 | function RotateRight() { |
---|
| 210 | return caca_rotate_right($this->cv); |
---|
| 211 | } |
---|
| 212 | |
---|
[3193] | 213 | function drawLine($x1, $y1, $x2, $y2, $char) { |
---|
[3286] | 214 | return caca_draw_line($this->cv, $x1, $y1, $x2, $y2, $char); |
---|
[3192] | 215 | } |
---|
| 216 | |
---|
[3193] | 217 | function drawPolyline($points, $char) { |
---|
| 218 | return caca_draw_polyline($this->cv, $points, $char); |
---|
[3192] | 219 | } |
---|
| 220 | |
---|
[3193] | 221 | function drawThinLine($x1, $y1, $x2, $y2) { |
---|
| 222 | return caca_draw_thin_line($this->cv, $x1, $y1, $x2, $y2); |
---|
[3192] | 223 | } |
---|
| 224 | |
---|
[3193] | 225 | function drawThinPolyline($points) { |
---|
| 226 | return caca_draw_thin_polyline($this->cv, $points); |
---|
[3192] | 227 | } |
---|
| 228 | |
---|
[3193] | 229 | function drawCircle($x, $y, $radius, $char) { |
---|
| 230 | return caca_draw_circle($this->cv, $x, $y, $radius, $char); |
---|
[3192] | 231 | } |
---|
| 232 | |
---|
[3193] | 233 | function drawEllipse($x1, $y1, $x2, $y2, $char) { |
---|
[3293] | 234 | return caca_draw_ellipse($this->cv, $x1, $y1, $x2, $y2, $char); |
---|
[3192] | 235 | } |
---|
| 236 | |
---|
[3193] | 237 | function drawThinEllipse($x1, $y1, $x2, $y2) { |
---|
[3293] | 238 | return caca_draw_thin_ellipse($this->cv, $x1, $y1, $x2, $y2); |
---|
[3192] | 239 | } |
---|
| 240 | |
---|
[3193] | 241 | function fillEllipse($x1, $y1, $x2, $y2, $char) { |
---|
[3293] | 242 | return caca_fill_ellipse($this->cv, $x1, $y1, $x2, $y2, $char); |
---|
[3192] | 243 | } |
---|
| 244 | |
---|
[3193] | 245 | function drawBox($x1, $y1, $x2, $y2, $char) { |
---|
[3225] | 246 | return caca_draw_box($this->cv, $x1, $y1, $x2, $y2, $char); |
---|
[3192] | 247 | } |
---|
| 248 | |
---|
[3193] | 249 | function drawThinBox($x1, $y1, $x2, $y2) { |
---|
[3225] | 250 | return caca_draw_thin_box($this->cv, $x1, $y1, $x2, $y2); |
---|
[3192] | 251 | } |
---|
| 252 | |
---|
[3193] | 253 | function drawCP437Box($x1, $y1, $x2, $y2) { |
---|
[3225] | 254 | return caca_draw_cp437_box($this->cv, $x1, $y1, $x2, $y2); |
---|
[3192] | 255 | } |
---|
| 256 | |
---|
[3193] | 257 | function fillBox($x1, $y1, $x2, $y2, $char) { |
---|
[3225] | 258 | return caca_fill_box($this->cv, $x1, $y1, $x2, $y2, $char); |
---|
[3192] | 259 | } |
---|
| 260 | |
---|
[3193] | 261 | function drawTriangle($x1, $y1, $x2, $y2, $x3, $y3, $char) { |
---|
[3225] | 262 | return caca_draw_triangle($this->cv, $x1, $y1, $x2, $y2, $x3, $y3, $char); |
---|
[3192] | 263 | } |
---|
| 264 | |
---|
[3193] | 265 | function drawThinTriangle($x1, $y1, $x2, $y2, $x3, $y3) { |
---|
[3225] | 266 | return caca_draw_thin_triangle($this->cv, $x1, $y1, $x2, $y2, $x3, $y3); |
---|
[3192] | 267 | } |
---|
| 268 | |
---|
[3193] | 269 | function fillTriangle($x1, $y1, $x2, $y2, $x3, $y3, $char) { |
---|
[3225] | 270 | return caca_fill_triangle($this->cv, $x1, $y1, $x2, $y2, $x3, $y3, $char); |
---|
[3192] | 271 | } |
---|
| 272 | |
---|
| 273 | function __construct($width = 0, $height = 0) { |
---|
[3195] | 274 | $this->cv = caca_create_canvas($width, $height); |
---|
[3192] | 275 | } |
---|
[3293] | 276 | |
---|
[3193] | 277 | function get_resource() { |
---|
| 278 | return $this->cv; |
---|
| 279 | } |
---|
[3192] | 280 | } |
---|
[3195] | 281 | |
---|
[3292] | 282 | class EventType |
---|
| 283 | { |
---|
| 284 | const NONE = CACA_EVENT_NONE; |
---|
| 285 | |
---|
| 286 | const KEY_PRESS = CACA_EVENT_KEY_PRESS; |
---|
| 287 | const KEY_RELEASE = CACA_EVENT_KEY_RELEASE; |
---|
| 288 | const MOUSE_PRESS = CACA_EVENT_MOUSE_PRESS; |
---|
| 289 | const MOUSE_RELEASE = CACA_EVENT_MOUSE_RELEASE; |
---|
| 290 | const MOUSE_MOTION = CACA_EVENT_MOUSE_MOTION; |
---|
| 291 | const RESIZE = CACA_EVENT_RESIZE; |
---|
| 292 | const QUIT = CACA_EVENT_QUIT; |
---|
| 293 | |
---|
| 294 | const ANY = CACA_EVENT_ANY; |
---|
| 295 | } |
---|
[3293] | 296 | |
---|
[3292] | 297 | class EventKey |
---|
| 298 | { |
---|
| 299 | const UNKNOWN = CACA_KEY_UNKNOWN; |
---|
| 300 | |
---|
| 301 | const CTRL_A = CACA_KEY_CTRL_A; |
---|
| 302 | const CTRL_B = CACA_KEY_CTRL_B; |
---|
| 303 | const CTRL_C = CACA_KEY_CTRL_C; |
---|
| 304 | const CTRL_D = CACA_KEY_CTRL_D; |
---|
| 305 | const CTRL_E = CACA_KEY_CTRL_E; |
---|
| 306 | const CTRL_F = CACA_KEY_CTRL_F; |
---|
| 307 | const CTRL_G = CACA_KEY_CTRL_G; |
---|
| 308 | const BACKSPACE = CACA_KEY_BACKSPACE; |
---|
| 309 | const TAB = CACA_KEY_TAB; |
---|
| 310 | const CTRL_J = CACA_KEY_CTRL_J; |
---|
| 311 | const CTRL_K = CACA_KEY_CTRL_K; |
---|
| 312 | const CTRL_L = CACA_KEY_CTRL_L; |
---|
| 313 | /* NOTE: We can't call this one RETURN because that's a |
---|
| 314 | * reserved token in PHP */ |
---|
| 315 | const RETURN_KEY = CACA_KEY_RETURN; |
---|
| 316 | const CTRL_N = CACA_KEY_CTRL_N; |
---|
| 317 | const CTRL_O = CACA_KEY_CTRL_O; |
---|
| 318 | const CTRL_P = CACA_KEY_CTRL_P; |
---|
| 319 | const CTRL_Q = CACA_KEY_CTRL_Q; |
---|
| 320 | const CTRL_R = CACA_KEY_CTRL_R; |
---|
| 321 | const PAUSE = CACA_KEY_PAUSE; |
---|
| 322 | const CTRL_T = CACA_KEY_CTRL_T; |
---|
| 323 | const CTRL_U = CACA_KEY_CTRL_U; |
---|
| 324 | const CTRL_V = CACA_KEY_CTRL_V; |
---|
| 325 | const CTRL_W = CACA_KEY_CTRL_W; |
---|
| 326 | const CTRL_X = CACA_KEY_CTRL_X; |
---|
| 327 | const CTRL_Y = CACA_KEY_CTRL_Y; |
---|
| 328 | const CTRL_Z = CACA_KEY_CTRL_Z; |
---|
| 329 | const ESCAPE = CACA_KEY_ESCAPE; |
---|
| 330 | const DELETE = CACA_KEY_DELETE; |
---|
| 331 | |
---|
| 332 | const UP = CACA_KEY_UP; |
---|
| 333 | const DOWN = CACA_KEY_DOWN; |
---|
| 334 | const LEFT = CACA_KEY_LEFT; |
---|
| 335 | const RIGHT = CACA_KEY_RIGHT; |
---|
| 336 | |
---|
| 337 | const INSERT = CACA_KEY_INSERT; |
---|
| 338 | const HOME = CACA_KEY_HOME; |
---|
| 339 | const END = CACA_KEY_END; |
---|
| 340 | const PAGEUP = CACA_KEY_PAGEUP; |
---|
| 341 | const PAGEDOWN = CACA_KEY_PAGEDOWN; |
---|
| 342 | |
---|
| 343 | const F1 = CACA_KEY_F1; |
---|
| 344 | const F2 = CACA_KEY_F2; |
---|
| 345 | const F3 = CACA_KEY_F3; |
---|
| 346 | const F4 = CACA_KEY_F4; |
---|
| 347 | const F5 = CACA_KEY_F5; |
---|
| 348 | const F6 = CACA_KEY_F6; |
---|
| 349 | const F7 = CACA_KEY_F7; |
---|
| 350 | const F8 = CACA_KEY_F8; |
---|
| 351 | const F9 = CACA_KEY_F9; |
---|
| 352 | const F10 = CACA_KEY_F10; |
---|
| 353 | const F11 = CACA_KEY_F11; |
---|
| 354 | const F12 = CACA_KEY_F12; |
---|
| 355 | const F13 = CACA_KEY_F13; |
---|
| 356 | const F14 = CACA_KEY_F14; |
---|
| 357 | const F15 = CACA_KEY_F15; |
---|
| 358 | } |
---|
| 359 | |
---|
[3286] | 360 | class Event { |
---|
| 361 | private $ev; |
---|
| 362 | |
---|
| 363 | function getType() { |
---|
| 364 | return caca_get_event_type($this->ev); |
---|
| 365 | } |
---|
| 366 | |
---|
| 367 | function getKeyCh() { |
---|
| 368 | return caca_get_event_key_ch($this->ev); |
---|
| 369 | } |
---|
| 370 | |
---|
| 371 | function getMouseX() { |
---|
| 372 | return caca_get_event_mouse_x($this->ev); |
---|
| 373 | } |
---|
| 374 | |
---|
| 375 | function getResizeWidth() { |
---|
| 376 | return caca_get_event_resize_width($this->ev); |
---|
| 377 | } |
---|
| 378 | |
---|
| 379 | function getResizeHeight() { |
---|
| 380 | return caca_get_event_resize_height($this->ev); |
---|
| 381 | } |
---|
| 382 | |
---|
| 383 | function __construct($_ev) { |
---|
| 384 | $this->ev = $_ev; |
---|
| 385 | } |
---|
[3293] | 386 | |
---|
[3286] | 387 | function get_resource() { |
---|
| 388 | return $this->ev; |
---|
| 389 | } |
---|
| 390 | } |
---|
| 391 | |
---|
[3195] | 392 | class Display { |
---|
| 393 | private $dp; |
---|
| 394 | |
---|
[3253] | 395 | function setCursor($visible) { |
---|
| 396 | return caca_set_cursor($this->dp, $visible); |
---|
| 397 | } |
---|
| 398 | |
---|
[3225] | 399 | function refresh() { |
---|
| 400 | return caca_refresh_display($this->dp); |
---|
| 401 | } |
---|
| 402 | |
---|
| 403 | function getDriver() { |
---|
| 404 | return caca_get_display_driver($this->dp); |
---|
| 405 | } |
---|
| 406 | |
---|
| 407 | function setDriver($name) { |
---|
| 408 | return caca_set_display_driver($this->dp, $name); |
---|
| 409 | } |
---|
| 410 | |
---|
[3195] | 411 | function setDisplayTime($time) { |
---|
| 412 | return caca_set_display_time($this->dp, $time); |
---|
| 413 | } |
---|
| 414 | |
---|
| 415 | function getDisplayTime() { |
---|
| 416 | return caca_get_display_time($this->dp); |
---|
| 417 | } |
---|
| 418 | |
---|
| 419 | function getWidth() { |
---|
| 420 | return caca_get_display_width($this->dp); |
---|
| 421 | } |
---|
| 422 | |
---|
| 423 | function getHeight() { |
---|
| 424 | return caca_get_display_height($this->dp); |
---|
| 425 | } |
---|
| 426 | |
---|
| 427 | function setTitle($title) { |
---|
| 428 | return caca_set_display_title($this->dp, $title); |
---|
| 429 | } |
---|
| 430 | |
---|
[3225] | 431 | function gotoXY($x, $y) { |
---|
| 432 | return caca_gotoxy($this->dp, $x, $y); |
---|
| 433 | } |
---|
| 434 | |
---|
[3195] | 435 | function getMouseX() { |
---|
| 436 | return caca_get_mouse_x($this->dp); |
---|
| 437 | } |
---|
| 438 | |
---|
| 439 | function getMouseY() { |
---|
| 440 | return caca_get_mouse_y($this->dp); |
---|
| 441 | } |
---|
| 442 | |
---|
| 443 | function setMouse($state) { |
---|
| 444 | return caca_set_mouse($this->dp, $state); |
---|
| 445 | } |
---|
| 446 | |
---|
[3295] | 447 | function getEvent($t, $timeout = 0) { |
---|
[3286] | 448 | $ev = caca_get_event($this->dp, $t, $timeout); |
---|
| 449 | if(! $ev) { |
---|
| 450 | return NULL; |
---|
| 451 | } |
---|
| 452 | return new Event($ev); |
---|
| 453 | } |
---|
| 454 | |
---|
[3294] | 455 | function __construct($canvas, $driver = NULL) { |
---|
| 456 | if($driver) |
---|
[3225] | 457 | $this->dp = caca_create_display_with_driver($canvas->get_resource(), $driver); |
---|
| 458 | else |
---|
| 459 | $this->dp = caca_create_display($canvas->get_resource()); |
---|
[3293] | 460 | } |
---|
[3195] | 461 | |
---|
| 462 | function get_resource() { |
---|
| 463 | return $this->dp; |
---|
| 464 | } |
---|
| 465 | } |
---|
[3216] | 466 | |
---|
| 467 | class Dither { |
---|
| 468 | private $dt; |
---|
| 469 | private $img; |
---|
| 470 | |
---|
| 471 | function setPalette($colors) { |
---|
[3217] | 472 | return caca_set_dither_palette($this->dt, $colors); |
---|
[3216] | 473 | } |
---|
| 474 | |
---|
| 475 | function setBrightness($value) { |
---|
[3217] | 476 | return caca_set_dither_brightness($this->dt, $value); |
---|
[3216] | 477 | } |
---|
| 478 | |
---|
| 479 | function getBrightness() { |
---|
[3217] | 480 | return caca_get_dither_brightness($this->dt); |
---|
[3216] | 481 | } |
---|
[3293] | 482 | |
---|
[3216] | 483 | function setGamme($value) { |
---|
[3217] | 484 | return caca_set_dither_gamma($this->dt, $value); |
---|
[3216] | 485 | } |
---|
[3293] | 486 | |
---|
[3216] | 487 | function getGamma() { |
---|
[3217] | 488 | return caca_get_dither_gamma($this->dt); |
---|
[3216] | 489 | } |
---|
[3293] | 490 | |
---|
[3216] | 491 | function setContrast($value) { |
---|
[3217] | 492 | return caca_set_dither_contrast($this->dt, $value); |
---|
[3216] | 493 | } |
---|
[3293] | 494 | |
---|
[3216] | 495 | function getContrast() { |
---|
[3217] | 496 | return caca_get_dither_contrast($this->dt); |
---|
[3216] | 497 | } |
---|
[3293] | 498 | |
---|
[3216] | 499 | function setAntialias($value) { |
---|
[3217] | 500 | return caca_set_dither_antialias($this->dt, $value); |
---|
[3216] | 501 | } |
---|
[3293] | 502 | |
---|
[3216] | 503 | function getAntialiasList() { |
---|
[3217] | 504 | return caca_get_dither_antialias_list($this->dt); |
---|
[3216] | 505 | } |
---|
[3293] | 506 | |
---|
[3216] | 507 | function getAntialias() { |
---|
[3217] | 508 | return caca_get_dither_antialias($this->dt); |
---|
[3216] | 509 | } |
---|
[3293] | 510 | |
---|
[3216] | 511 | function setColor($color) { |
---|
[3217] | 512 | return caca_set_dither_color($this->dt, $color); |
---|
[3216] | 513 | } |
---|
[3293] | 514 | |
---|
[3216] | 515 | function getColorList() { |
---|
[3217] | 516 | return caca_get_dither_color_list($this->dt); |
---|
[3216] | 517 | } |
---|
[3293] | 518 | |
---|
[3216] | 519 | function getColor() { |
---|
[3217] | 520 | return caca_get_dither_color($this->dt); |
---|
[3216] | 521 | } |
---|
[3293] | 522 | |
---|
[3216] | 523 | function setCharset($value) { |
---|
[3217] | 524 | return caca_set_dither_charset($this->dt, $value); |
---|
[3216] | 525 | } |
---|
[3293] | 526 | |
---|
[3216] | 527 | function getCharsetList() { |
---|
[3217] | 528 | return caca_get_dither_charset_list($this->dt); |
---|
[3216] | 529 | } |
---|
[3293] | 530 | |
---|
[3216] | 531 | function getCharset() { |
---|
[3217] | 532 | return caca_get_dither_charset($this->dt); |
---|
[3216] | 533 | } |
---|
[3293] | 534 | |
---|
[3216] | 535 | function setAlgorithm($name) { |
---|
[3217] | 536 | return caca_set_dither_algorithm($this->dt, $name); |
---|
[3216] | 537 | } |
---|
[3293] | 538 | |
---|
[3216] | 539 | function getAlgorithmList() { |
---|
[3217] | 540 | return caca_get_dither_algorithm_list($this->dt); |
---|
[3216] | 541 | } |
---|
[3293] | 542 | |
---|
[3216] | 543 | function getAlgorithm() { |
---|
[3217] | 544 | return caca_get_dither_algorithm($this->dt); |
---|
[3216] | 545 | } |
---|
[3293] | 546 | |
---|
[3216] | 547 | function bitmap($canvas, $x, $y, $width, $height, $load_palette = true) { |
---|
[3286] | 548 | return caca_dither_bitmap($canvas->get_resource(), $x, $y, $width, $height, $this->dt, $this->img, $load_palette); |
---|
[3216] | 549 | } |
---|
| 550 | |
---|
| 551 | function __construct($image) { |
---|
| 552 | $this->dt = caca_create_dither($image); |
---|
| 553 | $this->img = $image; |
---|
[3293] | 554 | } |
---|
[3216] | 555 | } |
---|
[3253] | 556 | |
---|
| 557 | class Font { |
---|
| 558 | private $f; |
---|
[3293] | 559 | |
---|
[3253] | 560 | function getWidth() { |
---|
| 561 | return caca_get_font_width($this->f); |
---|
| 562 | } |
---|
| 563 | |
---|
| 564 | function getHeight() { |
---|
| 565 | return caca_get_font_height($this->f); |
---|
| 566 | } |
---|
| 567 | |
---|
| 568 | function getBlocks() { |
---|
| 569 | return caca_get_font_blocks($this->f); |
---|
| 570 | } |
---|
| 571 | |
---|
[3286] | 572 | function Render($cv, $image) { |
---|
| 573 | return caca_render_canvas($cv->get_resource(), $this->f, $image); |
---|
| 574 | } |
---|
| 575 | |
---|
| 576 | static function getList() { |
---|
| 577 | return caca_get_font_list(); |
---|
| 578 | } |
---|
| 579 | |
---|
[3253] | 580 | function __construct($name) { |
---|
| 581 | $this->f = caca_load_builtin_font($name); |
---|
[3293] | 582 | } |
---|
[3253] | 583 | } |
---|