Sfoglia il codice sorgente

fix type in Canvas::drawLine; add a minimal class Event providing a

subset of the functionality of the .NET version; added Display::getEvent
similar to the .NET version; change Dither::bitmap to take a Canvas
object rather than a caca canvas resource as its first parameter; add
Font::Render and Font::getList methods parallel to the .NET version
tags/v0.99.beta17
Ben Wiley Sittler bsittler 16 anni fa
parent
commit
eb7b2bdda7
1 ha cambiato i file con 50 aggiunte e 2 eliminazioni
  1. +50
    -2
      caca-php/caca.php

+ 50
- 2
caca-php/caca.php Vedi File

@@ -173,7 +173,7 @@ class Canvas {
}

function drawLine($x1, $y1, $x2, $y2, $char) {
return caca_draw_line($this->cv, $x1, $y1, $x2, $y2, $color);
return caca_draw_line($this->cv, $x1, $y1, $x2, $y2, $char);
}

function drawPolyline($points, $char) {
@@ -241,6 +241,38 @@ class Canvas {
}
}

class Event {
private $ev;

function getType() {
return caca_get_event_type($this->ev);
}

function getKeyCh() {
return caca_get_event_key_ch($this->ev);
}

function getMouseX() {
return caca_get_event_mouse_x($this->ev);
}

function getResizeWidth() {
return caca_get_event_resize_width($this->ev);
}

function getResizeHeight() {
return caca_get_event_resize_height($this->ev);
}

function __construct($_ev) {
$this->ev = $_ev;
}
function get_resource() {
return $this->ev;
}
}

class Display {
private $dp;

@@ -296,6 +328,14 @@ class Display {
return caca_set_mouse($this->dp, $state);
}

function getEvent($t, $timeout) {
$ev = caca_get_event($this->dp, $t, $timeout);
if(! $ev) {
return NULL;
}
return new Event($ev);
}

function __construct($canvas, $driver = false) {
if ($driver)
$this->dp = caca_create_display_with_driver($canvas->get_resource(), $driver);
@@ -389,7 +429,7 @@ class Dither {
}
function bitmap($canvas, $x, $y, $width, $height, $load_palette = true) {
return caca_dither_bitmap($canvas, $x, $y, $width, $height, $this->dt, $this->img, $load_palette);
return caca_dither_bitmap($canvas->get_resource(), $x, $y, $width, $height, $this->dt, $this->img, $load_palette);
}

function __construct($image) {
@@ -413,6 +453,14 @@ class Font {
return caca_get_font_blocks($this->f);
}

function Render($cv, $image) {
return caca_render_canvas($cv->get_resource(), $this->f, $image);
}

static function getList() {
return caca_get_font_list();
}

function __construct($name) {
$this->f = caca_load_builtin_font($name);
}


Caricamento…
Annulla
Salva