System.Drawing.Graphics.make_arcs C# (CSharp) Method

make_arcs() static private method

static private make_arcs ( CGContext graphics, float x, float y, float width, float height, float startAngle, float sweepAngle, bool convert_units, bool antialiasing, bool isPieSlice ) : void
graphics CGContext
x float
y float
width float
height float
startAngle float
sweepAngle float
convert_units bool
antialiasing bool
isPieSlice bool
return void
        static void make_arcs(CGContext graphics, float x, float y, float width, float height, float startAngle, float sweepAngle,
			          bool convert_units, bool antialiasing, bool isPieSlice)
        {
            int i;
            float drawn = 0;
            float endAngle;
            bool enough = false;

            // I do not think we need to convert the units so commented this out.

            /* if required deal, once and for all, with unit conversions */
            //if (convert_units && !OPTIMIZE_CONVERSION(graphics))
            //{
            //    x = gdip_unitx_convgr(graphics, x);
            //    y = gdip_unity_convgr(graphics, y);
            //    width = gdip_unitx_convgr(graphics, width);
            //    height = gdip_unity_convgr(graphics, height);
            //}

            if (Math.Abs(sweepAngle) >= 360)
            {
                graphics.AddEllipseInRect (new CGRect (x,y,width,height));
                return;
            }

            endAngle = startAngle + sweepAngle;
            /* if we end before the start then reverse positions (to keep increment positive) */
            if (endAngle < startAngle)
            {
                var temp = endAngle;
                endAngle = startAngle;
                startAngle = temp;
            }

            if (isPieSlice) {
                graphics.MoveTo(x + (width / 2), y + (height / 2));
            }

            /* i is the number of sub-arcs drawn, each sub-arc can be at most 90 degrees.*/
            /* there can be no more then 4 subarcs, ie. 90 + 90 + 90 + (something less than 90) */
            for (i = 0; i < 4; i++)
            {
                float current = startAngle + drawn;
                float additional;

                if (enough)
                {
                    if (isPieSlice)
                    {
                        graphics.ClosePath();
                    }
                    return;
                }

                additional = endAngle - current; /* otherwise, add the remainder */
                if (additional > 90)
                {
                    additional = 90.0f;
                }
                else
                {
                    /* a near zero value will introduce bad artefact in the drawing (#78999) */
                    if (( additional >= -0.0001f) && (additional <= 0.0001f))
                        return;
                    enough = true;
                }

                make_arc(graphics, (i == 0),	/* only move to the starting pt in the 1st iteration */
                         x, y, width, height,	/* bounding rectangle */
                         current, current + additional, antialiasing, isPieSlice);

                drawn += additional;

            }

            if (isPieSlice) {
                graphics.ClosePath();
            }
        }