+void swf_ExpandRect(SRECT*src, SPOINT add)
+{
+ if((src->xmin | src->ymin | src->xmax | src->ymax)==0) {
+ src->xmin = add.x;
+ src->ymin = add.y;
+ src->xmax = add.x;
+ src->ymax = add.y;
+ if((add.x|add.y) == 0) src->xmax++; //make sure the bbox is not NULL anymore
+ return;
+ }
+ if(add.x < src->xmin)
+ src->xmin = add.x;
+ if(add.x > src->xmax)
+ src->xmax = add.x;
+ if(add.y < src->ymin)
+ src->ymin = add.y;
+ if(add.y > src->ymax)
+ src->ymax = add.y;
+}
+void swf_ExpandRect2(SRECT*src, SRECT*add)
+{
+ if((add->xmin | add->ymin | add->xmax | add->ymax)==0)
+ return;
+ if((src->xmin | src->ymin | src->xmax | src->ymax)==0)
+ *src = *add;
+ if(add->xmin < src->xmin)
+ src->xmin = add->xmin;
+ if(add->ymin < src->ymin)
+ src->ymin = add->ymin;
+ if(add->xmax > src->xmax)
+ src->xmax = add->xmax;
+ if(add->ymax > src->ymax)
+ src->ymax = add->ymax;
+}
+void swf_ExpandRect3(SRECT*src, SPOINT center, int radius)
+{
+ if((src->xmin | src->ymin | src->xmax | src->ymax)==0) {
+ src->xmin = center.x-radius;
+ src->ymin = center.y-radius;
+ src->xmax = center.x+radius;
+ src->ymax = center.y+radius;
+ if((center.x|center.y|radius) == 0) src->xmax++; //make sure the bbox is not NULL anymore
+ return;
+ }
+ if(center.x - radius < src->xmin)
+ src->xmin = center.x - radius;
+ if(center.x + radius > src->xmax)
+ src->xmax = center.x - radius;
+ if(center.y - radius < src->ymin)
+ src->ymin = center.y - radius;
+ if(center.y + radius > src->ymax)
+ src->ymax = center.y - radius;
+}
+SPOINT swf_TurnPoint(SPOINT p, MATRIX* m)
+{
+ SPOINT r;
+ r.x = (int)(m->sx*(1/65536.0)*p.x + m->r1*(1/65536.0)*p.y + 0.5) + m->tx;
+ r.y = (int)(m->r0*(1/65536.0)*p.x + m->sy*(1/65536.0)*p.y + 0.5) + m->ty;
+ return r;
+}
+SRECT swf_TurnRect(SRECT r, MATRIX* m)
+{
+ SRECT g;
+ SPOINT p1,p2,p3,p4,pp1,pp2,pp3,pp4;
+ p1.x = r.xmin;p1.y = r.ymin;
+ p2.x = r.xmax;p2.y = r.ymin;
+ p3.x = r.xmin;p3.y = r.ymax;
+ p4.x = r.xmax;p4.y = r.ymax;
+ pp1 = swf_TurnPoint(p1, m);
+ pp2 = swf_TurnPoint(p2, m);
+ pp3 = swf_TurnPoint(p3, m);
+ pp4 = swf_TurnPoint(p4, m);
+ g.xmin = g.xmax = pp1.x;
+ g.ymin = g.ymax = pp1.y;
+ swf_ExpandRect(&g, pp2);
+ swf_ExpandRect(&g, pp3);
+ swf_ExpandRect(&g, pp4);
+ return g;
+}
+
+