Arc not showing when using AddArc

I'm expecting a red arc, but I'm only seeing a grey circle.

Please help!

void OnCanvasViewPaintSurface(object sender, SKPaintSurfaceEventArgs args)
        {
            SKImageInfo info = args.Info;
            SKSurface surface = args.Surface;
            SKCanvas canvas = surface.Canvas;

           canvas.Clear(SKColors.White);

            var canvas_width = info.Width;
            var canvas_height = info.Height;

            SKRect rect = new SKRect(500, 500, 100, 100);
            SKRect rect2 = new SKRect(100, 100, 100, 100);


            SKPaint paint = new SKPaint
            {
                Style = SKPaintStyle.Stroke,
                Color = Color.LightGray.ToSKColor(),
                StrokeWidth = 25
            };


            canvas.DrawOval(rect, paint);


            paint.Color = SKColors.Red;




            using (SKPath path = new SKPath())
            {
                path.AddArc(rect2, 0, 45);
                canvas.DrawPath(path, paint);
            }



        }

Best Answer

  • CarmenBranjeCarmenBranje CA ✭✭
    Accepted Answer

    This was related to something to do with the rectangle I was using.

     SKImageInfo info = args.Info;
                SKSurface surface = args.Surface;
                SKCanvas canvas = surface.Canvas;
    
                canvas.Clear(SKColors.White);
    
                var canvas_width = info.Width;
                var canvas_height = info.Height;
    
                SKPaint paint = new SKPaint
                {
                    Style = SKPaintStyle.Stroke,
                    Color = Color.LightGray.ToSKColor(),
                    StrokeWidth = 25
                };
    
                var radial_width = 300;
                var radial_height = 300;
    
                SKRect skRectangle = new SKRect();
                skRectangle.Size = new SKSize(radial_width, radial_height);
                skRectangle.Location = new SKPoint((canvas_width / 4) - (radial_width / 2), (canvas_height / 4) - (radial_height / 2));
    
                canvas.DrawOval(skRectangle, paint);
    
                paint.Color = SKColors.Green;
    
                float startAngle = -90;
                float sweepAngle = 260; // (75 / 100) * 360
    
                SKPath skPath = new SKPath();
                skPath.AddArc(skRectangle, startAngle, sweepAngle);
    
    
    
                canvas.DrawPath(skPath, paint);
    

Answers

  • CarmenBranjeCarmenBranje CAMember ✭✭
    Accepted Answer

    This was related to something to do with the rectangle I was using.

     SKImageInfo info = args.Info;
                SKSurface surface = args.Surface;
                SKCanvas canvas = surface.Canvas;
    
                canvas.Clear(SKColors.White);
    
                var canvas_width = info.Width;
                var canvas_height = info.Height;
    
                SKPaint paint = new SKPaint
                {
                    Style = SKPaintStyle.Stroke,
                    Color = Color.LightGray.ToSKColor(),
                    StrokeWidth = 25
                };
    
                var radial_width = 300;
                var radial_height = 300;
    
                SKRect skRectangle = new SKRect();
                skRectangle.Size = new SKSize(radial_width, radial_height);
                skRectangle.Location = new SKPoint((canvas_width / 4) - (radial_width / 2), (canvas_height / 4) - (radial_height / 2));
    
                canvas.DrawOval(skRectangle, paint);
    
                paint.Color = SKColors.Green;
    
                float startAngle = -90;
                float sweepAngle = 260; // (75 / 100) * 360
    
                SKPath skPath = new SKPath();
                skPath.AddArc(skRectangle, startAngle, sweepAngle);
    
    
    
                canvas.DrawPath(skPath, paint);
    
Sign In or Register to comment.