CairoContext almost done ... testing still to be done ...
[phpCairo.git] / individual_files / phpCairoContext.c
blob604442c58a432642985f0a14542215e6e9b83781
1 /* {{{ Class CairoContext */
3 static zend_class_entry * CairoContext_ce_ptr = NULL;
5 /* {{{ Methods */
8 /* {{{ proto void construct(object obj)
9 */
10 PHP_METHOD(CairoContext, __construct)
12 zend_class_entry * _this_ce;
13 zval * _this_zval;
15 zval * obj = NULL;
17 if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|o", &obj) == FAILURE) {
18 return;
21 _this_zval = getThis();
22 _this_ce = Z_OBJCE_P(_this_zval);
23 cairo_surface_t *surface;
24 //if(obj != NULL) {
26 surface_object *sobj = (surface_object *)zend_object_store_get_object(obj TSRMLS_CC);
27 //}
28 //else {
29 // surface_object *sobj = (surface_object *)malloc(surface_object);
30 //}
32 surface = sobj->surface;
33 context_object *context=(context_object *)zend_objects_get_address(_this_zval TSRMLS_CC);
34 context->context=cairo_create(surface);
36 /*php_error(E_WARNING, "__construct: not yet implemented"); RETURN_FALSE; */
39 /* }}} __construct */
43 /* {{{ proto void append_path(object p)
45 PHP_METHOD(CairoContext, append_path)
47 zend_class_entry * _this_ce;
49 zval * _this_zval = NULL;
50 zval * p = NULL;
54 if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "Oo", &_this_zval, CairoContext_ce_ptr, &p) == FAILURE) {
55 return;
58 _this_ce = Z_OBJCE_P(_this_zval);
59 context_object *curr = (context_object *)zend_objects_get_address(_this_zval TSRMLS_CC);
60 path_object *pobj=(path_object *)zend_objects_get_address(p TSRMLS_CC);
61 cairo_append_path(curr->context,pobj->path);
62 phpCAIRO_CONTEXT_ERROR(curr->context)
65 /* }}} append_path */
69 /* {{{ proto void arc(float xc, float yc, float radius, float angle1, float angle2)
71 PHP_METHOD(CairoContext, arc)
73 zend_class_entry * _this_ce;
75 zval * _this_zval = NULL;
76 double xc = 0.0;
77 double yc = 0.0;
78 double radius = 0.0;
79 double angle1 = 0.0;
80 double angle2 = 0.0;
84 if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "Oddddd", &_this_zval, CairoContext_ce_ptr, &xc, &yc, &radius, &angle1, &angle2) == FAILURE) {
85 return;
88 _this_ce = Z_OBJCE_P(_this_zval);
89 context_object *curr=(context_object *)zend_objects_get_address(_this_zval TSRMLS_CC);
90 cairo_arc(curr->context,xc,yc,radius,angle1,angle2);
91 phpCAIRO_CONTEXT_ERROR(curr->context)
94 /* }}} arc */
98 /* {{{ proto void arc_negative(float xc, float yc, float radius, float angle1, float angle2)
100 PHP_METHOD(CairoContext, arc_negative)
102 zend_class_entry * _this_ce;
104 zval * _this_zval = NULL;
105 double xc = 0.0;
106 double yc = 0.0;
107 double radius = 0.0;
108 double angle1 = 0.0;
109 double angle2 = 0.0;
113 if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "Oddddd", &_this_zval, CairoContext_ce_ptr, &xc, &yc, &radius, &angle1, &angle2) == FAILURE) {
114 return;
117 _this_ce = Z_OBJCE_P(_this_zval);
119 context_object *curr = (context_object *)zend_objects_get_address(_this_zval TSRMLS_CC);
122 cairo_arc_negative(curr->context, xc, yc, radius, angle1, angle2);
123 phpCAIRO_CONTEXT_ERROR(curr->context)
127 /* }}} arc_negative */
131 /* {{{ proto void clip()
133 PHP_METHOD(CairoContext, clip)
135 zend_class_entry * _this_ce;
137 zval * _this_zval = NULL;
141 if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "O", &_this_zval, CairoContext_ce_ptr) == FAILURE) {
142 return;
145 _this_ce = Z_OBJCE_P(_this_zval);
146 context_object *curr=(context_object *)zend_objects_get_address(_this_zval TSRMLS_CC);
147 cairo_clip(curr->context);
148 phpCAIRO_CONTEXT_ERROR(curr->context)
150 /* }}} clip */
154 /* {{{ proto array clip_extents()
156 PHP_METHOD(CairoContext, clip_extents)
158 zend_class_entry * _this_ce;
160 zval * _this_zval = NULL;
162 double x1, y1, x2, y2;
164 if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "O", &_this_zval, CairoContext_ce_ptr) == FAILURE) {
165 return;
168 _this_ce = Z_OBJCE_P(_this_zval);
169 context_object *curr=(context_object *)zend_objects_get_address(_this_zval TSRMLS_CC);
171 cairo_clip_extents(curr->context, &x1, &y1, &x2, &y2);
172 phpCAIRO_CONTEXT_ERROR(curr->context)
173 array_init(return_value);
174 add_next_index_double(return_value, x1);
175 add_next_index_double(return_value, y1);
176 add_next_index_double(return_value, x2);
177 add_next_index_double(return_value, y2);
180 /* }}} clip_extents */
184 /* {{{ proto void clip_preserve()
186 PHP_METHOD(CairoContext, clip_preserve)
188 zend_class_entry * _this_ce;
190 zval * _this_zval = NULL;
194 if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "O", &_this_zval, CairoContext_ce_ptr) == FAILURE) {
195 return;
198 _this_ce = Z_OBJCE_P(_this_zval);
200 context_object *curr=(context_object *)zend_objects_get_address(_this_zval TSRMLS_CC);
202 cairo_clip_preserve(curr->context);
203 phpCAIRO_CONTEXT_ERROR(curr->context)
205 /* }}} clip_preserve */
209 /* {{{ proto void close_path()
211 PHP_METHOD(CairoContext, close_path)
213 zend_class_entry * _this_ce;
215 zval * _this_zval = NULL;
219 if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "O", &_this_zval, CairoContext_ce_ptr) == FAILURE) {
220 return;
223 _this_ce = Z_OBJCE_P(_this_zval);
224 context_object *curr=(context_object *)zend_objects_get_address(_this_zval TSRMLS_CC);
226 cairo_close_path(curr->context);
227 phpCAIRO_CONTEXT_ERROR(curr->context)
230 /* }}} close_path */
234 /* {{{ proto object copy_clip_rectangle_list() --Not complete
236 PHP_METHOD(CairoContext, copy_clip_rectangle_list)
238 zend_class_entry * _this_ce;
240 zval * _this_zval = NULL;
241 cairo_rectangle_t *r;
242 cairo_rectangle_list_t *rlist;
243 zval *arr;
244 zval **temp_arr;
245 int i;
247 if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "O", &_this_zval, CairoContext_ce_ptr) == FAILURE) {
248 return;
250 _this_ce = Z_OBJCE_P(_this_zval);
251 context_object *curr=(context_object *)zend_objects_get_address(_this_zval TSRMLS_CC);
252 rlist = cairo_copy_clip_rectangle_list(curr->context);
253 phpCAIRO_ERROR(rlist->status)
256 ALLOC_INIT_ZVAL(arr);
257 array_init(arr);
258 for(i = 0, r = rlist->rectangle; i < rlist->num_rectangles; i++, r++) {
259 ALLOC_INIT_ZVAL(temp_arr);
260 array_init(temp_arr);
261 array_assoc_double(temp_arr,"x",r->x);
262 array_assoc_double(temp_arr,"y",r->y);
263 array_assoc_double(temp_arr,"width",r->width);
264 array_assoc_double(temp_arr,"height",r->height);
265 add_next_index_zval(arr,temp_arr);
266 zval_ptr_dtor(temp_arr);
269 /* Need to pass the arr to an iterator */
270 //cairo_rectangle_list_destroy(rlist);
274 /* }}} copy_clip_rectangle_list */
278 /* {{{ proto void copy_page()
280 PHP_METHOD(CairoContext, copy_page)
282 zend_class_entry * _this_ce;
284 zval * _this_zval = NULL;
288 if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "O", &_this_zval, CairoContext_ce_ptr) == FAILURE) {
289 return;
292 _this_ce = Z_OBJCE_P(_this_zval);
293 context_object *curr=(context_object *)zend_objects_get_address(_this_zval TSRMLS_CC);
294 cairo_copy_page(curr->context);
295 phpCAIRO_CONTEXT_ERROR(curr->context)
298 /* }}} copy_page */
302 /* {{{ proto object copy_path()
304 PHP_METHOD(CairoContext, copy_path)
306 zend_class_entry * _this_ce;
308 zval * _this_zval = NULL;
312 if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "O", &_this_zval, CairoContext_ce_ptr) == FAILURE) {
313 return;
316 _this_ce = Z_OBJCE_P(_this_zval);
317 context_object *curr=(context_object *)zend_objects_get_address(_this_zval TSRMLS_CC);
319 object_init(return_value);
320 path_object *pobj = (path_object *)zend_objects_get_address(return_value TSRMLS_CC);
321 pobj->path = cairo_copy_path(curr->context);
323 /* }}} copy_path */
327 /* {{{ proto object copy_path_flat()
329 PHP_METHOD(CairoContext, copy_path_flat)
331 zend_class_entry * _this_ce;
333 zval * _this_zval = NULL;
337 if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "O", &_this_zval, CairoContext_ce_ptr) == FAILURE) {
338 return;
341 _this_ce = Z_OBJCE_P(_this_zval);
342 context_object *curr=(context_object *)zend_objects_get_address(_this_zval TSRMLS_CC);
344 object_init(return_value);
345 path_object *pobj = (path_object *)zend_objects_get_address(return_value TSRMLS_CC);
346 pobj->path = cairo_copy_path_flat(curr->context);
349 /* }}} copy_path_flat */
353 /* {{{ proto void curve_to (float x1, float y1, float x2, float y2, float x3, float y3)
355 PHP_METHOD(CairoContext, curve_to)
357 zend_class_entry * _this_ce;
359 zval * _this_zval = NULL;
360 double x1 = 0.0;
361 double y1 = 0.0;
362 double x2 = 0.0;
363 double y2 = 0.0;
364 double x3 = 0.0;
365 double y3 = 0.0;
369 if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "Odddddd", &_this_zval, CairoContext_ce_ptr, &x1, &y1, &x2, &y2, &x3, &y3) == FAILURE) {
370 return;
373 _this_ce = Z_OBJCE_P(_this_zval);
374 context_object *curr=(context_object *)zend_objects_get_address(_this_zval TSRMLS_CC);
376 cairo_curve_to(curr->context, x1, y1, x2, y2, x3, y3);
377 phpCAIRO_CONTEXT_ERROR(curr->context)
380 /* }}} curve_to */
384 /* {{{ proto array device_to_user(float x, float y)
386 PHP_METHOD(CairoContext, device_to_user)
388 zend_class_entry * _this_ce;
390 zval * _this_zval = NULL;
391 double x = 0.0;
392 double y = 0.0;
396 if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "Odd", &_this_zval, CairoContext_ce_ptr, &x, &y) == FAILURE) {
397 return;
400 _this_ce = Z_OBJCE_P(_this_zval);
401 context_object *curr=(context_object *)zend_objects_get_address(_this_zval TSRMLS_CC);
403 cairo_device_to_user(curr->context, &x, &y);
404 phpCAIRO_CONTEXT_ERROR(curr->context)
406 array_init(return_value);
407 add_assoc_double(return_value, "x", x);
408 add_assoc_double(return_value, "y", y);
411 /* }}} device_to_user */
415 /* {{{ proto array device_to_user_distance(float x, float y)
417 PHP_METHOD(CairoContext, device_to_user_distance)
419 zend_class_entry * _this_ce;
421 zval * _this_zval = NULL;
422 double x = 0.0;
423 double y = 0.0;
427 if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "Odd", &_this_zval, CairoContext_ce_ptr, &x, &y) == FAILURE) {
428 return;
431 _this_ce = Z_OBJCE_P(_this_zval);
432 context_object *curr=(context_object *)zend_objects_get_address(_this_zval TSRMLS_CC);
433 cairo_device_to_user_distance(curr->context, &x, &y);
434 phpCAIRO_CONTEXT_ERROR(curr->context)
435 array_init(return_value);
436 add_assoc_double(return_value, "x", x);
437 add_assoc_double(return_value, "y", y);
440 /* }}} device_to_user_distance */
444 /* {{{ proto void fill()
446 PHP_METHOD(CairoContext, fill)
448 zend_class_entry * _this_ce;
450 zval * _this_zval = NULL;
454 if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "O", &_this_zval, CairoContext_ce_ptr) == FAILURE) {
455 return;
458 _this_ce = Z_OBJCE_P(_this_zval);
459 context_object *curr=(context_object *)zend_objects_get_address(_this_zval TSRMLS_CC);
460 cairo_fill(curr->context);
461 phpCAIRO_CONTEXT_ERROR(curr->context)
465 /* }}} fill */
469 /* {{{ proto array fill_extents()
471 PHP_METHOD(CairoContext, fill_extents)
473 zend_class_entry * _this_ce;
475 zval * _this_zval = NULL;
476 cairo_font_extents_t e;
479 if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "O", &_this_zval, CairoContext_ce_ptr) == FAILURE) {
480 return;
483 _this_ce = Z_OBJCE_P(_this_zval);
484 context_object *curr=(context_object *)zend_objects_get_address(_this_zval TSRMLS_CC);
485 cairo_font_extents(curr->context, &e);
487 phpCAIRO_CONTEXT_ERROR(curr->context)
488 array_init(return_value);
489 add_assoc_double(return_value, "ascent", e.ascent);
490 add_assoc_double(return_value, "descent", e.descent);
491 add_assoc_double(return_value, "height", e.height);
492 add_assoc_double(return_value, "max X advance", e.max_x_advance);
493 add_assoc_double(return_value, "max Y advance", e.max_y_advance);
495 /* }}} fill_extents */
499 /* {{{ proto void fill_preserve()
501 PHP_METHOD(CairoContext, fill_preserve)
503 zend_class_entry * _this_ce;
505 zval * _this_zval = NULL;
509 if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "O", &_this_zval, CairoContext_ce_ptr) == FAILURE) {
510 return;
513 _this_ce = Z_OBJCE_P(_this_zval);
514 context_object *curr=(context_object *)zend_objects_get_address(_this_zval TSRMLS_CC);
515 cairo_fill_preserve(curr->context);
516 phpCAIRO_CONTEXT_ERROR(curr->context)
520 /* }}} fill_preserve */
524 /* {{{ proto array font_extents()
526 PHP_METHOD(CairoContext, font_extents)
528 zend_class_entry * _this_ce;
529 zval * _this_zval = NULL;
530 cairo_font_extents_t e;
532 if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "O", &_this_zval, CairoContext_ce_ptr) == FAILURE) {
533 return;
536 _this_ce = Z_OBJCE_P(_this_zval);
537 context_object *curr=(context_object *)zend_objects_get_address(_this_zval TSRMLS_CC);
538 cairo_font_extents(curr->context, &e);
539 phpCAIRO_CONTEXT_ERROR(curr->context)
541 array_init(return_value);
542 add_assoc_double(return_value, "ascent", e.ascent);
543 add_assoc_double(return_value, "descent", e.descent);
544 add_assoc_double(return_value, "height", e.height);
545 add_assoc_double(return_value, "max X advance", e.max_x_advance);
546 add_assoc_double(return_value, "max Y advance", e.max_y_advance);
549 /* }}} font_extents */
553 /* {{{ proto int get_antialias()
555 PHP_METHOD(CairoContext, get_antialias)
557 zend_class_entry * _this_ce;
558 zval * _this_zval = NULL;
559 long temp;
561 if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "O", &_this_zval, CairoContext_ce_ptr) == FAILURE) {
562 return;
565 _this_ce = Z_OBJCE_P(_this_zval);
566 context_object *curr=(context_object *)zend_objects_get_address(_this_zval TSRMLS_CC);
567 temp = cairo_get_antialias(curr->context);
569 RETURN_LONG(temp);
571 /* }}} get_antialias */
575 /* {{{ proto array get_current_point()
577 PHP_METHOD(CairoContext, get_current_point)
579 zend_class_entry * _this_ce;
581 zval * _this_zval = NULL;
582 double x,y;
585 if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "O", &_this_zval, CairoContext_ce_ptr) == FAILURE) {
586 return;
589 _this_ce = Z_OBJCE_P(_this_zval);
590 context_object *curr=(context_object *)zend_objects_get_address(_this_zval TSRMLS_CC);
591 cairo_get_current_point(curr->context, &x, &y);
592 array_init(return_value);
593 add_assoc_double(return_value, "x", x);
594 add_assoc_double(return_value, "y", y);
596 /* }}} get_current_point */
600 /* {{{ proto array get_dash()
602 PHP_METHOD(CairoContext, get_dash)
604 zend_class_entry * _this_ce;
605 zval *sub_array;
606 zval * _this_zval = NULL;
607 double *dashes = NULL, offset;
608 int count, i;
610 if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "O", &_this_zval, CairoContext_ce_ptr) == FAILURE) {
611 return;
614 _this_ce = Z_OBJCE_P(_this_zval);
615 context_object *curr=(context_object *)zend_objects_get_address(_this_zval TSRMLS_CC);
616 count = cairo_get_dash_count(curr->context);
617 dashes = emalloc(count* sizeof(double));
618 if(dashes==NULL)
619 return;
620 cairo_get_dashes(curr->context, dashes, &offset);
622 MAKE_STD_ZVAL(sub_array);
623 array_init(sub_array);
624 for(i=0; i<count; i++) {
625 add_next_index_double(sub_array,dashes[i]);
628 array_init(return_value);
629 add_assoc_zval(return_value, "Dashes", sub_array);
630 add_assoc_double(return_value, "Offset", offset);
632 /* }}} get_dash */
636 /* {{{ proto int get_dash_count()
638 PHP_METHOD(CairoContext, get_dash_count)
640 zend_class_entry * _this_ce;
642 zval * _this_zval = NULL;
643 long count;
646 if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "O", &_this_zval, CairoContext_ce_ptr) == FAILURE) {
647 return;
650 _this_ce = Z_OBJCE_P(_this_zval);
651 context_object *curr=(context_object *)zend_objects_get_address(_this_zval TSRMLS_CC);
652 count = cairo_get_dash_count(curr->context);
654 RETURN_LONG(count);
656 /* }}} get_dash_count */
660 /* {{{ proto int get_fill_rule()
662 PHP_METHOD(CairoContext, get_fill_rule)
664 zend_class_entry * _this_ce;
666 zval * _this_zval = NULL;
667 long fill;
670 if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "O", &_this_zval, CairoContext_ce_ptr) == FAILURE) {
671 return;
674 _this_ce = Z_OBJCE_P(_this_zval);
675 context_object *curr=(context_object *)zend_objects_get_address(_this_zval TSRMLS_CC);
676 fill = cairo_get_fill_rule(curr->context);
678 RETURN_LONG(fill);
680 /* }}} get_fill_rule */
684 /* {{{ proto object get_font_face()
686 PHP_METHOD(CairoContext, get_font_face)
688 zend_class_entry * _this_ce;
690 zval * _this_zval = NULL;
692 if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "O", &_this_zval, CairoContext_ce_ptr) == FAILURE) {
693 return;
696 _this_ce = Z_OBJCE_P(_this_zval);
697 context_object *curr=(context_object *)zend_objects_get_address(_this_zval TSRMLS_CC);
699 object_init(return_value);
700 fontface_object *ffobj = (fontface_object *)zend_objects_get_address(return_value TSRMLS_CC);
701 ffobj->fontface = cairo_font_face_reference (cairo_get_font_face(curr->context));
703 /* }}} get_font_face */
707 /* {{{ proto object get_font_matrix()
709 PHP_METHOD(CairoContext, get_font_matrix)
711 zend_class_entry * _this_ce;
713 zval * _this_zval = NULL;
714 cairo_matrix_t matrix;
717 if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "O", &_this_zval, CairoContext_ce_ptr) == FAILURE) {
718 return;
721 _this_ce = Z_OBJCE_P(_this_zval);
722 context_object *curr=(context_object *)zend_objects_get_address(_this_zval TSRMLS_CC);
723 cairo_get_font_matrix(curr->context, &matrix);
725 object_init(return_value);
726 matrix_object *matobj = (matrix_object *)zend_object_get_address(return_value TSRMLS_CC);
727 matobj->matrix = matrix;
729 /* }}} get_font_matrix */
733 /* {{{ proto object get_font_options()
735 PHP_METHOD(CairoContext, get_font_options)
737 zend_class_entry * _this_ce;
739 zval * _this_zval = NULL;
740 cairo_font_options_t *options = cairo_font_options_create();
743 if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "O", &_this_zval, CairoContext_ce_ptr) == FAILURE) {
744 return;
747 _this_ce = Z_OBJCE_P(_this_zval);
748 context_object *curr=(context_object *)zend_objects_get_address(_this_zval TSRMLS_CC);
749 cairo_get_font_options(curr->context, options);
751 object_init(return_value);
752 fontoptions_object *foobj = (fontoptions_object *)zend_objects_get_address(return_value TSRMLS_CC);
753 foobj->fontoptions = options;
756 /* }}} get_font_options */
760 /* {{{ proto object get_group_target()
762 PHP_METHOD(CairoContext, get_group_target)
764 zend_class_entry * _this_ce;
766 zval * _this_zval = NULL;
770 if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "O", &_this_zval, CairoContext_ce_ptr) == FAILURE) {
771 return;
774 _this_ce = Z_OBJCE_P(_this_zval);
775 context_object *curr=(context_object *)zend_objects_get_address(_this_zval TSRMLS_CC);
777 object_init(return_value);
778 surface_object *sobj = (surface_object *)zend_objects_get_address(return_value TSRMLS_CC);
780 sobj->surface = cairo_surface_reference(cairo_get_group_target(curr->context));
782 /* }}} get_group_target */
786 /* {{{ proto int get_line_cap()
788 PHP_METHOD(CairoContext, get_line_cap)
790 zend_class_entry * _this_ce;
792 zval * _this_zval = NULL;
793 long line_cap;
796 if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "O", &_this_zval, CairoContext_ce_ptr) == FAILURE) {
797 return;
800 _this_ce = Z_OBJCE_P(_this_zval);
801 context_object *curr=(context_object *)zend_objects_get_address(_this_zval TSRMLS_CC);
802 line_cap = cairo_get_line_cap(curr->context);
805 RETURN_LONG(line_cap);
807 /* }}} get_line_cap */
811 /* {{{ proto int get_line_join()
813 PHP_METHOD(CairoContext, get_line_join)
815 zend_class_entry * _this_ce;
817 zval * _this_zval = NULL;
818 long line_join;
821 if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "O", &_this_zval, CairoContext_ce_ptr) == FAILURE) {
822 return;
825 _this_ce = Z_OBJCE_P(_this_zval);
826 context_object *curr=(context_object *)zend_objects_get_address(_this_zval TSRMLS_CC);
828 line_join = cairo_get_line_join(curr->context);
829 RETURN_LONG(line_join);
831 /* }}} get_line_join */
835 /* {{{ proto float get_line_width()
837 PHP_METHOD(CairoContext, get_line_width)
839 zend_class_entry * _this_ce;
841 zval * _this_zval = NULL;
843 double width;
847 if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "O", &_this_zval, CairoContext_ce_ptr) == FAILURE) {
848 return;
851 _this_ce = Z_OBJCE_P(_this_zval);
852 context_object *curr=(context_object *)zend_objects_get_address(_this_zval TSRMLS_CC);
853 width = cairo_get_line_width(curr->context);
855 RETURN_DOUBLE(width);
857 /* }}} get_line_width */
861 /* {{{ proto object get_matrix()
863 PHP_METHOD(CairoContext, get_matrix)
865 zend_class_entry * _this_ce;
867 zval * _this_zval = NULL;
869 cairo_matrix_t matrix;
871 if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "O", &_this_zval, CairoContext_ce_ptr) == FAILURE) {
872 return;
875 _this_ce = Z_OBJCE_P(_this_zval);
876 context_object *curr=(context_object *)zend_objects_get_address(_this_zval TSRMLS_CC);
878 cairo_get_matrix(curr->context, &matrix);
879 object_init(return_value);
880 matrix_object *mobj = (matrix_object *)zend_objects_get_address(return_value TSRMLS_CC);
881 mobj->matrix = matrix;
883 /* }}} get_matrix */
887 /* {{{ proto float get_miter_limit()
889 PHP_METHOD(CairoContext, get_miter_limit)
891 zend_class_entry * _this_ce;
893 zval * _this_zval = NULL;
894 double miter;
897 if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "O", &_this_zval, CairoContext_ce_ptr) == FAILURE) {
898 return;
901 _this_ce = Z_OBJCE_P(_this_zval);
902 context_object *curr=(context_object *)zend_objects_get_address(_this_zval TSRMLS_CC);
903 miter = cairo_get_miter_limit(curr->context);
905 RETURN_DOUBLE(miter);
907 /* }}} get_miter_limit */
911 /* {{{ proto int get_operator()
913 PHP_METHOD(CairoContext, get_operator)
915 zend_class_entry * _this_ce;
917 zval * _this_zval = NULL;
919 long operator;
921 if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "O", &_this_zval, CairoContext_ce_ptr) == FAILURE) {
922 return;
925 _this_ce = Z_OBJCE_P(_this_zval);
926 context_object *curr=(context_object *)zend_objects_get_address(_this_zval TSRMLS_CC);
927 operator = cairo_get_operator(curr->context);
929 RETURN_LONG(operator);
931 /* }}} get_operator */
935 /* {{{ proto object get_scaled_font()
937 PHP_METHOD(CairoContext, get_scaled_font)
939 zend_class_entry * _this_ce;
941 zval * _this_zval = NULL;
945 if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "O", &_this_zval, CairoContext_ce_ptr) == FAILURE) {
946 return;
949 _this_ce = Z_OBJCE_P(_this_zval);
950 context_object *curr=(context_object *)zend_objects_get_address(_this_zval TSRMLS_CC);
952 object_init(return_value);
953 scaledfont_object *sfobj = (scaledfont_object *)zend_objects_get_address(return_value TSRMLS_CC);
955 sfobj->scaledfont = cairo_scaled_font_reference(cairo_get_scaled_font(curr->context));
958 /* }}} get_scaled_font */
962 /* {{{ proto object get_source()
964 PHP_METHOD(CairoContext, get_source)
966 zend_class_entry * _this_ce;
968 zval * _this_zval = NULL;
972 if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "O", &_this_zval, CairoContext_ce_ptr) == FAILURE) {
973 return;
976 _this_ce = Z_OBJCE_P(_this_zval);
977 context_object *curr=(context_object *)zend_objects_get_address(_this_zval TSRMLS_CC);
979 object_init(return_value);
981 pattern_object *ptobj = (pattern_object *)zend_objects_get_address(return_value TSRMLS_CC);
982 ptobj->pattern = cairo_pattern_reference(cairo_get_source(curr->context));
984 /* }}} get_source */
988 /* {{{ proto object get_target()
990 PHP_METHOD(CairoContext, get_target)
992 zend_class_entry * _this_ce;
994 zval * _this_zval = NULL;
998 if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "O", &_this_zval, CairoContext_ce_ptr) == FAILURE) {
999 return;
1002 _this_ce = Z_OBJCE_P(_this_zval);
1003 context_object *curr=(context_object *)zend_objects_get_address(_this_zval TSRMLS_CC);
1004 object_init(return_value);
1006 surface_object *sobj = (surface_object *)zend_objects_get_address(return_value TSRMLS_CC);
1007 sobj->surface = cairo_surface_reference(cairo_get_target(curr->context));
1010 /* }}} get_target */
1014 /* {{{ proto float get_tolerance()
1016 PHP_METHOD(CairoContext, get_tolerance)
1018 zend_class_entry * _this_ce;
1020 zval * _this_zval = NULL;
1021 double tolerance;
1024 if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "O", &_this_zval, CairoContext_ce_ptr) == FAILURE) {
1025 return;
1028 _this_ce = Z_OBJCE_P(_this_zval);
1029 context_object *curr=(context_object *)zend_objects_get_address(_this_zval TSRMLS_CC);
1031 tolerance = cairo_get_tolerance(curr->context);
1032 RETURN_DOUBLE(tolerance);
1034 /* }}} get_tolerance */
1038 /* {{{ proto array glyph_extents(array obj,int num) --need to check
1040 PHP_METHOD(CairoContext, glyph_extents)
1042 zend_class_entry * _this_ce;
1043 int i;
1044 zval * _this_zval = NULL;
1045 zval * obj = NULL;
1046 long num = -1;
1047 cairo_glyph_t *glyphs=NULL , *glyph;
1048 HashTable *obj_hash = NULL;
1049 cairo_text_extents_t extents;
1051 if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "Oa/l", &_this_zval, CairoContext_ce_ptr, &obj, &num) == FAILURE) {
1052 return;
1054 obj_hash = HASH_OF(obj);
1056 glyphs = emalloc(num*sizeof(cairo_glyph_t));
1057 for(i=0 , glyph=glyphs; i<num; i++, glyph++) {
1058 zend_hash_get_current_data(obj_hash, (void **)&glyph);
1059 zend_hash_move_forward(obj_hash);
1062 _this_ce = Z_OBJCE_P(_this_zval);
1063 context_object *curr=(context_object *)zend_objects_get_address(_this_zval TSRMLS_CC);
1065 cairo_glyph_extents(curr->context, glyphs, num, &extents);
1067 array_init(return_value);
1068 add_assoc_double(return_value, "x_bearing", extents.x_bearing);
1069 add_assoc_double(return_value, "y_bearing", extents.y_bearing);
1070 add_assoc_double(return_value, "width", extents.width);
1071 add_assoc_double(return_value, "height", extents.height);
1072 add_assoc_double(return_value, "x_advance", extents.x_advance);
1073 add_assoc_double(return_value, "y_advance", extents.y_advance);
1076 /* }}} glyph_extents */
1080 /* {{{ proto void glyph_path(object obh , int num])
1082 PHP_METHOD(CairoContext, glyph_path)
1084 zend_class_entry * _this_ce;
1085 int i;
1086 zval * _this_zval = NULL;
1087 zval * obh = NULL;
1088 long num = 0;
1089 cairo_glyph_t *glyphs=NULL , *glyph;
1090 HashTable *obj_hash = NULL;
1091 cairo_text_extents_t extents;
1093 if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "Oa/l", &_this_zval, CairoContext_ce_ptr, &obh, &num) == FAILURE) {
1094 return;
1097 _this_ce = Z_OBJCE_P(_this_zval);
1098 context_object *curr=(context_object *)zend_objects_get_address(_this_zval TSRMLS_CC);
1099 obj_hash = HASH_OF(obh);
1101 glyphs = emalloc(num*sizeof(cairo_glyph_t));
1102 for(i=0 , glyph=glyphs; i<num; i++, glyph++) {
1103 zend_hash_get_current_data(obj_hash, (void **)&glyph);
1104 zend_hash_move_forward(obj_hash);
1106 cairo_glyph_path(curr->context, glyphs, num);
1107 phpCAIRO_CONTEXT_ERROR(curr->context);
1110 /* }}} glyph_path */
1114 /* {{{ proto bool has_current_point() -- Need to remove this and put it in path
1116 PHP_METHOD(CairoContext, has_current_point)
1118 zend_class_entry * _this_ce;
1120 zval * _this_zval = NULL;
1124 if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "O", &_this_zval, CairoContext_ce_ptr) == FAILURE) {
1125 return;
1128 _this_ce = Z_OBJCE_P(_this_zval);
1129 context_object *curr=(context_object *)zend_objects_get_address(_this_zval TSRMLS_CC);
1132 do {
1133 /* ONLY for CAIRO 1.6 */
1134 } while (0);
1136 /* }}} has_current_point */
1140 /* {{{ proto void identity_matrix()
1142 PHP_METHOD(CairoContext, identity_matrix)
1144 zend_class_entry * _this_ce;
1146 zval * _this_zval = NULL;
1150 if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "O", &_this_zval, CairoContext_ce_ptr) == FAILURE) {
1151 return;
1154 _this_ce = Z_OBJCE_P(_this_zval);
1155 context_object *curr=(context_object *)zend_objects_get_address(_this_zval TSRMLS_CC);
1156 cairo_identity_matrix(curr->context);
1158 phpCAIRO_CONTEXT_ERROR(curr->context);
1161 /* }}} identity_matrix */
1165 /* {{{ proto bool in_fill(float x, float y)
1167 PHP_METHOD(CairoContext, in_fill)
1169 zend_class_entry * _this_ce;
1171 zval * _this_zval = NULL;
1172 double x = 0.0;
1173 double y = 0.0;
1174 int result;
1177 if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "Odd", &_this_zval, CairoContext_ce_ptr, &x, &y) == FAILURE) {
1178 return;
1181 _this_ce = Z_OBJCE_P(_this_zval);
1182 context_object *curr=(context_object *)zend_objects_get_address(_this_zval TSRMLS_CC);
1184 result = cairo_in_fill(curr->context, x, y);
1186 if(result)
1187 zval_bool(return_value,1);
1188 else
1189 zval_bool(return_value,0);
1193 /* }}} in_fill */
1197 /* {{{ proto bool in_stroke(float x, float y)
1199 PHP_METHOD(CairoContext, in_stroke)
1201 zend_class_entry * _this_ce;
1203 zval * _this_zval = NULL;
1204 double x = 0.0;
1205 double y = 0.0;
1206 int result;
1209 if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "Odd", &_this_zval, CairoContext_ce_ptr, &x, &y) == FAILURE) {
1210 return;
1213 _this_ce = Z_OBJCE_P(_this_zval);
1214 context_object *curr=(context_object *)zend_objects_get_address(_this_zval TSRMLS_CC);
1216 result = cairo_in_stroke(curr->context, x, y);
1218 if(result)
1219 zval_bool(return_value,1);
1220 else
1221 zval_bool(return_value,0);
1224 /* }}} in_stroke */
1228 /* {{{ proto void line_to(float x, float y)
1230 PHP_METHOD(CairoContext, line_to)
1232 zend_class_entry * _this_ce;
1234 zval * _this_zval = NULL;
1235 double x = 0.0;
1236 double y = 0.0;
1240 if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "Odd", &_this_zval, CairoContext_ce_ptr, &x, &y) == FAILURE) {
1241 return;
1244 _this_ce = Z_OBJCE_P(_this_zval);
1245 context_object *curr=(context_object *)zend_objects_get_address(_this_zval TSRMLS_CC);
1247 cairo_line_to(curr->context, x, y);
1248 phpCAIRO_CONTEXT_ERROR(curr->context);
1251 /* }}} line_to */
1255 /* {{{ proto void mask(object p)
1257 PHP_METHOD(CairoContext, mask)
1259 zend_class_entry * _this_ce;
1261 zval * _this_zval = NULL;
1262 zval * p = NULL;
1266 if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "Oo", &_this_zval, CairoContext_ce_ptr, &p) == FAILURE) {
1267 return;
1270 _this_ce = Z_OBJCE_P(_this_zval);
1271 context_object *curr=(context_object *)zend_objects_get_address(_this_zval TSRMLS_CC);
1273 pattern_object *ptobj = (pattern_object *)zend_objects_get_address(p TSRMLS_CC);
1274 cairo_mask(curr->context, ptobj->pattern);
1275 phpCAIRO_CONTEXT_ERROR(curr->context);
1278 /* }}} mask */
1282 /* {{{ proto void mask_surface(object s[,float surface_x, float surface_y])
1284 PHP_METHOD(CairoContext, mask_surface)
1286 zend_class_entry * _this_ce;
1288 zval * _this_zval = NULL;
1289 zval * s = NULL;
1290 double surface_x = 0.0;
1291 double surface_y = 0.0;
1295 if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "Oo|dd", &_this_zval, CairoContext_ce_ptr, &s, &surface_x, &surface_y) == FAILURE) {
1296 return;
1299 _this_ce = Z_OBJCE_P(_this_zval);
1300 context_object *curr=(context_object *)zend_objects_get_address(_this_zval TSRMLS_CC);
1301 surface_object *sobj=(surface_object *)zend_objects_get_address(s TSRMLS_CC);
1302 cairo_mask_surface(curr->context, sobj->surface, surface_x, surface_y);
1303 phpCAIRO_CONTEXT_ERROR(curr->context);
1307 /* }}} mask_surface */
1311 /* {{{ proto void move_to(float x, float y)
1313 PHP_METHOD(CairoContext, move_to)
1315 zend_class_entry * _this_ce;
1317 zval * _this_zval = NULL;
1318 double x = 0.0;
1319 double y = 0.0;
1323 if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "Odd", &_this_zval, CairoContext_ce_ptr, &x, &y) == FAILURE) {
1324 return;
1327 _this_ce = Z_OBJCE_P(_this_zval);
1328 context_object *curr=(context_object *)zend_objects_get_address(_this_zval TSRMLS_CC);
1330 cairo_move_to(curr->context, x, y);
1331 phpCAIRO_CONTEXT_ERROR(curr->context);
1334 /* }}} move_to */
1338 /* {{{ proto void new_path()
1340 PHP_METHOD(CairoContext, new_path)
1342 zend_class_entry * _this_ce;
1344 zval * _this_zval = NULL;
1348 if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "O", &_this_zval, CairoContext_ce_ptr) == FAILURE) {
1349 return;
1352 _this_ce = Z_OBJCE_P(_this_zval);
1353 context_object *curr=(context_object *)zend_objects_get_address(_this_zval TSRMLS_CC);
1354 cairo_new_path(curr->context);
1355 phpCAIRO_CONTEXT_ERROR(curr->context);
1358 /* }}} new_path */
1362 /* {{{ proto void new_sub_path()
1364 PHP_METHOD(CairoContext, new_sub_path)
1366 zend_class_entry * _this_ce;
1368 zval * _this_zval = NULL;
1372 if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "O", &_this_zval, CairoContext_ce_ptr) == FAILURE) {
1373 return;
1376 _this_ce = Z_OBJCE_P(_this_zval);
1377 context_object *curr=(context_object *)zend_objects_get_address(_this_zval TSRMLS_CC);
1379 cairo_new_sub_path(curr->context);
1380 phpCAIRO_CONTEXT_ERROR(curr->context);
1382 /* }}} new_sub_path */
1386 /* {{{ proto void paint()
1388 PHP_METHOD(CairoContext, paint)
1390 zend_class_entry * _this_ce;
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 _this_ce = Z_OBJCE_P(_this_zval);
1401 context_object *curr=(context_object *)zend_objects_get_address(_this_zval TSRMLS_CC);
1402 cairo_paint(curr->context);
1403 phpCAIRO_CONTEXT_ERROR(curr->context);
1407 /* }}} paint */
1411 /* {{{ proto void paint_with_alpha(float alpha)
1413 PHP_METHOD(CairoContext, paint_with_alpha)
1415 zend_class_entry * _this_ce;
1417 zval * _this_zval = NULL;
1418 double alpha = 0.0;
1422 if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "Od", &_this_zval, CairoContext_ce_ptr, &alpha) == FAILURE) {
1423 return;
1426 _this_ce = Z_OBJCE_P(_this_zval);
1427 context_object *curr=(context_object *)zend_objects_get_address(_this_zval TSRMLS_CC);
1428 cairo_paint_with_alpha(curr->context, alpha);
1432 /* }}} paint_with_alpha */
1436 /* {{{ proto array path_extents([object path]) --- need to shift it to path --
1438 PHP_METHOD(CairoContext, path_extents)
1440 zend_class_entry * _this_ce;
1442 zval * _this_zval = NULL;
1443 zval * path = NULL;
1447 if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "O|o", &_this_zval, CairoContext_ce_ptr, &path) == FAILURE) {
1448 return;
1451 _this_ce = Z_OBJCE_P(_this_zval);
1452 context_object *curr=(context_object *)zend_objects_get_address(_this_zval TSRMLS_CC);
1455 array_init(return_value);
1457 do {
1458 /* ONLY for CAIRO 1.6 */
1459 } while (0);
1461 /* }}} path_extents */
1465 /* {{{ proto object pop_group()
1467 PHP_METHOD(CairoContext, pop_group)
1469 zend_class_entry * _this_ce;
1471 zval * _this_zval = NULL;
1475 if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "O", &_this_zval, CairoContext_ce_ptr) == FAILURE) {
1476 return;
1479 _this_ce = Z_OBJCE_P(_this_zval);
1480 context_object *curr=(context_object *)zend_objects_get_address(_this_zval TSRMLS_CC);
1482 object_init(return_value);
1483 pattern_object *ptobj=(pattern_object *)zend_objects_get_address(return_value TSRMLS_CC);
1484 ptobj->pattern = cairo_pop_group(curr->context);
1487 /* }}} pop_group */
1491 /* {{{ proto void pop_group_to_source()
1493 PHP_METHOD(CairoContext, pop_group_to_source)
1495 zend_class_entry * _this_ce;
1497 zval * _this_zval = NULL;
1501 if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "O", &_this_zval, CairoContext_ce_ptr) == FAILURE) {
1502 return;
1505 _this_ce = Z_OBJCE_P(_this_zval);
1506 context_object *curr=(context_object *)zend_objects_get_address(_this_zval TSRMLS_CC);
1507 cairo_pop_group_to_source(curr->context);
1508 phpCAIRO_CONTEXT_ERROR(curr->context);
1512 /* }}} pop_group_to_source */
1516 /* {{{ proto void push_group()
1518 PHP_METHOD(CairoContext, push_group)
1520 zend_class_entry * _this_ce;
1522 zval * _this_zval = NULL;
1526 if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "O", &_this_zval, CairoContext_ce_ptr) == FAILURE) {
1527 return;
1530 _this_ce = Z_OBJCE_P(_this_zval);
1531 context_object *curr=(context_object *)zend_objects_get_address(_this_zval TSRMLS_CC);
1532 cairo_push_group(curr->context);
1533 phpCAIRO_CONTEXT_ERROR(curr->context);
1537 /* }}} push_group */
1541 /* {{{ proto void push_group_with_content(int content)
1543 PHP_METHOD(CairoContext, push_group_with_content)
1545 zend_class_entry * _this_ce;
1547 zval * _this_zval = NULL;
1548 cairo_content_t content;
1552 if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "Ol", &_this_zval, CairoContext_ce_ptr, &content) == FAILURE) {
1553 return;
1556 _this_ce = Z_OBJCE_P(_this_zval);
1557 context_object *curr=(context_object *)zend_objects_get_address(_this_zval TSRMLS_CC);
1558 cairo_push_group_with_content(curr->context, content);
1559 phpCAIRO_CONTEXT_ERROR(curr->context);
1562 /* }}} push_group_with_content */
1566 /* {{{ proto void rectangle(float x, float y, float width, float height)
1568 PHP_METHOD(CairoContext, rectangle)
1570 zend_class_entry * _this_ce;
1572 zval * _this_zval = NULL;
1573 double x = 0.0;
1574 double y = 0.0;
1575 double width = 0.0;
1576 double height = 0.0;
1580 if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "Odddd", &_this_zval, CairoContext_ce_ptr, &x, &y, &width, &height) == FAILURE) {
1581 return;
1584 _this_ce = Z_OBJCE_P(_this_zval);
1585 context_object *curr=(context_object *)zend_objects_get_address(_this_zval TSRMLS_CC);
1586 cairo_rectangle(curr->context, x, y, width, height);
1587 phpCAIRO_CONTEXT_ERROR(curr->context);
1591 /* }}} rectangle */
1595 /* {{{ proto void rel_curve_to(float x1, float y1, float x2, float y2, float x3, float y3)
1597 PHP_METHOD(CairoContext, rel_curve_to)
1599 zend_class_entry * _this_ce;
1601 zval * _this_zval = NULL;
1602 double x1 = 0.0;
1603 double y1 = 0.0;
1604 double x2 = 0.0;
1605 double y2 = 0.0;
1606 double x3 = 0.0;
1607 double y3 = 0.0;
1611 if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "Odddddd", &_this_zval, CairoContext_ce_ptr, &x1, &y1, &x2, &y2, &x3, &y3) == FAILURE) {
1612 return;
1615 _this_ce = Z_OBJCE_P(_this_zval);
1616 context_object *curr=(context_object *)zend_objects_get_address(_this_zval TSRMLS_CC);
1617 cairo_rel_curve_to(curr->context, x1, y1, x2, y2, x3, y3);
1618 phpCAIRO_CONTEXT_ERROR(curr->context);
1621 /* }}} rel_curve_to */
1625 /* {{{ proto void rel_line_to(float x, float y)
1627 PHP_METHOD(CairoContext, rel_line_to)
1629 zend_class_entry * _this_ce;
1631 zval * _this_zval = NULL;
1632 double x = 0.0;
1633 double y = 0.0;
1637 if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "Odd", &_this_zval, CairoContext_ce_ptr, &x, &y) == FAILURE) {
1638 return;
1641 _this_ce = Z_OBJCE_P(_this_zval);
1642 context_object *curr=(context_object *)zend_objects_get_address(_this_zval TSRMLS_CC);
1643 cairo_rel_line_to(curr->context, x, y);
1644 phpCAIRO_CONTEXT_ERROR(curr->context);
1647 /* }}} rel_line_to */
1651 /* {{{ proto void rel_move_to(float x, float y)
1653 PHP_METHOD(CairoContext, rel_move_to)
1655 zend_class_entry * _this_ce;
1657 zval * _this_zval = NULL;
1658 double x = 0.0;
1659 double y = 0.0;
1663 if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "Odd", &_this_zval, CairoContext_ce_ptr, &x, &y) == FAILURE) {
1664 return;
1667 _this_ce = Z_OBJCE_P(_this_zval);
1668 context_object *curr=(context_object *)zend_objects_get_address(_this_zval TSRMLS_CC);
1669 cairo_rel_move_to(curr->context, x, y);
1670 phpCAIRO_CONTEXT_ERROR(curr->context);
1672 /* }}} rel_move_to */
1676 /* {{{ proto void reset_clip()
1678 PHP_METHOD(CairoContext, reset_clip)
1680 zend_class_entry * _this_ce;
1682 zval * _this_zval = NULL;
1686 if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "O", &_this_zval, CairoContext_ce_ptr) == FAILURE) {
1687 return;
1690 _this_ce = Z_OBJCE_P(_this_zval);
1691 context_object *curr=(context_object *)zend_objects_get_address(_this_zval TSRMLS_CC);
1692 cairo_reset_clip(curr->context);
1693 phpCAIRO_CONTEXT_ERROR(curr->context);
1697 /* }}} reset_clip */
1701 /* {{{ proto void restore()
1703 PHP_METHOD(CairoContext, restore)
1705 zend_class_entry * _this_ce;
1707 zval * _this_zval = NULL;
1711 if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "O", &_this_zval, CairoContext_ce_ptr) == FAILURE) {
1712 return;
1715 _this_ce = Z_OBJCE_P(_this_zval);
1716 context_object *curr=(context_object *)zend_objects_get_address(_this_zval TSRMLS_CC);
1718 cairo_restore(curr->context);
1719 phpCAIRO_CONTEXT_ERROR(curr->context);
1723 /* }}} restore */
1727 /* {{{ proto void rotate(float angle)
1729 PHP_METHOD(CairoContext, rotate)
1731 zend_class_entry * _this_ce;
1733 zval * _this_zval = NULL;
1734 double angle = 0.0;
1738 if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "Od", &_this_zval, CairoContext_ce_ptr, &angle) == FAILURE) {
1739 return;
1742 _this_ce = Z_OBJCE_P(_this_zval);
1743 context_object *curr=(context_object *)zend_objects_get_address(_this_zval TSRMLS_CC);
1744 cairo_rotate(curr->context, angle);
1745 phpCAIRO_CONTEXT_ERROR(curr->context);
1748 /* }}} rotate */
1752 /* {{{ proto void save()
1754 PHP_METHOD(CairoContext, save)
1756 zend_class_entry * _this_ce;
1758 zval * _this_zval = NULL;
1762 if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "O", &_this_zval, CairoContext_ce_ptr) == FAILURE) {
1763 return;
1766 _this_ce = Z_OBJCE_P(_this_zval);
1767 context_object *curr=(context_object *)zend_objects_get_address(_this_zval TSRMLS_CC);
1769 cairo_save(curr->context);
1770 phpCAIRO_CONTEXT_ERROR(curr->context);
1773 /* }}} save */
1777 /* {{{ proto void scale(float x, float y)
1779 PHP_METHOD(CairoContext, scale)
1781 zend_class_entry * _this_ce;
1783 zval * _this_zval = NULL;
1784 double x = 0.0;
1785 double y = 0.0;
1789 if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "Odd", &_this_zval, CairoContext_ce_ptr, &x, &y) == FAILURE) {
1790 return;
1793 _this_ce = Z_OBJCE_P(_this_zval);
1794 context_object *curr=(context_object *)zend_objects_get_address(_this_zval TSRMLS_CC);
1796 cairo_scale(curr->context, x, y);
1797 phpCAIRO_CONTEXT_ERROR(curr->context);
1801 /* }}} scale */
1805 /* {{{ proto void select_font_face(object obj[, int slant, int weight])
1807 PHP_METHOD(CairoContext, select_font_face)
1809 zend_class_entry * _this_ce;
1811 zval * _this_zval = NULL;
1812 const char * family = NULL;
1813 int family_len = 0;
1814 cairo_font_slant_t slant = CAIRO_FONT_SLANT_NORMAL;
1815 cairo_font_weight_t weight = CAIRO_FONT_WEIGHT_NORMAL;
1819 if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "Os|ll", &_this_zval, CairoContext_ce_ptr, &family, &family_len, &slant, &weight) == FAILURE) {
1820 return;
1823 _this_ce = Z_OBJCE_P(_this_zval);
1824 context_object *curr=(context_object *)zend_objects_get_address(_this_zval TSRMLS_CC);
1825 cairo_select_font_face(curr->context, family, slant, weight);
1826 phpCAIRO_CONTEXT_ERROR(curr->context);
1829 /* }}} select_font_face */
1833 /* {{{ proto void set_antialias([int antialias])
1835 PHP_METHOD(CairoContext, set_antialias)
1837 zend_class_entry * _this_ce;
1839 zval * _this_zval = NULL;
1840 cairo_antialias_t antialias = CAIRO_ANTIALIAS_DEFAULT;
1844 if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "O|l", &_this_zval, CairoContext_ce_ptr, &antialias) == FAILURE) {
1845 return;
1848 _this_ce = Z_OBJCE_P(_this_zval);
1849 context_object *curr=(context_object *)zend_objects_get_address(_this_zval TSRMLS_CC);
1850 cairo_set_antialias(curr->context, antialias);
1851 phpCAIRO_CONTEXT_ERROR(curr->context);
1854 /* }}} set_antialias */
1858 /* {{{ proto void set_dash(array dashes, int num_dashes [,float offset])
1860 PHP_METHOD(CairoContext, set_dash)
1862 zend_class_entry * _this_ce;
1863 double *das;
1864 zval * _this_zval = NULL;
1865 zval * dashes = NULL;
1866 long num_dashes = 0;
1867 HashTable *dashes_hash = NULL;
1868 double offset = 0.0;
1869 int i;
1872 if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "Oa/l|d", &_this_zval, CairoContext_ce_ptr, &dashes, &offset) == FAILURE) {
1873 return;
1875 dashes_hash = HASH_OF(dashes);
1876 das = emalloc(num_dashes * sizeof(double));
1877 _this_ce = Z_OBJCE_P(_this_zval);
1878 context_object *curr=(context_object *)zend_objects_get_address(_this_zval TSRMLS_CC);
1880 for(i=0; i<num_dashes; i++) {
1881 zend_hash_get_current_data(dashes_hash, (void **)&das[i]);
1882 zend_hash_move_forward(dashes_hash);
1884 cairo_set_dash(curr->context, das, num_dashes, offset);
1885 phpCAIRO_CONTEXT_ERROR(curr->context);
1889 /* }}} set_dash */
1893 /* {{{ proto void set_fill_rule(int fill_rule)
1895 PHP_METHOD(CairoContext, set_fill_rule)
1897 zend_class_entry * _this_ce;
1899 zval * _this_zval = NULL;
1900 cairo_fill_rule_t fill_rule = 0;
1904 if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "Ol", &_this_zval, CairoContext_ce_ptr, &fill_rule) == FAILURE) {
1905 return;
1908 _this_ce = Z_OBJCE_P(_this_zval);
1909 context_object *curr=(context_object *)zend_objects_get_address(_this_zval TSRMLS_CC);
1910 cairo_set_fill_rule(curr->context, fill_rule);
1911 phpCAIRO_CONTEXT_ERROR(curr->context);
1913 /* }}} set_fill_rule */
1917 /* {{{ proto void set_font_face([object obj])
1919 PHP_METHOD(CairoContext, set_font_face)
1921 zend_class_entry * _this_ce;
1923 zval * _this_zval = NULL;
1924 zval * obj = NULL;
1928 if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "O|o", &_this_zval, CairoContext_ce_ptr, &obj) == FAILURE) {
1929 return;
1932 _this_ce = Z_OBJCE_P(_this_zval);
1933 context_object *curr=(context_object *)zend_objects_get_address(_this_zval TSRMLS_CC);
1934 if (obj != NULL) {
1935 fontface_object *ffobj = (fontface_object *)zend_objects_get_address(obj TSRMLS_CC);
1936 cairo_set_font_face(curr->context, ffobj->fontface);
1938 else
1939 cairo_set_font_face(curr->context, NULL);
1940 phpCAIRO_CONTEXT_ERROR(curr->context);
1944 /* }}} set_font_face */
1948 /* {{{ proto void set_font_matrix(object matrix)
1950 PHP_METHOD(CairoContext, set_font_matrix)
1952 zend_class_entry * _this_ce;
1954 zval * _this_zval = NULL;
1955 zval * matrix = NULL;
1959 if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "Oo", &_this_zval, CairoContext_ce_ptr, &matrix) == FAILURE) {
1960 return;
1963 _this_ce = Z_OBJCE_P(_this_zval);
1964 context_object *curr=(context_object *)zend_objects_get_address(_this_zval TSRMLS_CC);
1965 matrix_object *mobj=(matrix_object *)zend_objects_get_address(matrix TSRMLS_CC);
1966 cairo_set_font_matrix(curr->context, &mobj->matrix);
1967 phpCAIRO_CONTEXT_ERROR(curr->context);
1970 /* }}} set_font_matrix */
1974 /* {{{ proto void set_font_options(object options)
1976 PHP_METHOD(CairoContext, set_font_options)
1978 zend_class_entry * _this_ce;
1980 zval * _this_zval = NULL;
1981 zval * options = NULL;
1985 if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "Oo", &_this_zval, CairoContext_ce_ptr, &options) == FAILURE) {
1986 return;
1989 _this_ce = Z_OBJCE_P(_this_zval);
1990 context_object *curr=(context_object *)zend_objects_get_address(_this_zval TSRMLS_CC);
1991 fontoptions_object *foobj=(fontoptions_object *)zend_objects_get_address(options TSRMLS_CC);
1992 cairo_set_font_options(curr->context, foobj->fontoptions);
1993 phpCAIRO_CONTEXT_ERROR(curr->context);
1997 /* }}} set_font_options */
2001 /* {{{ proto void set_font_size(float size)
2003 PHP_METHOD(CairoContext, set_font_size)
2005 zend_class_entry * _this_ce;
2007 zval * _this_zval = NULL;
2008 double size = 0.0;
2012 if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "Od", &_this_zval, CairoContext_ce_ptr, &size) == FAILURE) {
2013 return;
2016 _this_ce = Z_OBJCE_P(_this_zval);
2017 context_object *curr=(context_object *)zend_objects_get_address(_this_zval TSRMLS_CC);
2018 cairo_set_font_size(curr->context, size);
2019 phpCAIRO_CONTEXT_ERROR(curr->context);
2022 /* }}} set_font_size */
2026 /* {{{ proto void set_line_cap(int line_cap)
2028 PHP_METHOD(CairoContext, set_line_cap)
2030 zend_class_entry * _this_ce;
2032 zval * _this_zval = NULL;
2033 long line_cap = 0;
2037 if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "Ol", &_this_zval, CairoContext_ce_ptr, &line_cap) == FAILURE) {
2038 return;
2041 _this_ce = Z_OBJCE_P(_this_zval);
2042 context_object *curr=(context_object *)zend_objects_get_address(_this_zval TSRMLS_CC);
2043 cairo_set_line_cap(curr->context, line_cap);
2044 phpCAIRO_CONTEXT_ERROR(curr->context);
2049 /* }}} set_line_cap */
2053 /* {{{ proto void set_line_join(int line_join)
2055 PHP_METHOD(CairoContext, set_line_join)
2057 zend_class_entry * _this_ce;
2059 zval * _this_zval = NULL;
2060 long line_join = 0;
2064 if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "Ol", &_this_zval, CairoContext_ce_ptr, &line_join) == FAILURE) {
2065 return;
2068 _this_ce = Z_OBJCE_P(_this_zval);
2069 context_object *curr=(context_object *)zend_objects_get_address(_this_zval TSRMLS_CC);
2071 cairo_set_line_join(curr->context, line_join);
2072 phpCAIRO_CONTEXT_ERROR(curr->context);
2075 /* }}} set_line_join */
2079 /* {{{ proto void set_line_width(float width)
2081 PHP_METHOD(CairoContext, set_line_width)
2083 zend_class_entry * _this_ce;
2085 zval * _this_zval = NULL;
2086 double width = 0.0;
2090 if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "Od", &_this_zval, CairoContext_ce_ptr, &width) == FAILURE) {
2091 return;
2094 _this_ce = Z_OBJCE_P(_this_zval);
2095 context_object *curr = (context_object *)zend_objects_get_address(_this_zval TSRMLS_CC);
2096 cairo_set_line_width(curr->context, width);
2098 /* }}} set_line_width */
2102 /* {{{ proto void set_matrix(object matix)
2104 PHP_METHOD(CairoContext, set_matrix)
2106 zend_class_entry * _this_ce;
2108 zval * _this_zval = NULL;
2109 zval * matix = NULL;
2113 if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "Oo", &_this_zval, CairoContext_ce_ptr, &matix) == FAILURE) {
2114 return;
2117 _this_ce = Z_OBJCE_P(_this_zval);
2118 context_object *curr=(context_object *)zend_objects_get_address(_this_zval TSRMLS_CC);
2119 matrix_object *mobj=(matrix_object *)zend_objects_get_address(matix TSRMLS_CC);
2120 cairo_set_matrix(curr->context, &mobj->matrix);
2121 phpCAIRO_CONTEXT_ERROR(curr->context);
2124 /* }}} set_matrix */
2128 /* {{{ proto void set_miter_limit(float limit)
2130 PHP_METHOD(CairoContext, set_miter_limit)
2132 zend_class_entry * _this_ce;
2134 zval * _this_zval = NULL;
2135 double limit = 0.0;
2139 if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "Od", &_this_zval, CairoContext_ce_ptr, &limit) == FAILURE) {
2140 return;
2143 _this_ce = Z_OBJCE_P(_this_zval);
2144 context_object *curr=(context_object *)zend_objects_get_address(_this_zval TSRMLS_CC);
2145 cairo_set_mitter_limit(curr->context, limit);
2146 phpCAIRO_CONTEXT_ERROR(curr->context);
2149 /* }}} set_miter_limit */
2153 /* {{{ proto void set_operator(int op)
2155 PHP_METHOD(CairoContext, set_operator)
2157 zend_class_entry * _this_ce;
2159 zval * _this_zval = NULL;
2160 long op = 0;
2164 if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "Ol", &_this_zval, CairoContext_ce_ptr, &op) == FAILURE) {
2165 return;
2168 _this_ce = Z_OBJCE_P(_this_zval);
2169 context_object *curr=(context_object *)zend_objects_get_address(_this_zval TSRMLS_CC);
2170 cairo_set_operator(curr->context, op);
2171 phpCAIRO_CONTEXT_ERROR(curr->context);
2174 /* }}} set_operator */
2178 /* {{{ proto void set_source(object p)
2180 PHP_METHOD(CairoContext, set_source)
2182 zend_class_entry * _this_ce;
2184 zval * _this_zval = NULL;
2185 zval * p = NULL;
2189 if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "Oo", &_this_zval, CairoContext_ce_ptr, &p) == FAILURE) {
2190 return;
2193 _this_ce = Z_OBJCE_P(_this_zval);
2194 context_object *curr=(context_object *)zend_objects_get_address(_this_zval TSRMLS_CC);
2195 pattern_object *ptobj=(pattern_object *)zend_objects_get_address(p TSRMLS_CC);
2196 cairo_set_source(curr->context, ptobj->pattern);
2197 phpCAIRO_CONTEXT_ERROR(curr->context);
2200 /* }}} set_source */
2204 /* {{{ proto void set_source_rgb(float red, float green, float blue)
2206 PHP_METHOD(CairoContext, set_source_rgb)
2208 zend_class_entry * _this_ce;
2210 zval * _this_zval = NULL;
2211 double red = 0.0;
2212 double green = 0.0;
2213 double blue = 0.0;
2217 if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "Oddd", &_this_zval, CairoContext_ce_ptr, &red, &green, &blue) == FAILURE) {
2218 return;
2221 _this_ce = Z_OBJCE_P(_this_zval);
2222 context_object *curr=(context_object *)zend_objects_get_address(_this_zval TSRMLS_CC);
2223 cairo_set_source_rgb(curr->context, red, green, blue);
2224 phpCAIRO_CONTEXT_ERROR(curr->context);
2227 /* }}} set_source_rgb */
2231 /* {{{ proto void set_source_rgba(float red, float green, float blue [,float alpha])
2233 PHP_METHOD(CairoContext, set_source_rgba)
2235 zend_class_entry * _this_ce;
2237 zval * _this_zval = NULL;
2238 double red = 0.0;
2239 double green = 0.0;
2240 double blue = 0.0;
2241 double alpha = 0.0;
2245 if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "Oddd|d", &_this_zval, CairoContext_ce_ptr, &red, &green, &blue, &alpha) == FAILURE) {
2246 return;
2249 _this_ce = Z_OBJCE_P(_this_zval);
2250 context_object *curr=(context_object *)zend_objects_get_address(_this_zval TSRMLS_CC);
2251 cairo_set_source_rgba(curr->context, red, green, blue, alpha);
2252 phpCAIRO_CONTEXT_ERROR(curr->context);
2255 /* }}} set_source_rgba */
2259 /* {{{ proto void set_source_surface(object surface [,float x, float y])
2261 PHP_METHOD(CairoContext, set_source_surface)
2263 zend_class_entry * _this_ce;
2265 zval * _this_zval = NULL;
2266 zval * surface = NULL;
2267 double x = 0.0;
2268 double y = 0.0;
2272 if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "Oo|dd", &_this_zval, CairoContext_ce_ptr, &surface, &x, &y) == FAILURE) {
2273 return;
2276 _this_ce = Z_OBJCE_P(_this_zval);
2277 context_object *curr=(context_object *)zend_objects_get_address(_this_zval TSRMLS_CC);
2278 surface_object *sobj=(surface_object *)zend_objects_get_address(surface TSRMLS_CC);
2279 cairo_set_source_surface(curr->context, sobj->surface, x, y);
2280 phpCAIRO_CONTEXT_ERROR(curr->context);
2283 /* }}} set_source_surface */
2287 /* {{{ proto void set_tolerance(float tolerance)
2289 PHP_METHOD(CairoContext, set_tolerance)
2291 zend_class_entry * _this_ce;
2293 zval * _this_zval = NULL;
2294 double tolerance = 0.0;
2298 if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "Od", &_this_zval, CairoContext_ce_ptr, &tolerance) == FAILURE) {
2299 return;
2302 _this_ce = Z_OBJCE_P(_this_zval);
2303 context_object *curr=(context_object *)zend_objects_get_address(_this_zval TSRMLS_CC);
2304 cairo_set_tolerance(curr->context, tolerance);
2305 phpCAIRO_CONTEXT_ERROR(curr->context);
2308 /* }}} set_tolerance */
2312 /* {{{ proto void show_glyphs(array obj ,int num_glyphs)
2314 PHP_METHOD(CairoContext, show_glyphs)
2316 zend_class_entry * _this_ce;
2317 int i;
2318 zval * _this_zval = NULL;
2319 zval * obj = NULL;
2320 long num_glyphs = 0;
2321 HashTable *obj_hash = NULL;
2322 cairo_glyph_t *glyphs=NULL, *glyph;
2326 if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "Oa/l", &_this_zval, CairoContext_ce_ptr, &obj, &num_glyphs) == FAILURE) {
2327 return;
2330 _this_ce = Z_OBJCE_P(_this_zval);
2331 context_object *curr=(context_object *)zend_objects_get_address(_this_zval TSRMLS_CC);
2332 obj_hash = HASH_OF(obj);
2334 glyphs = emalloc(num_glyphs*sizeof(cairo_glyph_t));
2335 for(i=0 , glyph=glyphs; i<num_glyphs; i++, glyph++) {
2336 zend_hash_get_current_data(obj_hash, (void **)&glyph);
2337 zend_hash_move_forward(obj_hash);
2340 cairo_show_glyphs(curr->context, glyphs, num_glyphs);
2341 phpCAIRO_CONTEXT_ERROR(curr->context);
2344 /* }}} show_glyphs */
2348 /* {{{ proto void show_page()
2350 PHP_METHOD(CairoContext, show_page)
2352 zend_class_entry * _this_ce;
2354 zval * _this_zval = NULL;
2358 if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "O", &_this_zval, CairoContext_ce_ptr) == FAILURE) {
2359 return;
2362 _this_ce = Z_OBJCE_P(_this_zval);
2363 context_object *curr=(context_object *)zend_objects_get_address(_this_zval TSRMLS_CC);
2364 cairo_show_page(curr->context);
2365 phpCAIRO_CONTEXT_ERROR(curr->context);
2368 /* }}} show_page */
2372 /* {{{ proto void show_text(string obj)
2374 PHP_METHOD(CairoContext, show_text)
2376 zend_class_entry * _this_ce;
2378 zval * _this_zval = NULL;
2379 const char * obj = NULL;
2380 int obj_len = 0;
2384 if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "Os", &_this_zval, CairoContext_ce_ptr, &obj, &obj_len) == FAILURE) {
2385 return;
2388 _this_ce = Z_OBJCE_P(_this_zval);
2389 context_object *curr=(context_object *)zend_objects_get_address(_this_zval TSRMLS_CC);
2390 cairo_show_text(curr->context, obj);
2391 phpCAIRO_CONTEXT_ERROR(curr->context);
2394 /* }}} show_text */
2398 /* {{{ proto void stroke()
2400 PHP_METHOD(CairoContext, stroke)
2402 zend_class_entry * _this_ce;
2404 zval * _this_zval = NULL;
2408 if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "O", &_this_zval, CairoContext_ce_ptr) == FAILURE) {
2409 return;
2412 _this_ce = Z_OBJCE_P(_this_zval);
2413 context_object *curr = (context_object *)zend_objects_get_address(_this_zval TSRMLS_CC);
2414 cairo_stroke(curr->context);
2415 phpCAIRO_CONTEXT_ERROR(curr->context);
2419 /* }}} stroke */
2423 /* {{{ proto array stroke_extents()
2425 PHP_METHOD(CairoContext, stroke_extents)
2427 zend_class_entry * _this_ce;
2429 zval * _this_zval = NULL;
2430 double x1=0, x2=0, y1=0, y2=0;
2434 if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "O", &_this_zval, CairoContext_ce_ptr) == FAILURE) {
2435 return;
2438 _this_ce = Z_OBJCE_P(_this_zval);
2439 context_object *curr=(context_object *)zend_objects_get_address(_this_zval TSRMLS_CC);
2440 cairo_stroke_extents(curr->context, &x1, &y1, &x2, &y2);
2442 array_init(return_value);
2443 add_assoc_double(return_value, "x1", x1);
2444 add_assoc_double(return_value, "y1", y1);
2445 add_assoc_double(return_value, "x2", x2);
2446 add_assoc_double(return_value, "y2", y2);
2449 /* }}} stroke_extents */
2453 /* {{{ proto void stroke_preserve()
2455 PHP_METHOD(CairoContext, stroke_preserve)
2457 zend_class_entry * _this_ce;
2459 zval * _this_zval = NULL;
2463 if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "O", &_this_zval, CairoContext_ce_ptr) == FAILURE) {
2464 return;
2467 _this_ce = Z_OBJCE_P(_this_zval);
2468 context_object *curr=(context_object *)zend_objects_get_address(_this_zval TSRMLS_CC);
2469 cairo_stroke_preserve(curr->context);
2470 phpCAIRO_CONTEXT_ERROR(curr->context);
2473 /* }}} stroke_preserve */
2477 /* {{{ proto array text_extents(string str)
2479 PHP_METHOD(CairoContext, text_extents)
2481 zend_class_entry * _this_ce;
2483 zval * _this_zval = NULL;
2484 const char * str = NULL;
2485 long str_len=0;
2486 cairo_text_extents_t extents;
2489 if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "Os", &_this_zval, CairoContext_ce_ptr, &str, &str_len) == FAILURE) {
2490 return;
2493 _this_ce = Z_OBJCE_P(_this_zval);
2494 context_object *curr=(context_object *)zend_objects_get_address(_this_zval TSRMLS_CC);
2496 cairo_text_extents(curr->context, str, &extents);
2498 array_init(return_value);
2499 add_assoc_double(return_value, "x_bearing", extents.x_bearing);
2500 add_assoc_double(return_value, "y_bearing", extents.y_bearing);
2501 add_assoc_double(return_value, "width", extents.width);
2502 add_assoc_double(return_value, "height", extents.height);
2503 add_assoc_double(return_value, "x_advance", extents.x_advance);
2504 add_assoc_double(return_value, "y_advance", extents.y_advance);
2507 /* }}} text_extents */
2511 /* {{{ proto void text_path(string obj)
2513 PHP_METHOD(CairoContext, text_path)
2515 zend_class_entry * _this_ce;
2517 zval * _this_zval = NULL;
2518 const char * obj = NULL;
2519 long obj_len = 0;
2523 if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "Os", &_this_zval, CairoContext_ce_ptr, &obj, &obj_len) == FAILURE) {
2524 return;
2527 _this_ce = Z_OBJCE_P(_this_zval);
2528 context_object *curr=(context_object *)zend_objects_get_address(_this_zval TSRMLS_CC);
2529 cairo_text_path(curr->context, obj);
2530 phpCAIRO_CONTEXT_ERROR(curr->context);
2533 /* }}} text_path */
2537 /* {{{ proto void transform(object matrix)
2539 PHP_METHOD(CairoContext, transform)
2541 zend_class_entry * _this_ce;
2543 zval * _this_zval = NULL;
2544 zval * matrix = NULL;
2548 if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "Oo", &_this_zval, CairoContext_ce_ptr, &matrix) == FAILURE) {
2549 return;
2552 _this_ce = Z_OBJCE_P(_this_zval);
2553 context_object *curr=(context_object *)zend_objects_get_address(_this_zval TSRMLS_CC);
2554 matrix_object *mobj = (matrix_object *)zend_objects_get_address(matrix TSRMLS_CC);
2555 cairo_transform(curr->context, &mobj->matrix);
2556 phpCAIRO_CONTEXT_ERROR(curr->context);
2559 /* }}} transform */
2563 /* {{{ proto void translate(float tx, float ty)
2565 PHP_METHOD(CairoContext, translate)
2567 zend_class_entry * _this_ce;
2569 zval * _this_zval = NULL;
2570 double tx = 0.0;
2571 double ty = 0.0;
2575 if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "Odd", &_this_zval, CairoContext_ce_ptr, &tx, &ty) == FAILURE) {
2576 return;
2579 _this_ce = Z_OBJCE_P(_this_zval);
2580 context_object *curr=(context_object *)zend_objects_get_address(_this_zval TSRMLS_CC);
2582 cairo_translate(curr->context, tx, ty);
2583 phpCAIRO_CONTEXT_ERROR(curr->context);
2586 /* }}} translate */
2590 /* {{{ proto array user_to_device(float x, float y)
2592 PHP_METHOD(CairoContext, user_to_device)
2594 zend_class_entry * _this_ce;
2596 zval * _this_zval = NULL;
2597 double x = 0.0;
2598 double y = 0.0;
2602 if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "Odd", &_this_zval, CairoContext_ce_ptr, &x, &y) == FAILURE) {
2603 return;
2606 _this_ce = Z_OBJCE_P(_this_zval);
2607 context_object *curr=(context_object *)zend_objects_get_address(_this_zval TSRMLS_CC);
2609 cairo_user_to_device(curr->context, &x, &y);
2610 phpCAIRO_CONTEXT_ERROR(curr->context);
2612 array_init(return_value);
2613 add_assoc_double(return_value, "x", x);
2614 add_assoc_double(return_value, "y", y);
2617 /* }}} user_to_device */
2621 /* {{{ proto array user_to_device_distance(float dx, float dy)
2623 PHP_METHOD(CairoContext, user_to_device_distance)
2625 zend_class_entry * _this_ce;
2627 zval * _this_zval = NULL;
2628 double dx = 0.0;
2629 double dy = 0.0;
2633 if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "Odd", &_this_zval, CairoContext_ce_ptr, &dx, &dy) == FAILURE) {
2634 return;
2637 _this_ce = Z_OBJCE_P(_this_zval);
2638 context_object *curr=(context_object *)zend_objects_get_address(_this_zval TSRMLS_CC);
2639 cairo_user_to_device_distance(curr->context, &dx, &dy);
2640 phpCAIRO_CONTEXT_ERROR(curr->context);
2642 array_init(return_value);
2643 add_assoc_double(return_value, "x", dx);
2644 add_assoc_double(return_value, "y", dy);
2647 /* }}} user_to_device_distance */
2650 static zend_function_entry CairoContext_methods[] = {
2651 PHP_ME(CairoContext, __construct, NULL, /**/ZEND_ACC_PUBLIC | ZEND_ACC_CTOR)
2652 PHP_ME(CairoContext, append_path, CairoContext__append_path_args, /**/ZEND_ACC_PUBLIC)
2653 PHP_ME(CairoContext, arc, CairoContext__arc_args, /**/ZEND_ACC_PUBLIC)
2654 PHP_ME(CairoContext, arc_negative, CairoContext__arc_negative_args, /**/ZEND_ACC_PUBLIC)
2655 PHP_ME(CairoContext, clip, NULL, /**/ZEND_ACC_PUBLIC)
2656 PHP_ME(CairoContext, clip_extents, NULL, /**/ZEND_ACC_PUBLIC)
2657 PHP_ME(CairoContext, clip_preserve, NULL, /**/ZEND_ACC_PUBLIC)
2658 PHP_ME(CairoContext, close_path, NULL, /**/ZEND_ACC_PUBLIC)
2659 PHP_ME(CairoContext, copy_clip_rectangle_list, NULL, /**/ZEND_ACC_PUBLIC)
2660 PHP_ME(CairoContext, copy_page, NULL, /**/ZEND_ACC_PUBLIC)
2661 PHP_ME(CairoContext, copy_path, NULL, /**/ZEND_ACC_PUBLIC)
2662 PHP_ME(CairoContext, copy_path_flat, NULL, /**/ZEND_ACC_PUBLIC)
2663 PHP_ME(CairoContext, curve_to, CairoContext__curve_to_args, /**/ZEND_ACC_PUBLIC)
2664 PHP_ME(CairoContext, device_to_user, CairoContext__device_to_user_args, /**/ZEND_ACC_PUBLIC)
2665 PHP_ME(CairoContext, device_to_user_distance, CairoContext__device_to_user_distance_args, /**/ZEND_ACC_PUBLIC)
2666 PHP_ME(CairoContext, fill, NULL, /**/ZEND_ACC_PUBLIC)
2667 PHP_ME(CairoContext, fill_extents, NULL, /**/ZEND_ACC_PUBLIC)
2668 PHP_ME(CairoContext, fill_preserve, NULL, /**/ZEND_ACC_PUBLIC)
2669 PHP_ME(CairoContext, font_extents, NULL, /**/ZEND_ACC_PUBLIC)
2670 PHP_ME(CairoContext, get_antialias, NULL, /**/ZEND_ACC_PUBLIC)
2671 PHP_ME(CairoContext, get_current_point, NULL, /**/ZEND_ACC_PUBLIC)
2672 PHP_ME(CairoContext, get_dash, NULL, /**/ZEND_ACC_PUBLIC)
2673 PHP_ME(CairoContext, get_dash_count, NULL, /**/ZEND_ACC_PUBLIC)
2674 PHP_ME(CairoContext, get_fill_rule, NULL, /**/ZEND_ACC_PUBLIC)
2675 PHP_ME(CairoContext, get_font_face, NULL, /**/ZEND_ACC_PUBLIC)
2676 PHP_ME(CairoContext, get_font_matrix, NULL, /**/ZEND_ACC_PUBLIC)
2677 PHP_ME(CairoContext, get_font_options, NULL, /**/ZEND_ACC_PUBLIC)
2678 PHP_ME(CairoContext, get_group_target, NULL, /**/ZEND_ACC_PUBLIC)
2679 PHP_ME(CairoContext, get_line_cap, NULL, /**/ZEND_ACC_PUBLIC)
2680 PHP_ME(CairoContext, get_line_join, NULL, /**/ZEND_ACC_PUBLIC)
2681 PHP_ME(CairoContext, get_line_width, NULL, /**/ZEND_ACC_PUBLIC)
2682 PHP_ME(CairoContext, get_matrix, NULL, /**/ZEND_ACC_PUBLIC)
2683 PHP_ME(CairoContext, get_miter_limit, NULL, /**/ZEND_ACC_PUBLIC)
2684 PHP_ME(CairoContext, get_operator, NULL, /**/ZEND_ACC_PUBLIC)
2685 PHP_ME(CairoContext, get_scaled_font, NULL, /**/ZEND_ACC_PUBLIC)
2686 PHP_ME(CairoContext, get_source, NULL, /**/ZEND_ACC_PUBLIC)
2687 PHP_ME(CairoContext, get_target, NULL, /**/ZEND_ACC_PUBLIC)
2688 PHP_ME(CairoContext, get_tolerance, NULL, /**/ZEND_ACC_PUBLIC)
2689 PHP_ME(CairoContext, glyph_extents, CairoContext__glyph_extents_args, /**/ZEND_ACC_PUBLIC)
2690 PHP_ME(CairoContext, glyph_path, CairoContext__glyph_path_args, /**/ZEND_ACC_PUBLIC)
2691 PHP_ME(CairoContext, has_current_point, NULL, /**/ZEND_ACC_PUBLIC)
2692 PHP_ME(CairoContext, identity_matrix, NULL, /**/ZEND_ACC_PUBLIC)
2693 PHP_ME(CairoContext, in_fill, CairoContext__in_fill_args, /**/ZEND_ACC_PUBLIC)
2694 PHP_ME(CairoContext, in_stroke, CairoContext__in_stroke_args, /**/ZEND_ACC_PUBLIC)
2695 PHP_ME(CairoContext, line_to, CairoContext__line_to_args, /**/ZEND_ACC_PUBLIC)
2696 PHP_ME(CairoContext, mask, CairoContext__mask_args, /**/ZEND_ACC_PUBLIC)
2697 PHP_ME(CairoContext, mask_surface, CairoContext__mask_surface_args, /**/ZEND_ACC_PUBLIC)
2698 PHP_ME(CairoContext, move_to, CairoContext__move_to_args, /**/ZEND_ACC_PUBLIC)
2699 PHP_ME(CairoContext, new_path, NULL, /**/ZEND_ACC_PUBLIC)
2700 PHP_ME(CairoContext, new_sub_path, NULL, /**/ZEND_ACC_PUBLIC)
2701 PHP_ME(CairoContext, paint, NULL, /**/ZEND_ACC_PUBLIC)
2702 PHP_ME(CairoContext, paint_with_alpha, CairoContext__paint_with_alpha_args, /**/ZEND_ACC_PUBLIC)
2703 PHP_ME(CairoContext, path_extents, CairoContext__path_extents_args, /**/ZEND_ACC_PUBLIC)
2704 PHP_ME(CairoContext, pop_group, NULL, /**/ZEND_ACC_PUBLIC)
2705 PHP_ME(CairoContext, pop_group_to_source, NULL, /**/ZEND_ACC_PUBLIC)
2706 PHP_ME(CairoContext, push_group, NULL, /**/ZEND_ACC_PUBLIC)
2707 PHP_ME(CairoContext, push_group_with_content, CairoContext__push_group_with_content_args, /**/ZEND_ACC_PUBLIC)
2708 PHP_ME(CairoContext, rectangle, CairoContext__rectangle_args, /**/ZEND_ACC_PUBLIC)
2709 PHP_ME(CairoContext, rel_curve_to, CairoContext__rel_curve_to_args, /**/ZEND_ACC_PUBLIC)
2710 PHP_ME(CairoContext, rel_line_to, CairoContext__rel_line_to_args, /**/ZEND_ACC_PUBLIC)
2711 PHP_ME(CairoContext, rel_move_to, CairoContext__rel_move_to_args, /**/ZEND_ACC_PUBLIC)
2712 PHP_ME(CairoContext, reset_clip, NULL, /**/ZEND_ACC_PUBLIC)
2713 PHP_ME(CairoContext, restore, NULL, /**/ZEND_ACC_PUBLIC)
2714 PHP_ME(CairoContext, rotate, CairoContext__rotate_args, /**/ZEND_ACC_PUBLIC)
2715 PHP_ME(CairoContext, save, NULL, /**/ZEND_ACC_PUBLIC)
2716 PHP_ME(CairoContext, scale, CairoContext__scale_args, /**/ZEND_ACC_PUBLIC)
2717 PHP_ME(CairoContext, select_font_face, CairoContext__select_font_face_args, /**/ZEND_ACC_PUBLIC)
2718 PHP_ME(CairoContext, set_antialias, CairoContext__set_antialias_args, /**/ZEND_ACC_PUBLIC)
2719 PHP_ME(CairoContext, set_dash, CairoContext__set_dash_args, /**/ZEND_ACC_PUBLIC)
2720 PHP_ME(CairoContext, set_fill_rule, CairoContext__set_fill_rule_args, /**/ZEND_ACC_PUBLIC)
2721 PHP_ME(CairoContext, set_font_face, CairoContext__set_font_face_args, /**/ZEND_ACC_PUBLIC)
2722 PHP_ME(CairoContext, set_font_matrix, CairoContext__set_font_matrix_args, /**/ZEND_ACC_PUBLIC)
2723 PHP_ME(CairoContext, set_font_options, CairoContext__set_font_options_args, /**/ZEND_ACC_PUBLIC)
2724 PHP_ME(CairoContext, set_font_size, CairoContext__set_font_size_args, /**/ZEND_ACC_PUBLIC)
2725 PHP_ME(CairoContext, set_line_cap, CairoContext__set_line_cap_args, /**/ZEND_ACC_PUBLIC)
2726 PHP_ME(CairoContext, set_line_join, CairoContext__set_line_join_args, /**/ZEND_ACC_PUBLIC)
2727 PHP_ME(CairoContext, set_line_width, CairoContext__set_line_width_args, /**/ZEND_ACC_PUBLIC)
2728 PHP_ME(CairoContext, set_matrix, CairoContext__set_matrix_args, /**/ZEND_ACC_PUBLIC)
2729 PHP_ME(CairoContext, set_miter_limit, CairoContext__set_miter_limit_args, /**/ZEND_ACC_PUBLIC)
2730 PHP_ME(CairoContext, set_operator, CairoContext__set_operator_args, /**/ZEND_ACC_PUBLIC)
2731 PHP_ME(CairoContext, set_source, CairoContext__set_source_args, /**/ZEND_ACC_PUBLIC)
2732 PHP_ME(CairoContext, set_source_rgb, CairoContext__set_source_rgb_args, /**/ZEND_ACC_PUBLIC)
2733 PHP_ME(CairoContext, set_source_rgba, CairoContext__set_source_rgba_args, /**/ZEND_ACC_PUBLIC)
2734 PHP_ME(CairoContext, set_source_surface, CairoContext__set_source_surface_args, /**/ZEND_ACC_PUBLIC)
2735 PHP_ME(CairoContext, set_tolerance, CairoContext__set_tolerance_args, /**/ZEND_ACC_PUBLIC)
2736 PHP_ME(CairoContext, show_glyphs, CairoContext__show_glyphs_args, /**/ZEND_ACC_PUBLIC)
2737 PHP_ME(CairoContext, show_page, NULL, /**/ZEND_ACC_PUBLIC)
2738 PHP_ME(CairoContext, show_text, CairoContext__show_text_args, /**/ZEND_ACC_PUBLIC)
2739 PHP_ME(CairoContext, stroke, NULL, /**/ZEND_ACC_PUBLIC)
2740 PHP_ME(CairoContext, stroke_extents, NULL, /**/ZEND_ACC_PUBLIC)
2741 PHP_ME(CairoContext, stroke_preserve, NULL, /**/ZEND_ACC_PUBLIC)
2742 PHP_ME(CairoContext, text_extents, CairoContext__text_extents_args, /**/ZEND_ACC_PUBLIC)
2743 PHP_ME(CairoContext, text_path, CairoContext__text_path_args, /**/ZEND_ACC_PUBLIC)
2744 PHP_ME(CairoContext, transform, CairoContext__transform_args, /**/ZEND_ACC_PUBLIC)
2745 PHP_ME(CairoContext, translate, CairoContext__translate_args, /**/ZEND_ACC_PUBLIC)
2746 PHP_ME(CairoContext, user_to_device, CairoContext__user_to_device_args, /**/ZEND_ACC_PUBLIC)
2747 PHP_ME(CairoContext, user_to_device_distance, CairoContext__user_to_device_distance_args, /**/ZEND_ACC_PUBLIC)
2748 { NULL, NULL, NULL }
2751 /* }}} Methods */
2753 static zend_object_handlers CairoContext_handlers;
2756 typedef struct _context_object {
2757 zend_object std;
2758 cairo_t *context;
2759 } context_object;
2762 static void CairoContext_object_dtor(void *object)
2764 context_object *context = (context_object *)object;
2765 zend_hash_destroy(context->std.properties);
2766 FREE_HASHTABLE(context->std.properties);
2768 if(context->context){
2769 cairo_destroy(context->context);
2771 efree(object);
2774 static zend_object_value CairoContext_object_new(zend_class_entry *ce)
2776 zend_object_value retval;
2777 context_object *context;
2778 zval *temp;
2780 context=emalloc(sizeof(context_object));
2781 memset(context,0,sizeof(context_object));
2782 context->std.ce = ce;
2783 ALLOC_HASHTABLE(context->std.properties);
2784 zend_hash_init(context->std.properties, 0, NULL, ZVAL_PTR_DTOR,0);
2785 zend_hash_copy(context->std.properties, &ce->default_properties, (copy_ctor_func_t) zval_add_ref, (void *) &temp, sizeof(zval *));
2786 retval.handle = zend_objects_store_put(context, NULL, (zend_objects_free_object_storage_t)CairoContext_object_dtor, NULL TSRMLS_CC);
2787 retval.handlers = &CairoContext_handlers;
2788 return retval;
2793 static void class_init_CairoContext(void)
2795 zend_class_entry ce;
2796 INIT_CLASS_ENTRY(ce, "CairoContext", CairoContext_methods);
2797 CairoContext_ce_ptr = zend_register_internal_class(&ce);
2798 CairoContext_ce_ptr->create_object = CairoContext_object_new;
2799 memcpy(&CairoContext_handlers, zend_get_std_object_handlers(), sizeof(zend_object_handlers));
2800 CairoContext_handlers.clone_obj=NULL;
2803 /* }}} Class CairoContext */