Ignore:
Timestamp:
Oct 26, 2008, 2:38:47 PM (11 years ago)
Author:
nico
Message:
  • Add php binding for 4 new functions
  • Add "full" demo to "examples/demo.php"
File:
1 edited

Legend:

Unmodified
Added
Removed
  • libcaca/trunk/caca-php/php_caca.c

    r3108 r3109  
    627627
    628628PHP_FUNCTION(caca_draw_circle) {
     629        zval *_zval;
     630        char *str;
     631        long str_len, x, y, r = 0;
     632        if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "rllls", &_zval, &x, &y, &r, &str, &str_len) == FAILURE) {
     633                RETURN_FALSE;
     634        }
     635        caca_canvas_t *canvas;
     636        ZEND_FETCH_RESOURCE(canvas, caca_canvas_t*, &_zval, -1, PHP_CACA_CANVAS_RES_NAME, le_caca_canvas);
     637        if (str_len != 1) {
     638                RETURN_FALSE;
     639        }
     640        RETURN_BOOL(caca_draw_circle(canvas, x, y, r, str[0]) == 0);
    629641}
    630642
     
    723735
    724736PHP_FUNCTION(caca_draw_triangle) {
     737        zval *_zval;
     738        char *str;
     739        long str_len, xa, ya, xb, yb, xc, yc = 0;
     740        if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "rlllllls", &_zval, &xa, &ya, &xb, &yb, &xc, &yc, &str, &str_len) == FAILURE) {
     741                RETURN_FALSE;
     742        }
     743        caca_canvas_t *canvas;
     744        ZEND_FETCH_RESOURCE(canvas, caca_canvas_t*, &_zval, -1, PHP_CACA_CANVAS_RES_NAME, le_caca_canvas);
     745        if (str_len != 1) {
     746                RETURN_FALSE;
     747        }
     748        RETURN_BOOL(caca_draw_triangle(canvas, xa, ya, xb, yb, xc, yc, str[0]) == 0);
    725749}
    726750
    727751PHP_FUNCTION(caca_draw_thin_triangle) {
     752        zval *_zval;
     753        long xa, ya, xb, yb, xc, yc = 0;
     754        if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "rllllll", &_zval, &xa, &ya, &xb, &yb, &xc, &yc) == FAILURE) {
     755                RETURN_FALSE;
     756        }
     757        caca_canvas_t *canvas;
     758        ZEND_FETCH_RESOURCE(canvas, caca_canvas_t*, &_zval, -1, PHP_CACA_CANVAS_RES_NAME, le_caca_canvas);
     759        RETURN_BOOL(caca_draw_thin_triangle(canvas, xa, ya, xb, yb, xc, yc) == 0);
    728760}
    729761
    730762PHP_FUNCTION(caca_fill_triangle) {
     763        zval *_zval;
     764        char *str;
     765        long str_len, xa, ya, xb, yb, xc, yc = 0;
     766        if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "rlllllls", &_zval, &xa, &ya, &xb, &yb, &xc, &yc, &str, &str_len) == FAILURE) {
     767                RETURN_FALSE;
     768        }
     769        caca_canvas_t *canvas;
     770        ZEND_FETCH_RESOURCE(canvas, caca_canvas_t*, &_zval, -1, PHP_CACA_CANVAS_RES_NAME, le_caca_canvas);
     771        if (str_len != 1) {
     772                RETURN_FALSE;
     773        }
     774        RETURN_BOOL(caca_fill_triangle(canvas, xa, ya, xb, yb, xc, yc, str[0]) == 0);
    731775}
    732776
Note: See TracChangeset for help on using the changeset viewer.