Updating checkpoint ...
[phpCairo.git] / src / cairo / CairoContext.c
blob015042cc79b49579ab2020210260b7247179e11f
1 /* {{{ Class CairoContext */
3 PHP_CAIRO_API static zend_class_entry * CairoContext_ce_ptr = NULL;
5 /* {{{ Methods */
8 /* {{{ proto void construct(object obj)
9 */
10 PHP_METHOD(CairoContext, __construct)
12 zval * _this_zval;
14 zval * obj = NULL;
16 if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|o", &obj) == FAILURE) {
17 return;
20 _this_zval = getThis();
21 cairo_surface_t *surface;
23 surface_object *sobj = (surface_object *)zend_object_store_get_object(obj TSRMLS_CC);
25 surface = sobj->surface;
26 context_object *context=(context_object *)zend_objects_get_address(_this_zval TSRMLS_CC);
27 context->context=cairo_create(surface);
29 /* }}} __construct */
33 /* {{{ proto void appendPath(object p)
35 PHP_METHOD(CairoContext, appendPath)
37 zval * _this_zval = NULL;
38 zval * p = NULL;
42 if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "Oo", &_this_zval, CairoContext_ce_ptr, &p) == FAILURE) {
43 return;
46 context_object *curr = (context_object *)zend_objects_get_address(_this_zval TSRMLS_CC);
47 path_object *pobj=(path_object *)zend_objects_get_address(p TSRMLS_CC);
48 cairo_append_path(curr->context,pobj->path);
49 PHP_CAIRO_CONTEXT_ERROR(curr->context)
52 /* }}} appendPath */
56 /* {{{ proto void arc(float xc, float yc, float radius, float angle1, float angle2)
58 PHP_METHOD(CairoContext, arc)
61 zval * _this_zval = NULL;
62 double xc = 0.0;
63 double yc = 0.0;
64 double radius = 0.0;
65 double angle1 = 0.0;
66 double angle2 = 0.0;
70 if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "Oddddd", &_this_zval, CairoContext_ce_ptr, &xc, &yc, &radius, &angle1, &angle2) == FAILURE) {
71 return;
74 context_object *curr=(context_object *)zend_objects_get_address(_this_zval TSRMLS_CC);
75 cairo_arc(curr->context,xc,yc,radius,angle1,angle2);
76 PHP_CAIRO_CONTEXT_ERROR(curr->context)
79 /* }}} arc */
83 /* {{{ proto void arcNegative(float xc, float yc, float radius, float angle1, float angle2)
85 PHP_METHOD(CairoContext, arcNegative)
88 zval * _this_zval = NULL;
89 double xc = 0.0;
90 double yc = 0.0;
91 double radius = 0.0;
92 double angle1 = 0.0;
93 double angle2 = 0.0;
97 if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "Oddddd", &_this_zval, CairoContext_ce_ptr, &xc, &yc, &radius, &angle1, &angle2) == FAILURE) {
98 return;
102 context_object *curr = (context_object *)zend_objects_get_address(_this_zval TSRMLS_CC);
105 cairo_arc_negative(curr->context, xc, yc, radius, angle1, angle2);
106 PHP_CAIRO_CONTEXT_ERROR(curr->context)
110 /* }}} arcNegative */
114 /* {{{ proto void clip()
116 PHP_METHOD(CairoContext, clip)
119 zval * _this_zval = NULL;
123 if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "O", &_this_zval, CairoContext_ce_ptr) == FAILURE) {
124 return;
127 context_object *curr=(context_object *)zend_objects_get_address(_this_zval TSRMLS_CC);
128 cairo_clip(curr->context);
129 PHP_CAIRO_CONTEXT_ERROR(curr->context)
131 /* }}} clip */
135 /* {{{ proto array clipExtents()
137 PHP_METHOD(CairoContext, clipExtents)
140 zval * _this_zval = NULL;
142 double x1, y1, x2, y2;
144 if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "O", &_this_zval, CairoContext_ce_ptr) == FAILURE) {
145 return;
148 context_object *curr=(context_object *)zend_objects_get_address(_this_zval TSRMLS_CC);
150 cairo_clip_extents(curr->context, &x1, &y1, &x2, &y2);
151 PHP_CAIRO_CONTEXT_ERROR(curr->context)
152 array_init(return_value);
153 add_next_index_double(return_value, x1);
154 add_next_index_double(return_value, y1);
155 add_next_index_double(return_value, x2);
156 add_next_index_double(return_value, y2);
159 /* }}} clipExtents */
163 /* {{{ proto void clipPreserve()
165 PHP_METHOD(CairoContext, clipPreserve)
168 zval * _this_zval = NULL;
172 if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "O", &_this_zval, CairoContext_ce_ptr) == FAILURE) {
173 return;
177 context_object *curr=(context_object *)zend_objects_get_address(_this_zval TSRMLS_CC);
179 cairo_clip_preserve(curr->context);
180 PHP_CAIRO_CONTEXT_ERROR(curr->context)
182 /* }}} clipPreserve */
186 /* {{{ proto void closePath()
188 PHP_METHOD(CairoContext, closePath)
191 zval * _this_zval = NULL;
195 if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "O", &_this_zval, CairoContext_ce_ptr) == FAILURE) {
196 return;
199 context_object *curr=(context_object *)zend_objects_get_address(_this_zval TSRMLS_CC);
201 cairo_close_path(curr->context);
202 PHP_CAIRO_CONTEXT_ERROR(curr->context)
205 /* }}} closePath */
209 /* {{{ proto object copyClipRectangleList()
211 PHP_METHOD(CairoContext, copyClipRectangleList)
214 zval * _this_zval = NULL;
215 cairo_rectangle_t *r;
216 cairo_rectangle_list_t *rlist;
217 zval *arr;
218 zval *temp_arr;
219 int i;
221 if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "O", &_this_zval, CairoContext_ce_ptr) == FAILURE) {
222 return;
224 context_object *curr=(context_object *)zend_objects_get_address(_this_zval TSRMLS_CC);
225 rlist = cairo_copy_clip_rectangle_list(curr->context);
226 PHP_CAIRO_ERROR(rlist->status)
228 array_init(return_value);
229 ALLOC_INIT_ZVAL(temp_arr);
230 array_init(temp_arr);
232 for(i = 0, r = rlist->rectangles; i < rlist->num_rectangles; i++, r++) {
233 //ALLOC_INIT_ZVAL(temp_arr);
234 //array_init(temp_arr);
235 add_assoc_double(temp_arr,"x",r->x);
236 add_assoc_double(temp_arr,"y",r->y);
237 add_assoc_double(temp_arr,"width",r->width);
238 add_assoc_double(temp_arr,"height",r->height);
239 add_next_index_zval(return_value,temp_arr);
240 // zval_ptr_dtor(temp_arr);
244 cairo_rectangle_list_destroy(rlist);
248 /* }}} copyClipRectangleList */
252 /* {{{ proto void copyPage()
254 PHP_METHOD(CairoContext, copyPage)
257 zval * _this_zval = NULL;
261 if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "O", &_this_zval, CairoContext_ce_ptr) == FAILURE) {
262 return;
265 context_object *curr=(context_object *)zend_objects_get_address(_this_zval TSRMLS_CC);
266 cairo_copy_page(curr->context);
267 PHP_CAIRO_CONTEXT_ERROR(curr->context)
270 /* }}} copyPage */
274 /* {{{ proto object copyPath()
276 PHP_METHOD(CairoContext, copyPath)
279 zval * _this_zval = NULL;
283 if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "O", &_this_zval, CairoContext_ce_ptr) == FAILURE) {
284 return;
287 context_object *curr=(context_object *)zend_objects_get_address(_this_zval TSRMLS_CC);
289 object_init_ex(return_value, CairoPath_ce_ptr);
290 path_object *pobj = (path_object *)zend_objects_get_address(return_value TSRMLS_CC);
291 pobj->path = cairo_copy_path(curr->context);
293 /* }}} copyPath */
297 /* {{{ proto object copyPathFlat()
299 PHP_METHOD(CairoContext, copyPathFlat)
302 zval * _this_zval = NULL;
306 if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "O", &_this_zval, CairoContext_ce_ptr) == FAILURE) {
307 return;
310 context_object *curr=(context_object *)zend_objects_get_address(_this_zval TSRMLS_CC);
312 object_init_ex(return_value, CairoPath_ce_ptr);
313 path_object *pobj = (path_object *)zend_objects_get_address(return_value TSRMLS_CC);
314 pobj->path = cairo_copy_path_flat(curr->context);
317 /* }}} copyPathFlat */
321 /* {{{ proto void curveTo (float x1, float y1, float x2, float y2, float x3, float y3)
323 PHP_METHOD(CairoContext, curveTo)
326 zval * _this_zval = NULL;
327 double x1 = 0.0;
328 double y1 = 0.0;
329 double x2 = 0.0;
330 double y2 = 0.0;
331 double x3 = 0.0;
332 double y3 = 0.0;
336 if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "Odddddd", &_this_zval, CairoContext_ce_ptr, &x1, &y1, &x2, &y2, &x3, &y3) == FAILURE) {
337 return;
340 context_object *curr=(context_object *)zend_objects_get_address(_this_zval TSRMLS_CC);
342 cairo_curve_to(curr->context, x1, y1, x2, y2, x3, y3);
343 PHP_CAIRO_CONTEXT_ERROR(curr->context)
346 /* }}} curveTo */
350 /* {{{ proto array deviceToUser(float x, float y)
352 PHP_METHOD(CairoContext, deviceToUser)
355 zval * _this_zval = NULL;
356 double x = 0.0;
357 double y = 0.0;
361 if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "Odd", &_this_zval, CairoContext_ce_ptr, &x, &y) == FAILURE) {
362 return;
365 context_object *curr=(context_object *)zend_objects_get_address(_this_zval TSRMLS_CC);
367 cairo_device_to_user(curr->context, &x, &y);
368 PHP_CAIRO_CONTEXT_ERROR(curr->context)
370 array_init(return_value);
371 add_assoc_double(return_value, "x", x);
372 add_assoc_double(return_value, "y", y);
375 /* }}} deviceToUser */
379 /* {{{ proto array deviceToUserDistance(float x, float y)
381 PHP_METHOD(CairoContext, deviceToUserDistance)
384 zval * _this_zval = NULL;
385 double x = 0.0;
386 double y = 0.0;
390 if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "Odd", &_this_zval, CairoContext_ce_ptr, &x, &y) == FAILURE) {
391 return;
394 context_object *curr=(context_object *)zend_objects_get_address(_this_zval TSRMLS_CC);
395 cairo_device_to_user_distance(curr->context, &x, &y);
396 PHP_CAIRO_CONTEXT_ERROR(curr->context)
397 array_init(return_value);
398 add_assoc_double(return_value, "x", x);
399 add_assoc_double(return_value, "y", y);
402 /* }}} deviceToUserDistance */
406 /* {{{ proto void fill()
408 PHP_METHOD(CairoContext, fill)
411 zval * _this_zval = NULL;
415 if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "O", &_this_zval, CairoContext_ce_ptr) == FAILURE) {
416 return;
419 context_object *curr=(context_object *)zend_objects_get_address(_this_zval TSRMLS_CC);
420 cairo_fill(curr->context);
421 PHP_CAIRO_CONTEXT_ERROR(curr->context)
425 /* }}} fill */
429 /* {{{ proto array fillExtents()
431 PHP_METHOD(CairoContext, fillExtents)
434 zval * _this_zval = NULL;
435 cairo_font_extents_t e;
438 if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "O", &_this_zval, CairoContext_ce_ptr) == FAILURE) {
439 return;
442 context_object *curr=(context_object *)zend_objects_get_address(_this_zval TSRMLS_CC);
443 cairo_font_extents(curr->context, &e);
445 PHP_CAIRO_CONTEXT_ERROR(curr->context)
446 array_init(return_value);
447 add_assoc_double(return_value, "ascent", e.ascent);
448 add_assoc_double(return_value, "descent", e.descent);
449 add_assoc_double(return_value, "height", e.height);
450 add_assoc_double(return_value, "max X advance", e.max_x_advance);
451 add_assoc_double(return_value, "max Y advance", e.max_y_advance);
453 /* }}} fillExtents */
457 /* {{{ proto void fillPreserve()
459 PHP_METHOD(CairoContext, fillPreserve)
462 zval * _this_zval = NULL;
466 if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "O", &_this_zval, CairoContext_ce_ptr) == FAILURE) {
467 return;
470 context_object *curr=(context_object *)zend_objects_get_address(_this_zval TSRMLS_CC);
471 cairo_fill_preserve(curr->context);
472 PHP_CAIRO_CONTEXT_ERROR(curr->context)
476 /* }}} fillPreserve */
480 /* {{{ proto array fontExtents()
482 PHP_METHOD(CairoContext, fontExtents)
484 zval * _this_zval = NULL;
485 cairo_font_extents_t e;
487 if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "O", &_this_zval, CairoContext_ce_ptr) == FAILURE) {
488 return;
491 context_object *curr=(context_object *)zend_objects_get_address(_this_zval TSRMLS_CC);
492 cairo_font_extents(curr->context, &e);
493 PHP_CAIRO_CONTEXT_ERROR(curr->context)
495 array_init(return_value);
496 add_assoc_double(return_value, "ascent", e.ascent);
497 add_assoc_double(return_value, "descent", e.descent);
498 add_assoc_double(return_value, "height", e.height);
499 add_assoc_double(return_value, "max X advance", e.max_x_advance);
500 add_assoc_double(return_value, "max Y advance", e.max_y_advance);
503 /* }}} fontExtents */
507 /* {{{ proto int getAntialias()
509 PHP_METHOD(CairoContext, getAntialias)
511 zval * _this_zval = NULL;
512 long temp;
514 if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "O", &_this_zval, CairoContext_ce_ptr) == FAILURE) {
515 return;
518 context_object *curr=(context_object *)zend_objects_get_address(_this_zval TSRMLS_CC);
519 temp = cairo_get_antialias(curr->context);
521 RETURN_LONG(temp);
523 /* }}} getAntialias */
527 /* {{{ proto array getCurrentPoint()
529 PHP_METHOD(CairoContext, getCurrentPoint)
532 zval * _this_zval = NULL;
533 double x,y;
536 if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "O", &_this_zval, CairoContext_ce_ptr) == FAILURE) {
537 return;
540 context_object *curr=(context_object *)zend_objects_get_address(_this_zval TSRMLS_CC);
541 cairo_get_current_point(curr->context, &x, &y);
542 array_init(return_value);
543 add_assoc_double(return_value, "x", x);
544 add_assoc_double(return_value, "y", y);
546 /* }}} getCurrentPoint */
550 /* {{{ proto array getDash()
552 PHP_METHOD(CairoContext, getDash)
554 zval *sub_array;
555 zval * _this_zval = NULL;
556 double *dashes = NULL, offset;
557 int count, i;
559 if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "O", &_this_zval, CairoContext_ce_ptr) == FAILURE) {
560 return;
563 context_object *curr=(context_object *)zend_objects_get_address(_this_zval TSRMLS_CC);
564 count = cairo_get_dash_count(curr->context);
565 dashes = emalloc(count* sizeof(double));
566 if(dashes==NULL)
567 return;
568 cairo_get_dashes(curr->context, dashes, &offset);
570 MAKE_STD_ZVAL(sub_array);
571 array_init(sub_array);
572 for(i=0; i<count; i++) {
573 add_next_index_double(sub_array,dashes[i]);
576 array_init(return_value);
577 add_assoc_zval(return_value, "Dashes", sub_array);
578 add_assoc_double(return_value, "Offset", offset);
580 /* }}} getDash */
584 /* {{{ proto int getDashCount()
586 PHP_METHOD(CairoContext, getDashCount)
589 zval * _this_zval = NULL;
590 long count;
593 if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "O", &_this_zval, CairoContext_ce_ptr) == FAILURE) {
594 return;
597 context_object *curr=(context_object *)zend_objects_get_address(_this_zval TSRMLS_CC);
598 count = cairo_get_dash_count(curr->context);
600 RETURN_LONG(count);
602 /* }}} getDashCount */
606 /* {{{ proto int getFillRule()
608 PHP_METHOD(CairoContext, getFillRule)
611 zval * _this_zval = NULL;
612 long fill;
615 if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "O", &_this_zval, CairoContext_ce_ptr) == FAILURE) {
616 return;
619 context_object *curr=(context_object *)zend_objects_get_address(_this_zval TSRMLS_CC);
620 fill = cairo_get_fill_rule(curr->context);
622 RETURN_LONG(fill);
624 /* }}} getFillRule */
628 /* {{{ proto object getFontFace()
630 PHP_METHOD(CairoContext, getFontFace)
633 zval * _this_zval = NULL;
635 if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "O", &_this_zval, CairoContext_ce_ptr) == FAILURE) {
636 return;
639 context_object *curr=(context_object *)zend_objects_get_address(_this_zval TSRMLS_CC);
641 object_init_ex(return_value, CairoFontFace_ce_ptr);
642 fontface_object *ffobj = (fontface_object *)zend_objects_get_address(return_value TSRMLS_CC);
643 ffobj->fontface = cairo_font_face_reference (cairo_get_font_face(curr->context));
645 /* }}} getFontFace */
649 /* {{{ proto object getFontMatrix()
651 PHP_METHOD(CairoContext, getFontMatrix)
654 zval * _this_zval = NULL;
655 cairo_matrix_t matrix;
658 if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "O", &_this_zval, CairoContext_ce_ptr) == FAILURE) {
659 return;
662 context_object *curr=(context_object *)zend_objects_get_address(_this_zval TSRMLS_CC);
663 cairo_get_font_matrix(curr->context, &matrix);
665 object_init_ex(return_value, CairoMatrix_ce_ptr);
666 matrix_object *matobj = (matrix_object *)zend_objects_get_address(return_value TSRMLS_CC);
667 matobj->matrix = matrix;
669 /* }}} getFontMatrix */
673 /* {{{ proto object getFontOptions()
675 PHP_METHOD(CairoContext, getFontOptions)
678 zval * _this_zval = NULL;
679 cairo_font_options_t *options = cairo_font_options_create();
682 if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "O", &_this_zval, CairoContext_ce_ptr) == FAILURE) {
683 return;
686 context_object *curr=(context_object *)zend_objects_get_address(_this_zval TSRMLS_CC);
687 cairo_get_font_options(curr->context, options);
689 object_init_ex(return_value, CairoFontOptions_ce_ptr);
690 fontoptions_object *foobj = (fontoptions_object *)zend_objects_get_address(return_value TSRMLS_CC);
691 foobj->fontoptions = options;
694 /* }}} getFontOptions */
698 /* {{{ proto object getGroupTarget()
700 PHP_METHOD(CairoContext, getGroupTarget)
702 zend_class_entry *ce;
703 zval * _this_zval = NULL;
704 cairo_surface_t *sur;
707 if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "O", &_this_zval, CairoContext_ce_ptr) == FAILURE) {
708 return;
711 context_object *curr=(context_object *)zend_objects_get_address(_this_zval TSRMLS_CC);
712 sur = cairo_get_group_target(curr->context);
714 ce = get_CairoSurface_ce_ptr(sur);
716 object_init_ex(return_value, ce);
717 surface_object *sobj = (surface_object *)zend_objects_get_address(return_value TSRMLS_CC);
719 sobj->surface = cairo_surface_reference(sur);
721 /* }}} getGroupTarget */
725 /* {{{ proto int getLineCap()
727 PHP_METHOD(CairoContext, getLineCap)
730 zval * _this_zval = NULL;
731 long line_cap;
734 if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "O", &_this_zval, CairoContext_ce_ptr) == FAILURE) {
735 return;
738 context_object *curr=(context_object *)zend_objects_get_address(_this_zval TSRMLS_CC);
739 line_cap = cairo_get_line_cap(curr->context);
742 RETURN_LONG(line_cap);
744 /* }}} getLineCap */
748 /* {{{ proto int getLineJoin()
750 PHP_METHOD(CairoContext, getLineJoin)
753 zval * _this_zval = NULL;
754 long line_join;
757 if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "O", &_this_zval, CairoContext_ce_ptr) == FAILURE) {
758 return;
761 context_object *curr=(context_object *)zend_objects_get_address(_this_zval TSRMLS_CC);
763 line_join = cairo_get_line_join(curr->context);
764 RETURN_LONG(line_join);
766 /* }}} getLineJoin */
770 /* {{{ proto float getLineWidth()
772 PHP_METHOD(CairoContext, getLineWidth)
775 zval * _this_zval = NULL;
777 double width;
781 if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "O", &_this_zval, CairoContext_ce_ptr) == FAILURE) {
782 return;
785 context_object *curr=(context_object *)zend_objects_get_address(_this_zval TSRMLS_CC);
786 width = cairo_get_line_width(curr->context);
788 RETURN_DOUBLE(width);
790 /* }}} getLineWidth */
794 /* {{{ proto object getMatrix()
796 PHP_METHOD(CairoContext, getMatrix)
799 zval * _this_zval = NULL;
801 cairo_matrix_t matrix;
803 if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "O", &_this_zval, CairoContext_ce_ptr) == FAILURE) {
804 return;
807 context_object *curr=(context_object *)zend_objects_get_address(_this_zval TSRMLS_CC);
809 cairo_get_matrix(curr->context, &matrix);
810 object_init_ex(return_value, CairoMatrix_ce_ptr);
811 matrix_object *mobj = (matrix_object *)zend_objects_get_address(return_value TSRMLS_CC);
812 mobj->matrix = matrix;
814 /* }}} getMatrix */
818 /* {{{ proto float getMiterLimit()
820 PHP_METHOD(CairoContext, getMiterLimit)
823 zval * _this_zval = NULL;
824 double miter;
827 if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "O", &_this_zval, CairoContext_ce_ptr) == FAILURE) {
828 return;
831 context_object *curr=(context_object *)zend_objects_get_address(_this_zval TSRMLS_CC);
832 miter = cairo_get_miter_limit(curr->context);
834 RETURN_DOUBLE(miter);
836 /* }}} getMiterLimit */
840 /* {{{ proto int getOperator()
842 PHP_METHOD(CairoContext, getOperator)
845 zval * _this_zval = NULL;
847 long operator;
849 if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "O", &_this_zval, CairoContext_ce_ptr) == FAILURE) {
850 return;
853 context_object *curr=(context_object *)zend_objects_get_address(_this_zval TSRMLS_CC);
854 operator = cairo_get_operator(curr->context);
856 RETURN_LONG(operator);
858 /* }}} getOperator */
862 /* {{{ proto object getScaledFont()
864 PHP_METHOD(CairoContext, getScaledFont)
867 zval * _this_zval = NULL;
871 if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "O", &_this_zval, CairoContext_ce_ptr) == FAILURE) {
872 return;
875 context_object *curr=(context_object *)zend_objects_get_address(_this_zval TSRMLS_CC);
877 object_init_ex(return_value, CairoScaledFont_ce_ptr);
878 scaledfont_object *sfobj = (scaledfont_object *)zend_objects_get_address(return_value TSRMLS_CC);
880 sfobj->scaledfont = cairo_scaled_font_reference(cairo_get_scaled_font(curr->context));
883 /* }}} getScaledFont */
887 /* {{{ proto object getSource()
889 PHP_METHOD(CairoContext, getSource)
891 zend_class_entry *ce;
892 zval * _this_zval = NULL;
893 cairo_pattern_t *pat;
896 if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "O", &_this_zval, CairoContext_ce_ptr) == FAILURE) {
897 return;
900 context_object *curr=(context_object *)zend_objects_get_address(_this_zval TSRMLS_CC);
902 pat = cairo_pattern_reference(cairo_get_source(curr->context));
904 ce = get_CairoPattern_ce_ptr(pat);
905 object_init_ex(return_value, ce);
907 pattern_object *ptobj = (pattern_object *)zend_objects_get_address(return_value TSRMLS_CC);
908 ptobj->pattern = cairo_pattern_reference(pat);
910 /* }}} getSource */
914 /* {{{ proto object getTarget()
916 PHP_METHOD(CairoContext, getTarget)
918 zend_class_entry *ce;
919 zval * _this_zval = NULL;
920 cairo_surface_t *sur;
923 if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "O", &_this_zval, CairoContext_ce_ptr) == FAILURE) {
924 return;
927 context_object *curr=(context_object *)zend_objects_get_address(_this_zval TSRMLS_CC);
929 sur = cairo_surface_reference(cairo_get_target(curr->context));
931 ce = get_CairoSurface_ce_ptr(sur);
932 object_init_ex(return_value, ce);
934 surface_object *sobj = (surface_object *)zend_objects_get_address(return_value TSRMLS_CC);
935 sobj->surface = cairo_surface_reference(sur);
938 /* }}} getTarget */
942 /* {{{ proto float getTolerance()
944 PHP_METHOD(CairoContext, getTolerance)
947 zval * _this_zval = NULL;
948 double tolerance;
951 if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "O", &_this_zval, CairoContext_ce_ptr) == FAILURE) {
952 return;
955 context_object *curr=(context_object *)zend_objects_get_address(_this_zval TSRMLS_CC);
957 tolerance = cairo_get_tolerance(curr->context);
958 RETURN_DOUBLE(tolerance);
960 /* }}} getTolerance */
964 /* {{{ proto array glyphExtents(array obj,int num) --need to check
966 PHP_METHOD(CairoContext, glyphExtents)
968 int i;
969 zval * _this_zval = NULL, **ppzval;
970 zval * obj = NULL;
971 long num = -1;
972 cairo_glyph_t **glyphs=NULL , **glyph;
973 HashTable *obj_hash = NULL;
974 cairo_text_extents_t extents;
976 if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "Oa/l", &_this_zval, CairoContext_ce_ptr, &obj, &num) == FAILURE) {
977 return;
979 obj_hash = HASH_OF(obj);
980 glyphs = emalloc(num*sizeof(cairo_glyph_t));
982 for(i=0 , glyph=glyphs; i<num; i++, glyph++) {
983 zend_hash_get_current_data(obj_hash, (void **)&glyph);
984 zend_hash_move_forward(obj_hash);
986 context_object *curr=(context_object *)zend_objects_get_address(_this_zval TSRMLS_CC);
988 cairo_glyph_extents(curr->context, glyphs, num, &extents);
990 array_init(return_value);
991 add_assoc_double(return_value, "x_bearing", extents.x_bearing);
992 add_assoc_double(return_value, "y_bearing", extents.y_bearing);
993 add_assoc_double(return_value, "width", extents.width);
994 add_assoc_double(return_value, "height", extents.height);
995 add_assoc_double(return_value, "x_advance", extents.x_advance);
996 add_assoc_double(return_value, "y_advance", extents.y_advance);
997 efree(glyphs);
1000 /* }}} glyphExtents */
1004 /* {{{ proto void glyphPath(array obh , int num])
1006 PHP_METHOD(CairoContext, glyphPath)
1008 int i;
1009 zval * _this_zval = NULL;
1010 zval * obh = NULL;
1011 long num = 0;
1012 cairo_glyph_t *glyphs=NULL , *glyph;
1013 HashTable *obj_hash = NULL;
1014 cairo_text_extents_t extents;
1016 if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "Oa/l", &_this_zval, CairoContext_ce_ptr, &obh, &num) == FAILURE) {
1017 return;
1020 context_object *curr=(context_object *)zend_objects_get_address(_this_zval TSRMLS_CC);
1021 obj_hash = HASH_OF(obh);
1023 glyphs = emalloc(num*sizeof(cairo_glyph_t));
1024 for(i=0 , glyph=glyphs; i<num; i++, glyph++) {
1025 zend_hash_get_current_data(obj_hash, (void **)&glyph);
1026 zend_hash_move_forward(obj_hash);
1028 cairo_glyph_path(curr->context, glyphs, num);
1029 PHP_CAIRO_CONTEXT_ERROR(curr->context);
1032 /* }}} glyphPath */
1036 /* {{{ proto bool hasCurrentPoint() -- Need to remove this and put it in path
1038 PHP_METHOD(CairoContext, hasCurrentPoint)
1041 zval * _this_zval = NULL;
1045 if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "O", &_this_zval, CairoContext_ce_ptr) == FAILURE) {
1046 return;
1049 context_object *curr=(context_object *)zend_objects_get_address(_this_zval TSRMLS_CC);
1052 do {
1053 /* ONLY for CAIRO 1.6 */
1054 } while (0);
1056 /* }}} hasCurrentPoint */
1060 /* {{{ proto void identityMatrix()
1062 PHP_METHOD(CairoContext, identityMatrix)
1065 zval * _this_zval = NULL;
1069 if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "O", &_this_zval, CairoContext_ce_ptr) == FAILURE) {
1070 return;
1073 context_object *curr=(context_object *)zend_objects_get_address(_this_zval TSRMLS_CC);
1074 cairo_identity_matrix(curr->context);
1076 PHP_CAIRO_CONTEXT_ERROR(curr->context);
1079 /* }}} identityMatrix */
1083 /* {{{ proto bool inFill(float x, float y)
1085 PHP_METHOD(CairoContext, inFill)
1088 zval * _this_zval = NULL;
1089 double x = 0.0;
1090 double y = 0.0;
1091 int result;
1094 if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "Odd", &_this_zval, CairoContext_ce_ptr, &x, &y) == FAILURE) {
1095 return;
1098 context_object *curr=(context_object *)zend_objects_get_address(_this_zval TSRMLS_CC);
1100 result = cairo_in_fill(curr->context, x, y);
1102 if(result)
1103 zval_bool(return_value,1);
1104 else
1105 zval_bool(return_value,0);
1109 /* }}} inFill */
1113 /* {{{ proto bool inStroke(float x, float y)
1115 PHP_METHOD(CairoContext, inStroke)
1118 zval * _this_zval = NULL;
1119 double x = 0.0;
1120 double y = 0.0;
1121 int result;
1124 if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "Odd", &_this_zval, CairoContext_ce_ptr, &x, &y) == FAILURE) {
1125 return;
1128 context_object *curr=(context_object *)zend_objects_get_address(_this_zval TSRMLS_CC);
1130 result = cairo_in_stroke(curr->context, x, y);
1132 if(result)
1133 zval_bool(return_value,1);
1134 else
1135 zval_bool(return_value,0);
1138 /* }}} inStroke */
1142 /* {{{ proto void lineTo(float x, float y)
1144 PHP_METHOD(CairoContext, lineTo)
1147 zval * _this_zval = NULL;
1148 double x = 0.0;
1149 double y = 0.0;
1153 if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "Odd", &_this_zval, CairoContext_ce_ptr, &x, &y) == FAILURE) {
1154 return;
1157 context_object *curr=(context_object *)zend_objects_get_address(_this_zval TSRMLS_CC);
1159 cairo_line_to(curr->context, x, y);
1160 PHP_CAIRO_CONTEXT_ERROR(curr->context);
1163 /* }}} lineTo */
1167 /* {{{ proto void mask(object p)
1169 PHP_METHOD(CairoContext, mask)
1172 zval * _this_zval = NULL;
1173 zval * p = NULL;
1177 if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "Oo", &_this_zval, CairoContext_ce_ptr, &p) == FAILURE) {
1178 return;
1181 context_object *curr=(context_object *)zend_objects_get_address(_this_zval TSRMLS_CC);
1183 pattern_object *ptobj = (pattern_object *)zend_objects_get_address(p TSRMLS_CC);
1184 cairo_mask(curr->context, ptobj->pattern);
1185 PHP_CAIRO_CONTEXT_ERROR(curr->context);
1188 /* }}} mask */
1192 /* {{{ proto void maskSurface(object s[,float surface_x, float surface_y])
1194 PHP_METHOD(CairoContext, maskSurface)
1197 zval * _this_zval = NULL;
1198 zval * s = NULL;
1199 double surface_x = 0.0;
1200 double surface_y = 0.0;
1204 if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "Oo|dd", &_this_zval, CairoContext_ce_ptr, &s, &surface_x, &surface_y) == FAILURE) {
1205 return;
1208 context_object *curr=(context_object *)zend_objects_get_address(_this_zval TSRMLS_CC);
1209 surface_object *sobj=(surface_object *)zend_objects_get_address(s TSRMLS_CC);
1210 cairo_mask_surface(curr->context, sobj->surface, surface_x, surface_y);
1211 PHP_CAIRO_CONTEXT_ERROR(curr->context);
1215 /* }}} maskSurface */
1219 /* {{{ proto void moveTo(float x, float y)
1221 PHP_METHOD(CairoContext, moveTo)
1224 zval * _this_zval = NULL;
1225 double x = 0.0;
1226 double y = 0.0;
1230 if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "Odd", &_this_zval, CairoContext_ce_ptr, &x, &y) == FAILURE) {
1231 return;
1234 context_object *curr=(context_object *)zend_objects_get_address(_this_zval TSRMLS_CC);
1236 cairo_move_to(curr->context, x, y);
1237 PHP_CAIRO_CONTEXT_ERROR(curr->context);
1240 /* }}} moveTo */
1244 /* {{{ proto void newPath()
1246 PHP_METHOD(CairoContext, newPath)
1249 zval * _this_zval = NULL;
1253 if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "O", &_this_zval, CairoContext_ce_ptr) == FAILURE) {
1254 return;
1257 context_object *curr=(context_object *)zend_objects_get_address(_this_zval TSRMLS_CC);
1258 cairo_new_path(curr->context);
1259 PHP_CAIRO_CONTEXT_ERROR(curr->context);
1262 /* }}} newPath */
1266 /* {{{ proto void newSubPath()
1268 PHP_METHOD(CairoContext, newSubPath)
1271 zval * _this_zval = NULL;
1275 if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "O", &_this_zval, CairoContext_ce_ptr) == FAILURE) {
1276 return;
1279 context_object *curr=(context_object *)zend_objects_get_address(_this_zval TSRMLS_CC);
1281 cairo_new_sub_path(curr->context);
1282 PHP_CAIRO_CONTEXT_ERROR(curr->context);
1284 /* }}} newSubPath */
1288 /* {{{ proto void paint()
1290 PHP_METHOD(CairoContext, paint)
1293 zval * _this_zval = NULL;
1297 if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "O", &_this_zval, CairoContext_ce_ptr) == FAILURE) {
1298 return;
1301 context_object *curr=(context_object *)zend_objects_get_address(_this_zval TSRMLS_CC);
1302 cairo_paint(curr->context);
1303 PHP_CAIRO_CONTEXT_ERROR(curr->context);
1307 /* }}} paint */
1311 /* {{{ proto void paintWithAlpha(float alpha)
1313 PHP_METHOD(CairoContext, paintWithAlpha)
1316 zval * _this_zval = NULL;
1317 double alpha = 0.0;
1321 if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "Od", &_this_zval, CairoContext_ce_ptr, &alpha) == FAILURE) {
1322 return;
1325 context_object *curr=(context_object *)zend_objects_get_address(_this_zval TSRMLS_CC);
1326 cairo_paint_with_alpha(curr->context, alpha);
1330 /* }}} paintWithAlpha */
1334 /* {{{ proto array pathExtents([object path]) --- need to shift it to path --
1336 PHP_METHOD(CairoContext, pathExtents)
1339 zval * _this_zval = NULL;
1340 zval * path = NULL;
1344 if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "O|o", &_this_zval, CairoContext_ce_ptr, &path) == FAILURE) {
1345 return;
1348 context_object *curr=(context_object *)zend_objects_get_address(_this_zval TSRMLS_CC);
1351 array_init(return_value);
1353 do {
1354 /* ONLY for CAIRO 1.6 */
1355 } while (0);
1357 /* }}} pathExtents */
1361 /* {{{ proto object popGroup()
1363 PHP_METHOD(CairoContext, popGroup)
1365 zend_class_entry *ce;
1366 zval * _this_zval = NULL;
1367 cairo_pattern_t *pat;
1370 if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "O", &_this_zval, CairoContext_ce_ptr) == FAILURE) {
1371 return;
1374 context_object *curr=(context_object *)zend_objects_get_address(_this_zval TSRMLS_CC);
1376 pat = cairo_pop_group(curr->context);
1377 ce = get_CairoPattern_ce_ptr(pat);
1378 object_init_ex(return_value, ce);
1379 pattern_object *ptobj=(pattern_object *)zend_objects_get_address(return_value TSRMLS_CC);
1380 ptobj->pattern = pat;
1383 /* }}} popGroup */
1387 /* {{{ proto void popGroupToSource()
1389 PHP_METHOD(CairoContext, popGroupToSource)
1392 zval * _this_zval = NULL;
1396 if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "O", &_this_zval, CairoContext_ce_ptr) == FAILURE) {
1397 return;
1400 context_object *curr=(context_object *)zend_objects_get_address(_this_zval TSRMLS_CC);
1401 cairo_pop_group_to_source(curr->context);
1402 PHP_CAIRO_CONTEXT_ERROR(curr->context);
1406 /* }}} popGroupToSource */
1410 /* {{{ proto void pushGroup()
1412 PHP_METHOD(CairoContext, pushGroup)
1415 zval * _this_zval = NULL;
1419 if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "O", &_this_zval, CairoContext_ce_ptr) == FAILURE) {
1420 return;
1423 context_object *curr=(context_object *)zend_objects_get_address(_this_zval TSRMLS_CC);
1424 cairo_push_group(curr->context);
1425 PHP_CAIRO_CONTEXT_ERROR(curr->context);
1429 /* }}} pushGroup */
1433 /* {{{ proto void pushGroupWithContent(int content)
1435 PHP_METHOD(CairoContext, pushGroupWithContent)
1438 zval * _this_zval = NULL;
1439 cairo_content_t content;
1443 if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "Ol", &_this_zval, CairoContext_ce_ptr, &content) == FAILURE) {
1444 return;
1447 context_object *curr=(context_object *)zend_objects_get_address(_this_zval TSRMLS_CC);
1448 cairo_push_group_with_content(curr->context, content);
1449 PHP_CAIRO_CONTEXT_ERROR(curr->context);
1452 /* }}} pushGroupWithContent */
1456 /* {{{ proto void rectangle(float x, float y, float width, float height)
1458 PHP_METHOD(CairoContext, rectangle)
1461 zval * _this_zval = NULL;
1462 double x = 0.0;
1463 double y = 0.0;
1464 double width = 0.0;
1465 double height = 0.0;
1469 if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "Odddd", &_this_zval, CairoContext_ce_ptr, &x, &y, &width, &height) == FAILURE) {
1470 return;
1473 context_object *curr=(context_object *)zend_objects_get_address(_this_zval TSRMLS_CC);
1474 cairo_rectangle(curr->context, x, y, width, height);
1475 PHP_CAIRO_CONTEXT_ERROR(curr->context);
1479 /* }}} rectangle */
1483 /* {{{ proto void relCurveTo(float x1, float y1, float x2, float y2, float x3, float y3)
1485 PHP_METHOD(CairoContext, relCurveTo)
1488 zval * _this_zval = NULL;
1489 double x1 = 0.0;
1490 double y1 = 0.0;
1491 double x2 = 0.0;
1492 double y2 = 0.0;
1493 double x3 = 0.0;
1494 double y3 = 0.0;
1498 if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "Odddddd", &_this_zval, CairoContext_ce_ptr, &x1, &y1, &x2, &y2, &x3, &y3) == FAILURE) {
1499 return;
1502 context_object *curr=(context_object *)zend_objects_get_address(_this_zval TSRMLS_CC);
1503 cairo_rel_curve_to(curr->context, x1, y1, x2, y2, x3, y3);
1504 PHP_CAIRO_CONTEXT_ERROR(curr->context);
1507 /* }}} relCurveTo */
1511 /* {{{ proto void relLineTo(float x, float y)
1513 PHP_METHOD(CairoContext, relLineTo)
1516 zval * _this_zval = NULL;
1517 double x = 0.0;
1518 double y = 0.0;
1522 if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "Odd", &_this_zval, CairoContext_ce_ptr, &x, &y) == FAILURE) {
1523 return;
1526 context_object *curr=(context_object *)zend_objects_get_address(_this_zval TSRMLS_CC);
1527 cairo_rel_line_to(curr->context, x, y);
1528 PHP_CAIRO_CONTEXT_ERROR(curr->context);
1531 /* }}} relLineTo */
1535 /* {{{ proto void relMoveTo(float x, float y)
1537 PHP_METHOD(CairoContext, relMoveTo)
1540 zval * _this_zval = NULL;
1541 double x = 0.0;
1542 double y = 0.0;
1546 if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "Odd", &_this_zval, CairoContext_ce_ptr, &x, &y) == FAILURE) {
1547 return;
1550 context_object *curr=(context_object *)zend_objects_get_address(_this_zval TSRMLS_CC);
1551 cairo_rel_move_to(curr->context, x, y);
1552 PHP_CAIRO_CONTEXT_ERROR(curr->context);
1554 /* }}} relMoveTo */
1558 /* {{{ proto void resetClip()
1560 PHP_METHOD(CairoContext, resetClip)
1563 zval * _this_zval = NULL;
1567 if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "O", &_this_zval, CairoContext_ce_ptr) == FAILURE) {
1568 return;
1571 context_object *curr=(context_object *)zend_objects_get_address(_this_zval TSRMLS_CC);
1572 cairo_reset_clip(curr->context);
1573 PHP_CAIRO_CONTEXT_ERROR(curr->context);
1577 /* }}} resetClip */
1581 /* {{{ proto void restore()
1583 PHP_METHOD(CairoContext, restore)
1586 zval * _this_zval = NULL;
1590 if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "O", &_this_zval, CairoContext_ce_ptr) == FAILURE) {
1591 return;
1594 context_object *curr=(context_object *)zend_objects_get_address(_this_zval TSRMLS_CC);
1596 cairo_restore(curr->context);
1597 PHP_CAIRO_CONTEXT_ERROR(curr->context);
1601 /* }}} restore */
1605 /* {{{ proto void rotate(float angle)
1607 PHP_METHOD(CairoContext, rotate)
1610 zval * _this_zval = NULL;
1611 double angle = 0.0;
1615 if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "Od", &_this_zval, CairoContext_ce_ptr, &angle) == FAILURE) {
1616 return;
1619 context_object *curr=(context_object *)zend_objects_get_address(_this_zval TSRMLS_CC);
1620 cairo_rotate(curr->context, angle);
1621 PHP_CAIRO_CONTEXT_ERROR(curr->context);
1624 /* }}} rotate */
1628 /* {{{ proto void save()
1630 PHP_METHOD(CairoContext, save)
1633 zval * _this_zval = NULL;
1637 if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "O", &_this_zval, CairoContext_ce_ptr) == FAILURE) {
1638 return;
1641 context_object *curr=(context_object *)zend_objects_get_address(_this_zval TSRMLS_CC);
1643 cairo_save(curr->context);
1644 PHP_CAIRO_CONTEXT_ERROR(curr->context);
1647 /* }}} save */
1651 /* {{{ proto void scale(float x, float y)
1653 PHP_METHOD(CairoContext, scale)
1656 zval * _this_zval = NULL;
1657 double x = 0.0;
1658 double y = 0.0;
1662 if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "Odd", &_this_zval, CairoContext_ce_ptr, &x, &y) == FAILURE) {
1663 return;
1666 context_object *curr=(context_object *)zend_objects_get_address(_this_zval TSRMLS_CC);
1668 cairo_scale(curr->context, x, y);
1669 PHP_CAIRO_CONTEXT_ERROR(curr->context);
1673 /* }}} scale */
1677 /* {{{ proto void selectFontFace(object string[, int slant, int weight])
1679 PHP_METHOD(CairoContext, selectFontFace)
1682 zval * _this_zval = NULL;
1683 const char * family = NULL;
1684 int family_len = 0;
1685 cairo_font_slant_t slant = CAIRO_FONT_SLANT_NORMAL;
1686 cairo_font_weight_t weight = CAIRO_FONT_WEIGHT_NORMAL;
1690 if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "Os|ll", &_this_zval, CairoContext_ce_ptr, &family, &family_len, &slant, &weight) == FAILURE) {
1691 return;
1694 context_object *curr=(context_object *)zend_objects_get_address(_this_zval TSRMLS_CC);
1695 cairo_select_font_face(curr->context, family, slant, weight);
1696 PHP_CAIRO_CONTEXT_ERROR(curr->context);
1699 /* }}} selectFontFace */
1703 /* {{{ proto void setAntialias([int antialias])
1705 PHP_METHOD(CairoContext, setAntialias)
1708 zval * _this_zval = NULL;
1709 cairo_antialias_t antialias = CAIRO_ANTIALIAS_DEFAULT;
1713 if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "O|l", &_this_zval, CairoContext_ce_ptr, &antialias) == FAILURE) {
1714 return;
1717 context_object *curr=(context_object *)zend_objects_get_address(_this_zval TSRMLS_CC);
1718 cairo_set_antialias(curr->context, antialias);
1719 PHP_CAIRO_CONTEXT_ERROR(curr->context);
1722 /* }}} setAntialias */
1726 /* {{{ proto void setDash(array dashes, int num_dashes [,float offset])
1728 PHP_METHOD(CairoContext, setDash)
1730 double *das, **d;
1731 zval * _this_zval = NULL;
1732 zval * dashes = NULL, **ppzval;
1733 long num_dashes = 0;
1734 HashTable *dashes_hash = NULL;
1735 double offset = 0.0;
1736 int i;
1739 if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "Oa/l|d", &_this_zval, CairoContext_ce_ptr, &dashes, &num_dashes, &offset) == FAILURE) {
1740 return;
1742 dashes_hash = Z_ARRVAL_P(dashes);
1743 das = emalloc(num_dashes * sizeof(double));
1744 context_object *curr=(context_object *)zend_objects_get_address(_this_zval TSRMLS_CC);
1745 i = zend_hash_num_elements(dashes_hash);
1746 if(i!=num_dashes)
1747 printf("Problem !!!");
1748 i=0;
1749 for(zend_hash_internal_pointer_reset(dashes_hash); zend_hash_has_more_elements(dashes_hash) == SUCCESS; zend_hash_move_forward(dashes_hash)) {
1750 if (zend_hash_get_current_data(dashes_hash, (void **)&ppzval) == FAILURE) {
1751 continue;
1754 das[i++] = Z_DVAL_PP(ppzval);
1757 cairo_set_dash(curr->context, das, num_dashes, offset);
1758 PHP_CAIRO_CONTEXT_ERROR(curr->context);
1759 efree(das);
1763 /* }}} setDash */
1767 /* {{{ proto void setFillRule(int fill_rule)
1769 PHP_METHOD(CairoContext, setFillRule)
1772 zval * _this_zval = NULL;
1773 cairo_fill_rule_t fill_rule = 0;
1777 if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "Ol", &_this_zval, CairoContext_ce_ptr, &fill_rule) == FAILURE) {
1778 return;
1781 context_object *curr=(context_object *)zend_objects_get_address(_this_zval TSRMLS_CC);
1782 cairo_set_fill_rule(curr->context, fill_rule);
1783 PHP_CAIRO_CONTEXT_ERROR(curr->context);
1785 /* }}} setFillRule */
1789 /* {{{ proto void setFontFace([object obj])
1791 PHP_METHOD(CairoContext, setFontFace)
1794 zval * _this_zval = NULL;
1795 zval * obj = NULL;
1799 if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "O|o", &_this_zval, CairoContext_ce_ptr, &obj) == FAILURE) {
1800 return;
1803 context_object *curr=(context_object *)zend_objects_get_address(_this_zval TSRMLS_CC);
1804 if (obj != NULL) {
1805 fontface_object *ffobj = (fontface_object *)zend_objects_get_address(obj TSRMLS_CC);
1806 cairo_set_font_face(curr->context, ffobj->fontface);
1808 else
1809 cairo_set_font_face(curr->context, NULL);
1810 PHP_CAIRO_CONTEXT_ERROR(curr->context);
1814 /* }}} setFontFace */
1818 /* {{{ proto void setFontMatrix(object matrix)
1820 PHP_METHOD(CairoContext, setFontMatrix)
1823 zval * _this_zval = NULL;
1824 zval * matrix = NULL;
1828 if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "Oo", &_this_zval, CairoContext_ce_ptr, &matrix) == FAILURE) {
1829 return;
1832 context_object *curr=(context_object *)zend_objects_get_address(_this_zval TSRMLS_CC);
1833 matrix_object *mobj=(matrix_object *)zend_objects_get_address(matrix TSRMLS_CC);
1834 cairo_set_font_matrix(curr->context, &mobj->matrix);
1835 PHP_CAIRO_CONTEXT_ERROR(curr->context);
1838 /* }}} setFontMatrix */
1842 /* {{{ proto void setFontOptions(object options)
1844 PHP_METHOD(CairoContext, setFontOptions)
1847 zval * _this_zval = NULL;
1848 zval * options = NULL;
1852 if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "Oo", &_this_zval, CairoContext_ce_ptr, &options) == FAILURE) {
1853 return;
1856 context_object *curr=(context_object *)zend_objects_get_address(_this_zval TSRMLS_CC);
1857 fontoptions_object *foobj=(fontoptions_object *)zend_objects_get_address(options TSRMLS_CC);
1858 cairo_set_font_options(curr->context, foobj->fontoptions);
1859 PHP_CAIRO_CONTEXT_ERROR(curr->context);
1863 /* }}} setFontOptions */
1867 /* {{{ proto void setFontSize(float size)
1869 PHP_METHOD(CairoContext, setFontSize)
1872 zval * _this_zval = NULL;
1873 double size = 0.0;
1877 if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "Od", &_this_zval, CairoContext_ce_ptr, &size) == FAILURE) {
1878 return;
1881 context_object *curr=(context_object *)zend_objects_get_address(_this_zval TSRMLS_CC);
1882 cairo_set_font_size(curr->context, size);
1883 PHP_CAIRO_CONTEXT_ERROR(curr->context);
1886 /* }}} setFontSize */
1890 /* {{{ proto void setLineCap(int line_cap)
1892 PHP_METHOD(CairoContext, setLineCap)
1895 zval * _this_zval = NULL;
1896 long line_cap = 0;
1900 if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "Ol", &_this_zval, CairoContext_ce_ptr, &line_cap) == FAILURE) {
1901 return;
1904 context_object *curr=(context_object *)zend_objects_get_address(_this_zval TSRMLS_CC);
1905 cairo_set_line_cap(curr->context, line_cap);
1906 PHP_CAIRO_CONTEXT_ERROR(curr->context);
1911 /* }}} setLineCap */
1915 /* {{{ proto void setLineJoin(int line_join)
1917 PHP_METHOD(CairoContext, setLineJoin)
1920 zval * _this_zval = NULL;
1921 long line_join = 0;
1925 if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "Ol", &_this_zval, CairoContext_ce_ptr, &line_join) == FAILURE) {
1926 return;
1929 context_object *curr=(context_object *)zend_objects_get_address(_this_zval TSRMLS_CC);
1931 cairo_set_line_join(curr->context, line_join);
1932 PHP_CAIRO_CONTEXT_ERROR(curr->context);
1935 /* }}} setLineJoin */
1939 /* {{{ proto void setLineWidth(float width)
1941 PHP_METHOD(CairoContext, setLineWidth)
1944 zval * _this_zval = NULL;
1945 double width = 0.0;
1949 if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "Od", &_this_zval, CairoContext_ce_ptr, &width) == FAILURE) {
1950 return;
1953 context_object *curr = (context_object *)zend_objects_get_address(_this_zval TSRMLS_CC);
1954 cairo_set_line_width(curr->context, width);
1956 /* }}} set_line_width */
1960 /* {{{ proto void setMatrix(object matix)
1962 PHP_METHOD(CairoContext, setMatrix)
1965 zval * _this_zval = NULL;
1966 zval * matix = NULL;
1970 if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "Oo", &_this_zval, CairoContext_ce_ptr, &matix) == FAILURE) {
1971 return;
1974 context_object *curr=(context_object *)zend_objects_get_address(_this_zval TSRMLS_CC);
1975 matrix_object *mobj=(matrix_object *)zend_objects_get_address(matix TSRMLS_CC);
1976 cairo_set_matrix(curr->context, &mobj->matrix);
1977 PHP_CAIRO_CONTEXT_ERROR(curr->context);
1980 /* }}} setMatrix */
1984 /* {{{ proto void setMiterLimit(float limit)
1986 PHP_METHOD(CairoContext, setMiterLimit)
1989 zval * _this_zval = NULL;
1990 double limit = 0.0;
1994 if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "Od", &_this_zval, CairoContext_ce_ptr, &limit) == FAILURE) {
1995 return;
1998 context_object *curr=(context_object *)zend_objects_get_address(_this_zval TSRMLS_CC);
1999 cairo_set_miter_limit(curr->context, limit);
2000 PHP_CAIRO_CONTEXT_ERROR(curr->context);
2003 /* }}} setMiterLimit */
2007 /* {{{ proto void setOperator(int op)
2009 PHP_METHOD(CairoContext, setOperator)
2012 zval * _this_zval = NULL;
2013 long op = 0;
2017 if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "Ol", &_this_zval, CairoContext_ce_ptr, &op) == FAILURE) {
2018 return;
2021 context_object *curr=(context_object *)zend_objects_get_address(_this_zval TSRMLS_CC);
2022 cairo_set_operator(curr->context, op);
2023 PHP_CAIRO_CONTEXT_ERROR(curr->context);
2026 /* }}} setOperator */
2030 /* {{{ proto void setSource(object p)
2032 PHP_METHOD(CairoContext, setSource)
2035 zval * _this_zval = NULL;
2036 zval * p = NULL;
2040 if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "Oo", &_this_zval, CairoContext_ce_ptr, &p) == FAILURE) {
2041 return;
2044 context_object *curr=(context_object *)zend_objects_get_address(_this_zval TSRMLS_CC);
2045 pattern_object *ptobj=(pattern_object *)zend_objects_get_address(p TSRMLS_CC);
2046 cairo_set_source(curr->context, ptobj->pattern);
2047 PHP_CAIRO_CONTEXT_ERROR(curr->context);
2050 /* }}} setSource */
2054 /* {{{ proto void setSourceRgb(float red, float green, float blue)
2056 PHP_METHOD(CairoContext, setSourceRgb)
2059 zval * _this_zval = NULL;
2060 double red = 0.0;
2061 double green = 0.0;
2062 double blue = 0.0;
2066 if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "Oddd", &_this_zval, CairoContext_ce_ptr, &red, &green, &blue) == FAILURE) {
2067 return;
2070 context_object *curr=(context_object *)zend_objects_get_address(_this_zval TSRMLS_CC);
2071 cairo_set_source_rgb(curr->context, red, green, blue);
2072 PHP_CAIRO_CONTEXT_ERROR(curr->context);
2075 /* }}} setSourceRgb */
2079 /* {{{ proto void setSourceRgba(float red, float green, float blue [,float alpha])
2081 PHP_METHOD(CairoContext, setSourceRgba)
2084 zval * _this_zval = NULL;
2085 double red = 0.0;
2086 double green = 0.0;
2087 double blue = 0.0;
2088 double alpha = 0.0;
2092 if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "Oddd|d", &_this_zval, CairoContext_ce_ptr, &red, &green, &blue, &alpha) == FAILURE) {
2093 return;
2096 context_object *curr=(context_object *)zend_objects_get_address(_this_zval TSRMLS_CC);
2097 cairo_set_source_rgba(curr->context, red, green, blue, alpha);
2098 PHP_CAIRO_CONTEXT_ERROR(curr->context);
2101 /* }}} setSourceRgba */
2105 /* {{{ proto void setSourceSurface(object surface [,float x, float y])
2107 PHP_METHOD(CairoContext, setSourceSurface)
2110 zval * _this_zval = NULL;
2111 zval * surface = NULL;
2112 double x = 0.0;
2113 double y = 0.0;
2117 if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "Oo|dd", &_this_zval, CairoContext_ce_ptr, &surface, &x, &y) == FAILURE) {
2118 return;
2121 context_object *curr=(context_object *)zend_objects_get_address(_this_zval TSRMLS_CC);
2122 surface_object *sobj=(surface_object *)zend_objects_get_address(surface TSRMLS_CC);
2123 cairo_set_source_surface(curr->context, sobj->surface, x, y);
2124 PHP_CAIRO_CONTEXT_ERROR(curr->context);
2127 /* }}} setSourceSurface */
2131 /* {{{ proto void setTolerance(float tolerance)
2133 PHP_METHOD(CairoContext, setTolerance)
2136 zval * _this_zval = NULL;
2137 double tolerance = 0.0;
2141 if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "Od", &_this_zval, CairoContext_ce_ptr, &tolerance) == FAILURE) {
2142 return;
2145 context_object *curr=(context_object *)zend_objects_get_address(_this_zval TSRMLS_CC);
2146 cairo_set_tolerance(curr->context, tolerance);
2147 PHP_CAIRO_CONTEXT_ERROR(curr->context);
2150 /* }}} setTolerance */
2154 /* {{{ proto void showGlyphs(array obj ,int num_glyphs)
2156 PHP_METHOD(CairoContext, showGlyphs)
2158 int i;
2159 zval * _this_zval = NULL, **ppzval;
2160 zval * obj = NULL;
2161 long num_glyphs = 0;
2162 HashTable *obj_hash = NULL;
2163 cairo_glyph_t *glyphs=NULL, *glyph;
2167 if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "Oa/l", &_this_zval, CairoContext_ce_ptr, &obj, &num_glyphs) == FAILURE) {
2168 return;
2171 context_object *curr=(context_object *)zend_objects_get_address(_this_zval TSRMLS_CC);
2172 obj_hash = HASH_OF(obj);
2174 glyphs = emalloc(num_glyphs*sizeof(cairo_glyph_t));
2175 i=0;
2176 for(zend_hash_internal_pointer_reset(obj_hash); zend_hash_has_more_elements(obj_hash) == SUCCESS; zend_hash_move_forward(obj_hash)) {
2177 if (zend_hash_get_current_data(obj_hash, (void **)&ppzval) == FAILURE) {
2178 continue;
2180 // glyphs[i++] = Z_RESVAL_PP(ppzval);
2184 /* for(i=0 , glyph=glyphs; i<num_glyphs; i++, glyph++) {
2185 zend_hash_get_current_data(obj_hash, (void **)&glyph);
2186 zend_hash_move_forward(obj_hash);
2189 cairo_show_glyphs(curr->context, glyphs, num_glyphs);
2190 PHP_CAIRO_CONTEXT_ERROR(curr->context);
2193 /* }}} showGlyphs */
2197 /* {{{ proto void showPage()
2199 PHP_METHOD(CairoContext, showPage)
2202 zval * _this_zval = NULL;
2206 if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "O", &_this_zval, CairoContext_ce_ptr) == FAILURE) {
2207 return;
2210 context_object *curr=(context_object *)zend_objects_get_address(_this_zval TSRMLS_CC);
2211 cairo_show_page(curr->context);
2212 PHP_CAIRO_CONTEXT_ERROR(curr->context);
2215 /* }}} showPage */
2219 /* {{{ proto void showText(string obj)
2221 PHP_METHOD(CairoContext, showText)
2224 zval * _this_zval = NULL;
2225 const char * obj = NULL;
2226 int obj_len = 0;
2230 if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "Os", &_this_zval, CairoContext_ce_ptr, &obj, &obj_len) == FAILURE) {
2231 return;
2234 context_object *curr=(context_object *)zend_objects_get_address(_this_zval TSRMLS_CC);
2235 cairo_show_text(curr->context, obj);
2236 PHP_CAIRO_CONTEXT_ERROR(curr->context);
2239 /* }}} showText */
2243 /* {{{ proto void stroke()
2245 PHP_METHOD(CairoContext, stroke)
2248 zval * _this_zval = NULL;
2252 if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "O", &_this_zval, CairoContext_ce_ptr) == FAILURE) {
2253 return;
2256 context_object *curr = (context_object *)zend_objects_get_address(_this_zval TSRMLS_CC);
2257 cairo_stroke(curr->context);
2258 PHP_CAIRO_CONTEXT_ERROR(curr->context);
2262 /* }}} stroke */
2266 /* {{{ proto array strokeExtents()
2268 PHP_METHOD(CairoContext, strokeExtents)
2271 zval * _this_zval = NULL;
2272 double x1=0, x2=0, y1=0, y2=0;
2276 if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "O", &_this_zval, CairoContext_ce_ptr) == FAILURE) {
2277 return;
2280 context_object *curr=(context_object *)zend_objects_get_address(_this_zval TSRMLS_CC);
2281 cairo_stroke_extents(curr->context, &x1, &y1, &x2, &y2);
2283 array_init(return_value);
2284 add_assoc_double(return_value, "x1", x1);
2285 add_assoc_double(return_value, "y1", y1);
2286 add_assoc_double(return_value, "x2", x2);
2287 add_assoc_double(return_value, "y2", y2);
2290 /* }}} strokeExtents */
2294 /* {{{ proto void strokePreserve()
2296 PHP_METHOD(CairoContext, strokePreserve)
2299 zval * _this_zval = NULL;
2303 if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "O", &_this_zval, CairoContext_ce_ptr) == FAILURE) {
2304 return;
2307 context_object *curr=(context_object *)zend_objects_get_address(_this_zval TSRMLS_CC);
2308 cairo_stroke_preserve(curr->context);
2309 PHP_CAIRO_CONTEXT_ERROR(curr->context);
2312 /* }}} strokePreserve */
2316 /* {{{ proto array textExtents(string str)
2318 PHP_METHOD(CairoContext, textExtents)
2321 zval * _this_zval = NULL;
2322 const char * str = NULL;
2323 long str_len=0;
2324 cairo_text_extents_t extents;
2327 if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "Os", &_this_zval, CairoContext_ce_ptr, &str, &str_len) == FAILURE) {
2328 return;
2331 context_object *curr=(context_object *)zend_objects_get_address(_this_zval TSRMLS_CC);
2333 cairo_text_extents(curr->context, str, &extents);
2335 array_init(return_value);
2336 add_assoc_double(return_value, "x_bearing", extents.x_bearing);
2337 add_assoc_double(return_value, "y_bearing", extents.y_bearing);
2338 add_assoc_double(return_value, "width", extents.width);
2339 add_assoc_double(return_value, "height", extents.height);
2340 add_assoc_double(return_value, "x_advance", extents.x_advance);
2341 add_assoc_double(return_value, "y_advance", extents.y_advance);
2344 /* }}} textExtents */
2348 /* {{{ proto void textPath(string obj)
2350 PHP_METHOD(CairoContext, textPath)
2353 zval * _this_zval = NULL;
2354 const char * obj = NULL;
2355 long obj_len = 0;
2359 if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "Os", &_this_zval, CairoContext_ce_ptr, &obj, &obj_len) == FAILURE) {
2360 return;
2363 context_object *curr=(context_object *)zend_objects_get_address(_this_zval TSRMLS_CC);
2364 cairo_text_path(curr->context, obj);
2365 PHP_CAIRO_CONTEXT_ERROR(curr->context);
2368 /* }}} textPath */
2372 /* {{{ proto void transform(object matrix)
2374 PHP_METHOD(CairoContext, transform)
2377 zval * _this_zval = NULL;
2378 zval * matrix = NULL;
2382 if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "Oo", &_this_zval, CairoContext_ce_ptr, &matrix) == FAILURE) {
2383 return;
2386 context_object *curr=(context_object *)zend_objects_get_address(_this_zval TSRMLS_CC);
2387 matrix_object *mobj = (matrix_object *)zend_objects_get_address(matrix TSRMLS_CC);
2388 cairo_transform(curr->context, &mobj->matrix);
2389 PHP_CAIRO_CONTEXT_ERROR(curr->context);
2392 /* }}} transform */
2396 /* {{{ proto void translate(float tx, float ty)
2398 PHP_METHOD(CairoContext, translate)
2401 zval * _this_zval = NULL;
2402 double tx = 0.0;
2403 double ty = 0.0;
2407 if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "Odd", &_this_zval, CairoContext_ce_ptr, &tx, &ty) == FAILURE) {
2408 return;
2411 context_object *curr=(context_object *)zend_objects_get_address(_this_zval TSRMLS_CC);
2413 cairo_translate(curr->context, tx, ty);
2414 PHP_CAIRO_CONTEXT_ERROR(curr->context);
2417 /* }}} translate */
2421 /* {{{ proto array userToDevice(float x, float y)
2423 PHP_METHOD(CairoContext, userToDevice)
2426 zval * _this_zval = NULL;
2427 double x = 0.0;
2428 double y = 0.0;
2432 if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "Odd", &_this_zval, CairoContext_ce_ptr, &x, &y) == FAILURE) {
2433 return;
2436 context_object *curr=(context_object *)zend_objects_get_address(_this_zval TSRMLS_CC);
2438 cairo_user_to_device(curr->context, &x, &y);
2439 PHP_CAIRO_CONTEXT_ERROR(curr->context);
2441 array_init(return_value);
2442 add_assoc_double(return_value, "x", x);
2443 add_assoc_double(return_value, "y", y);
2446 /* }}} userToDevice */
2450 /* {{{ proto array userToDeviceDistance(float dx, float dy)
2452 PHP_METHOD(CairoContext, userToDeviceDistance)
2455 zval * _this_zval = NULL;
2456 double dx = 0.0;
2457 double dy = 0.0;
2461 if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "Odd", &_this_zval, CairoContext_ce_ptr, &dx, &dy) == FAILURE) {
2462 return;
2465 context_object *curr=(context_object *)zend_objects_get_address(_this_zval TSRMLS_CC);
2466 cairo_user_to_device_distance(curr->context, &dx, &dy);
2467 PHP_CAIRO_CONTEXT_ERROR(curr->context);
2469 array_init(return_value);
2470 add_assoc_double(return_value, "x", dx);
2471 add_assoc_double(return_value, "y", dy);
2474 /* }}} userToDeviceDistance */
2477 static zend_function_entry CairoContext_methods[] = {
2478 PHP_ME(CairoContext, __construct, NULL, /**/ZEND_ACC_PUBLIC | ZEND_ACC_CTOR)
2479 PHP_ME(CairoContext, appendPath, CairoContext__append_path_args, /**/ZEND_ACC_PUBLIC)
2480 PHP_ME(CairoContext, arc, CairoContext__arc_args, /**/ZEND_ACC_PUBLIC)
2481 PHP_ME(CairoContext, arcNegative, CairoContext__arc_negative_args, /**/ZEND_ACC_PUBLIC)
2482 PHP_ME(CairoContext, clip, NULL, /**/ZEND_ACC_PUBLIC)
2483 PHP_ME(CairoContext, clipExtents, NULL, /**/ZEND_ACC_PUBLIC)
2484 PHP_ME(CairoContext, clipPreserve, NULL, /**/ZEND_ACC_PUBLIC)
2485 PHP_ME(CairoContext, closePath, NULL, /**/ZEND_ACC_PUBLIC)
2486 PHP_ME(CairoContext, copyClipRectangleList, NULL, /**/ZEND_ACC_PUBLIC)
2487 PHP_ME(CairoContext, copyPage, NULL, /**/ZEND_ACC_PUBLIC)
2488 PHP_ME(CairoContext, copyPath, NULL, /**/ZEND_ACC_PUBLIC)
2489 PHP_ME(CairoContext, copyPathFlat, NULL, /**/ZEND_ACC_PUBLIC)
2490 PHP_ME(CairoContext, curveTo, CairoContext__curve_to_args, /**/ZEND_ACC_PUBLIC)
2491 PHP_ME(CairoContext, deviceToUser, CairoContext__device_to_user_args, /**/ZEND_ACC_PUBLIC)
2492 PHP_ME(CairoContext, deviceToUserDistance, CairoContext__device_to_user_distance_args, /**/ZEND_ACC_PUBLIC)
2493 PHP_ME(CairoContext, fill, NULL, /**/ZEND_ACC_PUBLIC)
2494 PHP_ME(CairoContext, fillExtents, NULL, /**/ZEND_ACC_PUBLIC)
2495 PHP_ME(CairoContext, fillPreserve, NULL, /**/ZEND_ACC_PUBLIC)
2496 PHP_ME(CairoContext, fontExtents, NULL, /**/ZEND_ACC_PUBLIC)
2497 PHP_ME(CairoContext, getAntialias, NULL, /**/ZEND_ACC_PUBLIC)
2498 PHP_ME(CairoContext, getCurrentPoint, NULL, /**/ZEND_ACC_PUBLIC)
2499 PHP_ME(CairoContext, getDash, NULL, /**/ZEND_ACC_PUBLIC)
2500 PHP_ME(CairoContext, getDashCount, NULL, /**/ZEND_ACC_PUBLIC)
2501 PHP_ME(CairoContext, getFillRule, NULL, /**/ZEND_ACC_PUBLIC)
2502 PHP_ME(CairoContext, getFontFace, NULL, /**/ZEND_ACC_PUBLIC)
2503 PHP_ME(CairoContext, getFontMatrix, NULL, /**/ZEND_ACC_PUBLIC)
2504 PHP_ME(CairoContext, getFontOptions, NULL, /**/ZEND_ACC_PUBLIC)
2505 PHP_ME(CairoContext, getGroupTarget, NULL, /**/ZEND_ACC_PUBLIC)
2506 PHP_ME(CairoContext, getLineCap, NULL, /**/ZEND_ACC_PUBLIC)
2507 PHP_ME(CairoContext, getLineJoin, NULL, /**/ZEND_ACC_PUBLIC)
2508 PHP_ME(CairoContext, getLineWidth, NULL, /**/ZEND_ACC_PUBLIC)
2509 PHP_ME(CairoContext, getMatrix, NULL, /**/ZEND_ACC_PUBLIC)
2510 PHP_ME(CairoContext, getMiterLimit, NULL, /**/ZEND_ACC_PUBLIC)
2511 PHP_ME(CairoContext, getOperator, NULL, /**/ZEND_ACC_PUBLIC)
2512 PHP_ME(CairoContext, getScaledFont, NULL, /**/ZEND_ACC_PUBLIC)
2513 PHP_ME(CairoContext, getSource, NULL, /**/ZEND_ACC_PUBLIC)
2514 PHP_ME(CairoContext, getTarget, NULL, /**/ZEND_ACC_PUBLIC)
2515 PHP_ME(CairoContext, getTolerance, NULL, /**/ZEND_ACC_PUBLIC)
2516 PHP_ME(CairoContext, glyphExtents, CairoContext__glyph_extents_args, /**/ZEND_ACC_PUBLIC)
2517 PHP_ME(CairoContext, glyphPath, CairoContext__glyph_path_args, /**/ZEND_ACC_PUBLIC)
2518 PHP_ME(CairoContext, hasCurrentPoint, NULL, /**/ZEND_ACC_PUBLIC)
2519 PHP_ME(CairoContext, identityMatrix, NULL, /**/ZEND_ACC_PUBLIC)
2520 PHP_ME(CairoContext, inFill, CairoContext__in_fill_args, /**/ZEND_ACC_PUBLIC)
2521 PHP_ME(CairoContext, inStroke, CairoContext__in_stroke_args, /**/ZEND_ACC_PUBLIC)
2522 PHP_ME(CairoContext, lineTo, CairoContext__line_to_args, /**/ZEND_ACC_PUBLIC)
2523 PHP_ME(CairoContext, mask, CairoContext__mask_args, /**/ZEND_ACC_PUBLIC)
2524 PHP_ME(CairoContext, maskSurface, CairoContext__mask_surface_args, /**/ZEND_ACC_PUBLIC)
2525 PHP_ME(CairoContext, moveTo, CairoContext__move_to_args, /**/ZEND_ACC_PUBLIC)
2526 PHP_ME(CairoContext, newPath, NULL, /**/ZEND_ACC_PUBLIC)
2527 PHP_ME(CairoContext, newSubPath, NULL, /**/ZEND_ACC_PUBLIC)
2528 PHP_ME(CairoContext, paint, NULL, /**/ZEND_ACC_PUBLIC)
2529 PHP_ME(CairoContext, paintWithAlpha, CairoContext__paint_with_alpha_args, /**/ZEND_ACC_PUBLIC)
2530 PHP_ME(CairoContext, pathExtents, CairoContext__path_extents_args, /**/ZEND_ACC_PUBLIC)
2531 PHP_ME(CairoContext, popGroup, NULL, /**/ZEND_ACC_PUBLIC)
2532 PHP_ME(CairoContext, popGroupToSource, NULL, /**/ZEND_ACC_PUBLIC)
2533 PHP_ME(CairoContext, pushGroup, NULL, /**/ZEND_ACC_PUBLIC)
2534 PHP_ME(CairoContext, pushGroupWithContent, CairoContext__push_group_with_content_args, /**/ZEND_ACC_PUBLIC)
2535 PHP_ME(CairoContext, rectangle, CairoContext__rectangle_args, /**/ZEND_ACC_PUBLIC)
2536 PHP_ME(CairoContext, relCurveTo, CairoContext__rel_curve_to_args, /**/ZEND_ACC_PUBLIC)
2537 PHP_ME(CairoContext, relLineTo, CairoContext__rel_line_to_args, /**/ZEND_ACC_PUBLIC)
2538 PHP_ME(CairoContext, relMoveTo, CairoContext__rel_move_to_args, /**/ZEND_ACC_PUBLIC)
2539 PHP_ME(CairoContext, resetClip, NULL, /**/ZEND_ACC_PUBLIC)
2540 PHP_ME(CairoContext, restore, NULL, /**/ZEND_ACC_PUBLIC)
2541 PHP_ME(CairoContext, rotate, CairoContext__rotate_args, /**/ZEND_ACC_PUBLIC)
2542 PHP_ME(CairoContext, save, NULL, /**/ZEND_ACC_PUBLIC)
2543 PHP_ME(CairoContext, scale, CairoContext__scale_args, /**/ZEND_ACC_PUBLIC)
2544 PHP_ME(CairoContext, selectFontFace, CairoContext__select_font_face_args, /**/ZEND_ACC_PUBLIC)
2545 PHP_ME(CairoContext, setAntialias, CairoContext__set_antialias_args, /**/ZEND_ACC_PUBLIC)
2546 PHP_ME(CairoContext, setDash, CairoContext__set_dash_args, /**/ZEND_ACC_PUBLIC)
2547 PHP_ME(CairoContext, setFillRule, CairoContext__set_fill_rule_args, /**/ZEND_ACC_PUBLIC)
2548 PHP_ME(CairoContext, setFontFace, CairoContext__set_font_face_args, /**/ZEND_ACC_PUBLIC)
2549 PHP_ME(CairoContext, setFontMatrix, CairoContext__set_font_matrix_args, /**/ZEND_ACC_PUBLIC)
2550 PHP_ME(CairoContext, setFontOptions, CairoContext__set_font_options_args, /**/ZEND_ACC_PUBLIC)
2551 PHP_ME(CairoContext, setFontSize, CairoContext__set_font_size_args, /**/ZEND_ACC_PUBLIC)
2552 PHP_ME(CairoContext, setLineCap, CairoContext__set_line_cap_args, /**/ZEND_ACC_PUBLIC)
2553 PHP_ME(CairoContext, setLineJoin, CairoContext__set_line_join_args, /**/ZEND_ACC_PUBLIC)
2554 PHP_ME(CairoContext, setLineWidth, CairoContext__set_line_width_args, /**/ZEND_ACC_PUBLIC)
2555 PHP_ME(CairoContext, setMatrix, CairoContext__set_matrix_args, /**/ZEND_ACC_PUBLIC)
2556 PHP_ME(CairoContext, setMiterLimit, CairoContext__set_miter_limit_args, /**/ZEND_ACC_PUBLIC)
2557 PHP_ME(CairoContext, setOperator, CairoContext__set_operator_args, /**/ZEND_ACC_PUBLIC)
2558 PHP_ME(CairoContext, setSource, CairoContext__set_source_args, /**/ZEND_ACC_PUBLIC)
2559 PHP_ME(CairoContext, setSourceRgb, CairoContext__set_source_rgb_args, /**/ZEND_ACC_PUBLIC)
2560 PHP_ME(CairoContext, setSourceRgba, CairoContext__set_source_rgba_args, /**/ZEND_ACC_PUBLIC)
2561 PHP_ME(CairoContext, setSourceSurface, CairoContext__set_source_surface_args, /**/ZEND_ACC_PUBLIC)
2562 PHP_ME(CairoContext, setTolerance, CairoContext__set_tolerance_args, /**/ZEND_ACC_PUBLIC)
2563 PHP_ME(CairoContext, showGlyphs, CairoContext__show_glyphs_args, /**/ZEND_ACC_PUBLIC)
2564 PHP_ME(CairoContext, showPage, NULL, /**/ZEND_ACC_PUBLIC)
2565 PHP_ME(CairoContext, showText, CairoContext__show_text_args, /**/ZEND_ACC_PUBLIC)
2566 PHP_ME(CairoContext, stroke, NULL, /**/ZEND_ACC_PUBLIC)
2567 PHP_ME(CairoContext, strokeExtents, NULL, /**/ZEND_ACC_PUBLIC)
2568 PHP_ME(CairoContext, strokePreserve, NULL, /**/ZEND_ACC_PUBLIC)
2569 PHP_ME(CairoContext, textExtents, CairoContext__text_extents_args, /**/ZEND_ACC_PUBLIC)
2570 PHP_ME(CairoContext, textPath, CairoContext__text_path_args, /**/ZEND_ACC_PUBLIC)
2571 PHP_ME(CairoContext, transform, CairoContext__transform_args, /**/ZEND_ACC_PUBLIC)
2572 PHP_ME(CairoContext, translate, CairoContext__translate_args, /**/ZEND_ACC_PUBLIC)
2573 PHP_ME(CairoContext, userToDevice, CairoContext__user_to_device_args, /**/ZEND_ACC_PUBLIC)
2574 PHP_ME(CairoContext, userToDeviceDistance, CairoContext__user_to_device_distance_args, /**/ZEND_ACC_PUBLIC)
2575 { NULL, NULL, NULL }
2578 /* }}} Methods */
2580 static zend_object_handlers CairoContext_handlers;
2583 typedef struct _context_object {
2584 zend_object std;
2585 cairo_t *context;
2586 } context_object;
2589 static void CairoContext_object_dtor(void *object)
2591 context_object *context = (context_object *)object;
2592 zend_hash_destroy(context->std.properties);
2593 FREE_HASHTABLE(context->std.properties);
2595 if(context->context){
2596 cairo_destroy(context->context);
2598 efree(object);
2601 static zend_object_value CairoContext_object_new(zend_class_entry *ce)
2603 zend_object_value retval;
2604 context_object *context;
2605 zval *temp;
2607 context=emalloc(sizeof(context_object));
2608 memset(context,0,sizeof(context_object));
2609 context->std.ce = ce;
2610 ALLOC_HASHTABLE(context->std.properties);
2611 zend_hash_init(context->std.properties, 0, NULL, ZVAL_PTR_DTOR,0);
2612 zend_hash_copy(context->std.properties, &ce->default_properties, (copy_ctor_func_t) zval_add_ref, (void *) &temp, sizeof(zval *));
2613 retval.handle = zend_objects_store_put(context, NULL, (zend_objects_free_object_storage_t)CairoContext_object_dtor, NULL TSRMLS_CC);
2614 retval.handlers = &CairoContext_handlers;
2615 return retval;
2620 static void class_init_CairoContext(void)
2622 zend_class_entry ce;
2623 INIT_CLASS_ENTRY(ce, "CairoContext", CairoContext_methods);
2624 CairoContext_ce_ptr = zend_register_internal_class(&ce);
2625 CairoContext_ce_ptr->create_object = CairoContext_object_new;
2626 memcpy(&CairoContext_handlers, zend_get_std_object_handlers(), sizeof(zend_object_handlers));
2627 CairoContext_handlers.clone_obj=NULL;
2630 /* }}} Class CairoContext */
2632 zend_class_entry* get_CairoContext_ce_ptr()
2634 return CairoContext_ce_ptr;