cvs: php4 /ext/swf/ php_swf.h swf.c
| From: | Sterling Hughes | Date: | Sun, 14 May 2000 18:39:12 +0000 |
| Subject: | cvs: php4 /ext/swf/ php_swf.h swf.c | ||
| Groups: | php.version4 | ||
| Request: | Send a blank email to php-version4+get-15009@lists.php.net to get a copy of this message | ||
sterling Sun May 14 20:39:12 2000 EDT
Modified files:
/php4/ext/swf php_swf.h swf.c
Log:
@-Add swf_definepoly for drawing polygons to the SWF functions. (Sterling)
Index: php4/ext/swf/php_swf.h
diff -u php4/ext/swf/php_swf.h:1.3 php4/ext/swf/php_swf.h:1.4
--- php4/ext/swf/php_swf.h:1.3 Mon May 1 04:42:26 2000
+++ php4/ext/swf/php_swf.h Sun May 14 20:39:11 2000
@@ -16,7 +16,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: php_swf.h,v 1.3 2000/05/01 02:42:26 sas Exp $ */
+/* $Id: php_swf.h,v 1.4 2000/05/14 18:39:11 sterling Exp $ */
#ifndef _PHP_SWF_H
#define _PHP_SWF_H
@@ -62,6 +62,7 @@
PHP_FUNCTION(swf_actiongotolabel);
PHP_FUNCTION(swf_defineline);
PHP_FUNCTION(swf_definerect);
+PHP_FUNCTION(swf_definepoly);
PHP_FUNCTION(swf_startshape);
PHP_FUNCTION(swf_shapelinesolid);
PHP_FUNCTION(swf_shapefilloff);
Index: php4/ext/swf/swf.c
diff -u php4/ext/swf/swf.c:1.6 php4/ext/swf/swf.c:1.7
--- php4/ext/swf/swf.c:1.6 Tue May 2 02:44:26 2000
+++ php4/ext/swf/swf.c Sun May 14 20:39:11 2000
@@ -16,7 +16,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: swf.c,v 1.6 2000/05/02 00:44:26 sas Exp $ */
+/* $Id: swf.c,v 1.7 2000/05/14 18:39:11 sterling Exp $ */
#include "php.h"
@@ -53,6 +53,7 @@
PHP_FE(swf_actiongotolabel, NULL)
PHP_FE(swf_defineline, NULL)
PHP_FE(swf_definerect, NULL)
+ PHP_FE(swf_definepoly, NULL)
PHP_FE(swf_startshape, NULL)
PHP_FE(swf_shapelinesolid, NULL)
PHP_FE(swf_shapefilloff, NULL)
@@ -161,8 +162,9 @@
convert_to_double_ex(g);
convert_to_double_ex(b);
- swf_openfile((*name)->value.str.val, (float)(*sizeX)->value.dval,
(float)(*sizeY)->value.dval,
- (float)(*frameRate)->value.dval, (float)(*r)->value.dval,
(float)(*g)->value.dval, (float)(*b)->value.dval);
+ swf_openfile((*name)->value.str.val,
+ (float)(*sizeX)->value.dval, (float)(*sizeY)->value.dval,
+ (float)(*frameRate)->value.dval, (float)(*r)->value.dval,
(float)(*g)->value.dval, (float)(*b)->value.dval);
}
/* }}} */
@@ -475,6 +477,44 @@
PHP_FUNCTION(swf_definerect)
{
php_swf_define(INTERNAL_FUNCTION_PARAM_PASSTHRU, 0);
+}
+/* }}} */
+
+/* {{{ proto void swf_definepoly(int obj_id, array coords, int npoints, double width)
+ Define a Polygon from an array of x,y coordinates, coords. */
+PHP_FUNCTION(swf_definepoly)
+{
+ zval **obj_id, **coordinates, **NumPoints, **width, **var;
+ int npoints, i;
+ float coords[256][2];
+
+ if (ARG_COUNT(ht) != 4 ||
+ zend_get_parameters_ex(4, &obj_id, &coordinates, &NumPoints, &width) ==
FAILURE) {
+ WRONG_PARAM_COUNT;
+ }
+ convert_to_long_ex(obj_id);
+ convert_to_long_ex(NumPoints);
+ convert_to_double_ex(width);
+
+ if ((*coordinates)->type != IS_ARRAY) {
+ return;
+ php_error(E_WARNING, "Wrong datatype of second argument to swf_definepoly");
+ }
+
+ npoints = (*NumPoints)->value.lval;
+ for (i = 0; i < npoints; i++) {
+ if (zend_hash_index_find((*coordinates)->value.ht, (i * 2), (void **)&var) == SUCCESS) {
+ SEPARATE_ZVAL(var);
+ convert_to_double_ex(var);
+ coords[i][0] = (float)(*var)->value.dval;
+ }
+ if (zend_hash_index_find((*coordinates)->value.ht, (i * 2) + 1, (void **)&var) == SUCCESS)
{
+ SEPARATE_ZVAL(var);
+ convert_to_double_ex(var);
+ coords[i][1] = (float)(*var)->value.dval;
+ }
+ }
+ swf_definepoly((*obj_id)->value.lval, coords, npoints, (float)(*width)->value.dval);
}
/* }}} */