void Fixed_SWFShape_drawCircle(SWFShape shape, double r, double startAngle, double endAngle) { int i; double controlx, controly, anchorx, anchory, x, y; /* first determine number of segments, 8 at most */ int nSegs = (int)(1 + floor(15*(endAngle-startAngle)/360)); /* subangle is half the angle of each segment */ double subangle = M_PI*(endAngle-startAngle)/nSegs/360; double angle = M_PI*startAngle/180; x = r*sin(angle); y = -(r*cos(angle)); SWFShape_movePen(shape, x, y); for ( i=0; i<nSegs; ++i ) { angle += subangle; controlx = (r*sin(angle)/cos(subangle)); controly = (-r*cos(angle)/cos(subangle)); angle += subangle; anchorx = (r*sin(angle)); anchory = (-r*cos(angle)); SWFShape_drawCurve(shape, controlx-x, controly-y, anchorx-controlx, anchory-controly); x = anchorx; y = anchory; } }
void SWFShape_drawArc(SWFShape shape, float r, float startAngle, float endAngle) { int i; float controlx, controly, anchorx, anchory, x, y; /* first determine number of segments, 8 at most */ int nSegs = (int)(1 + floor(7*(endAngle-startAngle)/360)); /* subangle is half the angle of each segment */ float subangle = M_PI*(endAngle-startAngle)/nSegs/360; float angle = M_PI*startAngle/180; x = (float)rint(r*sin(angle)); y = (float)-rint(r*cos(angle)); SWFShape_movePen(shape, x, y); for ( i=0; i<nSegs; ++i ) { angle += subangle; controlx = (float)(r*sin(angle)/cos(subangle)); controly = (float)(-r*cos(angle)/cos(subangle)); angle += subangle; anchorx = (float)(r*sin(angle)); anchory = (float)(-r*cos(angle)); SWFShape_drawCurve(shape, (float)rint(controlx)-x, (float)rint(controly)-y, (float)rint(anchorx-controlx), (float)rint(anchory-controly)); x = anchorx; y = anchory; } }
static VALUE move_pen(VALUE self, VALUE x, VALUE y) { SWFShape shape; Data_Get_Struct(self, struct SWFShape_s, shape); SWFShape_movePen(shape, NUM2DBL(x), NUM2DBL(y)); return self; }
void SWFShape_drawArc(SWFShape shape, double r, double startAngle, double endAngle) { int i, nSegs; double controlx, controly, anchorx, anchory, x, y; double angle, subangle, controlRadius; /* Normalize the angles */ double delta = endAngle - startAngle; if ( abs(delta) >= 360) delta = 360; else if (delta < 0) delta += 360; else if (delta == 0) return; startAngle = fmod(startAngle, 360); /* first determine number of segments, 8 at most */ nSegs = 1 + (int)rint(7 * (delta / 360)); /* subangle is half the angle of each segment */ subangle = M_PI * delta / nSegs / 360; angle = M_PI * startAngle / 180; x = r * sin(angle); y = -r * cos(angle); SWFShape_movePen(shape, x, y); controlRadius = r / cos(subangle); for ( i=0; i<nSegs; ++i ) { angle += subangle; controlx = controlRadius * sin(angle); controly = -controlRadius * cos(angle); angle += subangle; anchorx = (r*sin(angle)); anchory = (-r*cos(angle)); SWFShape_drawCurve(shape, controlx-x, controly-y, anchorx-controlx, anchory-controly); x = anchorx; y = anchory; } }
EXPORT BOOL WINAPI s_movePen(float dx, float dy, int p3, int p4) { lstrcpy(funcname, "s_movePen"); SWFShape_movePen(mhsp_shape, dx, dy); return 0; }