AddEllipseInRect() public method

public AddEllipseInRect ( RectangleF rect ) : void
rect System.Drawing.RectangleF
return void
Exemplo n.º 1
0
 public static void FillEllipsis(CGContext context, RectangleF rect, CGColor color, float lineWidth)
 {
     context.SaveState();
     context.SetFillColor(color);
     context.AddEllipseInRect(rect);
     context.FillPath();
     context.RestoreState();
 }
Exemplo n.º 2
0
		public override void DrawInContext (CGContext context)
		{
			base.DrawInContext (context);
			
			context.AddEllipseInRect (Bounds);
			context.SetFillColor (ClockColor);
			context.FillPath ();
		}
Exemplo n.º 3
0
 public static void DrawEllipsis(CGContext context, RectangleF rect, CGColor color, float lineWidth)
 {
     context.SaveState();
     context.SetStrokeColor(color);
     context.SetLineWidth(lineWidth);
     context.AddEllipseInRect(rect);
     context.StrokePath();
     context.RestoreState();
 }
        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 RectangleF(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();
            }
        }