+/* TODO: move to ../lib/rfxswf */
+void changeRect(TAG*tag, int pos, SRECT*newrect)
+{
+ /* determine length of old rect */
+ tag->pos = pos;
+ tag->readBit = 0;
+ SRECT old;
+ swf_GetRect(tag, &old);
+ swf_ResetReadBits(tag);
+ int pos_end = tag->pos;
+
+ int len = tag->len - pos_end;
+ U8*data = (U8*)malloc(len);
+ memcpy(data, &tag->data[pos_end], len);
+ tag->writeBit = 0;
+ tag->len = pos;
+ swf_SetRect(tag, newrect);
+ swf_SetBlock(tag, data, len);
+ free(data);
+ tag->pos = tag->readBit = 0;
+}
+
+void fixAreas()
+{
+ if(!shapeisempty && fill &&
+ (bboxrect.xmin == bboxrect.xmax ||
+ bboxrect.ymin == bboxrect.ymax)) {
+ msg("<debug> Shape has size 0");
+
+ if(bboxrect.xmin == bboxrect.xmax && bboxrect.ymin == bboxrect.ymax) {
+ /* this thing comes down to a single dot- nothing to fix here */
+ return;
+ }
+
+ float x=0,y=0;
+ if(bboxrect.xmin == bboxrect.xmax) {
+ x = 0.05;
+ } else {
+ y = 0.05;
+ }
+ /* warning: doing this inside endshape() is dangerous */
+ moveto(tag, bboxrect.xmin/20.0, bboxrect.ymin/20.0);
+ lineto(tag, bboxrect.xmax/20.0 + x, bboxrect.ymin/20.0);
+ lineto(tag, bboxrect.xmax/20.0 + x, bboxrect.ymax/20.0 + y);
+ lineto(tag, bboxrect.xmin/20.0, bboxrect.ymax/20.0 + y);
+ lineto(tag, bboxrect.xmin/20.0, bboxrect.ymin/20.0);
+ }
+
+}
+
+static void endshape(int clipdepth)