public static GraphicsPathFP CreateArc(int ff_xmin, int ff_ymin, int ff_xmax, int ff_ymax, int ff_startangle, int ff_sweepangle, bool closed, bool standalone) { if (ff_sweepangle < 0) { ff_startangle += ff_sweepangle; ff_sweepangle = -ff_sweepangle; } int segments = MathFP.Round(MathFP.Div(4 * MathFP.Abs(ff_sweepangle), MathFP.PI)) >> SingleFP.DecimalBits; if (segments == 0) { segments = 1; } GraphicsPathFP path = new GraphicsPathFP(); int ff_darg = ff_sweepangle / segments; int ff_arg = ff_startangle; int ff_lastcos = MathFP.Cos(ff_startangle); int ff_lastsin = MathFP.Sin(ff_startangle); int ff_xc = (ff_xmin + ff_xmax) / 2; int ff_yc = (ff_ymin + ff_ymax) / 2; int ff_rx = (ff_xmax - ff_xmin) / 2; int ff_ry = (ff_ymax - ff_ymin) / 2; int ff_RXBETA = MathFP.Mul(17381, ff_rx); int ff_RYBETA = MathFP.Mul(17381, ff_ry); int ff_currcos, ff_currsin, ff_x1, ff_y1, ff_x2, ff_y2; if (closed) { path.AddMoveTo(new PointFP(ff_xc, ff_yc)); } for (int i = 1; i <= segments; i++) { ff_arg = i == segments?ff_startangle + ff_sweepangle:ff_arg + ff_darg; ff_currcos = MathFP.Cos(ff_arg); ff_currsin = MathFP.Sin(ff_arg); ff_x1 = ff_xc + MathFP.Mul(ff_rx, ff_lastcos); ff_y1 = ff_yc + MathFP.Mul(ff_ry, ff_lastsin); ff_x2 = ff_xc + MathFP.Mul(ff_rx, ff_currcos); ff_y2 = ff_yc + MathFP.Mul(ff_ry, ff_currsin); if (i == 1) { if (closed) { path.AddLineTo(new PointFP(ff_x1, ff_y1)); } else if (standalone) { path.AddMoveTo(new PointFP(ff_x1, ff_y1)); } } path.AddCurveTo( new PointFP(ff_x1 - MathFP.Mul(ff_RXBETA, ff_lastsin), ff_y1 + MathFP.Mul(ff_RYBETA, ff_lastcos)), new PointFP(ff_x2 + MathFP.Mul(ff_RXBETA, ff_currsin), ff_y2 - MathFP.Mul(ff_RYBETA, ff_currcos)), new PointFP(ff_x2, ff_y2)); ff_lastcos = ff_currcos; ff_lastsin = ff_currsin; } if (closed) { path.AddClose(); } return(path); }