1 /* ==================================================================== 2 * Copyright (c) 2000-2001 by Soheil Seyfaie. All rights reserved. 3 * This program is free software; you can redistribute it and/or modify 4 * it under the same terms as Perl itself. 5 * ==================================================================== 6 * 7 * $Author$ 8 * $Id$ 9 */ 10 11 12 #include "EXTERN.h" 13 #include "perl.h" 14 #include "XSUB.h" 15 16 #include "SWF.h" 17 #include "perl_swf.h" 18 19 20 MODULE = SWF::Shape PACKAGE = SWF::Shape PREFIX = SWFShape_ 21 22 PROTOTYPES: ENABLE 23 24 SWF::Shape 25 SWFShape_new(package="SWF::Shape") 26 char *package 27 CODE: 28 RETVAL = newSWFShape(); 29 ST(0) = sv_newmortal(); 30 sv_setref_pv(ST(0), package, (void*)RETVAL); 31 32 void 33 destroySWFShape(shape) 34 SWF::Shape shape 35 ALIAS: 36 SWF::Shape::DESTROY = 1 37 CODE: 38 S_DEBUG(2, fprintf(stderr, "Shape DESTROY CALLED\n")); 39 swf_stash_refcnt_dec((SV*)SvRV(ST(0))); 40 destroySWFShape(shape); 41 42 void 43 SWFShape_movePenTo(shape, x, y) 44 SWF::Shape shape 45 double x 46 double y 47 48 void 49 SWFShape_movePen(shape, x, y) 50 SWF::Shape shape 51 double x 52 double y 53 54 float 55 SWFShape_getPenX(shape) 56 SWF::Shape shape 57 58 float 59 SWFShape_getPenY(shape) 60 SWF::Shape shape 61 62 63 void 64 SWFShape_getPen(shape) 65 SWF::Shape shape 66 PREINIT: 67 double x; 68 double y; 69 PPCODE: 70 SWFShape_getPen(shape, &x, &y); 71 EXTEND(SP, 2); 72 PUSHs(sv_2mortal(newSVnv(x))); 73 PUSHs(sv_2mortal(newSVnv(y))); 74 75 void 76 SWFShape_drawLineTo(shape, x, y) 77 SWF::Shape shape 78 double x 79 double y 80 81 void 82 SWFShape_drawLine(shape, dx, dy) 83 SWF::Shape shape 84 double dx 85 double dy 86 87 void 88 SWFShape_drawCurveTo(shape, controlx, controly, anchorx, anchory) 89 SWF::Shape shape 90 double controlx 91 double controly 92 double anchorx 93 double anchory 94 95 void 96 SWFShape_drawCurve(shape, controldx, controldy, anchordx, anchordy) 97 SWF::Shape shape 98 double controldx 99 double controldy 100 double anchordx 101 double anchordy 102 103 104 void 105 SWFShape_drawCubicTo(shape, bx, by, cx, cy, dx, dy) 106 SWF::Shape shape 107 double bx 108 double by 109 double cx 110 double cy 111 double dx 112 double dy 113 114 void 115 SWFShape_drawCubic(shape, bx, by, cx, cy, dx, dy) 116 SWF::Shape shape 117 double bx 118 double by 119 double cx 120 double cy 121 double dx 122 double dy 123 124 void 125 SWFShape_end(shape) 126 SWF::Shape shape 127 128 void 129 SWFShape_setLineStyle(shape, width, r, g, b, a=0xff) 130 SWF::Shape shape 131 unsigned short width 132 byte r 133 byte g 134 byte b 135 byte a 136 CODE: 137 warn("Using setLineStyle() is deprecated. Use setLine() instead!"); 138 SWFShape_setLineStyle(shape, width, r, g, b, a); 139 140 void 141 SWFShape_setLineStyle2(shape, width, r, g, b, a, flags, miterLimit) 142 SWF::Shape shape 143 unsigned short width 144 byte r 145 byte g 146 byte b 147 byte a 148 int flags 149 float miterLimit 150 CODE: 151 warn("Using setLineStyle2() is deprecated. Use setLine2() instead!"); 152 SWFShape_setLineStyle2(shape, width, r, g, b, a, flags, miterLimit); 153 154 void 155 SWFShape_setLineStyle2filled(shape, width, fill, flags, miterLimit) 156 SWF::Shape shape 157 unsigned short width 158 SWF::Fill fill 159 int flags 160 float miterLimit 161 CODE: 162 warn("Using setLineStyle2filled() is deprecated. Use setLine2Filled() instead!"); 163 SWFShape_setLineStyle2filled(shape, width, 164 SWFFill_getFillStyle(fill), flags, miterLimit); 165 166 SWF::Fill 167 SWFShape_addFill(shape, ...) 168 SWF::Shape shape 169 PREINIT: 170 CV *cv; 171 char *my_sub; 172 CODE: 173 174 PUSHMARK(mark); 175 if (sv_derived_from(ST(1), "SWF::Gradient")) 176 my_sub = "SWF::Shape::addGradientFill"; 177 else if(sv_derived_from(ST(1), "SWF::Bitmap")) 178 my_sub = "SWF::Shape::addBitmapFill"; 179 else 180 my_sub = "SWF::Shape::addSolidFill"; 181 cv = GvCV(gv_fetchpv(my_sub, FALSE, SVt_PVCV)); 182 #ifdef PERL_OBJECT 183 (void)(*CvXSUB(cv))(cv, pPerl); 184 #else 185 (void)(*CvXSUB(cv))(aTHXo_ cv); 186 #endif 187 188 189 SWF::Fill 190 SWFShape_addSolidFill(shape, r, g, b, a=0xff) 191 SWF::Shape shape 192 byte r 193 byte g 194 byte b 195 byte a 196 PREINIT: 197 SV *sv; 198 CODE: 199 sv = (SV*)SvRV(ST(0)); 200 RETVAL = SWFShape_addSolidFill(shape, r, g, b, a); 201 ST(0) = sv_newmortal(); 202 sv_setref_pv(ST(0), "SWF::Fill", (void*)RETVAL); 203 swf_stash_refcnt_inc(sv, (SV*)SvRV(ST(0))); 204 205 SWF::Fill 206 SWFShape_addGradientFill(shape, gradient, flags=SWFFILL_LINEAR_GRADIENT) 207 SWF::Shape shape 208 SWF::Gradient gradient 209 byte flags 210 CODE: 211 swf_stash_refcnt_inc((SV*)SvRV(ST(0)), (SV*)SvRV(ST(1))); 212 RETVAL = SWFShape_addGradientFill(shape, gradient, flags); 213 ST(0) = sv_newmortal(); 214 sv_setref_pv(ST(0), "SWF::Fill", (void*)RETVAL); 215 216 SWF::Fill 217 SWFShape_addBitmapFill(shape, bitmap, flags=SWFFILL_TILED_BITMAP) 218 SWF::Shape shape 219 SWF::Bitmap bitmap 220 byte flags 221 CODE: 222 swf_stash_refcnt_inc((SV*)SvRV(ST(0)), (SV*)SvRV(ST(1))); 223 RETVAL = SWFShape_addBitmapFill(shape, bitmap, flags); 224 ST(0) = sv_newmortal(); 225 sv_setref_pv(ST(0), "SWF::Fill", (void*)RETVAL); 226 227 void 228 SWFShape_xs_setLeftFill(shape, fill=NULL) 229 SWF::Shape shape 230 SWF::Fill fill 231 CODE: 232 SWFShape_setLeftFill(shape, fill); 233 234 void 235 SWFShape_xs_setRightFill(shape, fill=NULL) 236 SWF::Shape shape 237 SWF::Fill fill 238 CODE: 239 SWFShape_setRightFill(shape, fill); 240 241 void 242 SWFShape_drawGlyph(shape, font, c, size=0) 243 SWF::Shape shape 244 SWF::Font font 245 int c 246 int size 247 CODE: 248 swf_stash_refcnt_inc((SV*)SvRV(ST(0)), (SV*)SvRV(ST(1))); 249 SWFShape_drawSizedGlyph(shape, font, c, size); 250 251 void 252 SWFShape_drawArc(shape, r, startAngle, endAngle) 253 SWF::Shape shape 254 int r 255 float startAngle 256 float endAngle 257 258 void 259 SWFShape_drawCircle(shape, r) 260 SWF::Shape shape 261 float r 262 263 void 264 SWFShape_setLine(shape, w, r, g, b, a=0xff) 265 SWF::Shape shape 266 int w 267 unsigned char r 268 unsigned char g 269 unsigned char b 270 unsigned char a 271 272 void 273 SWFShape_setLine2(shape, width, r, g, b, a, flags, miterLimit) 274 SWF::Shape shape 275 unsigned short width 276 byte r 277 byte g 278 byte b 279 byte a 280 int flags 281 float miterLimit 282 283 void 284 SWFShape_setLine2Filled(shape, width, fill, flags, miterLimit) 285 SWF::Shape shape 286 unsigned short width 287 SWF::Fill fill 288 int flags 289 float miterLimit 290 CODE: 291 SWFShape_setLine2Filled(shape, width, 292 SWFFill_getFillStyle(fill), flags, miterLimit); 293 294 void 295 SWFShape_useVersion(shape, version) 296 SWF::Shape shape 297 int version 298 299 int 300 SWFShape_getVersion(shape) 301 SWF::Shape shape 302 303 void 304 SWFShape_setRenderHintingFlags(shape, flags) 305 SWF::Shape shape 306 int flags 307 308 void 309 SWFShape_hideLine(shape) 310 SWF::Shape shape 311 312 void 313 SWFShape_drawCharacterBounds(shape, character) 314 SWF::Shape shape 315 SWF::Character character = NO_INIT 316 PREINIT: 317 IV tmp; 318 CODE: 319 tmp = SvIV((SV*)SvRV(ST(1))); 320 character = INT2PTR(SWF__Character, tmp); 321 SWFShape_drawCharacterBounds(shape, character); 322 323 SV * 324 SWFShape_dumpOutline(shape) 325 SWF::Shape shape 326 PREINIT: 327 char *buf; 328 CODE: 329 buf=SWFShape_dumpOutline(shape); 330 RETVAL=newSVpv(buf,0); 331 free(buf); 332 OUTPUT: 333 RETVAL 334