private void CanvasView_PaintSurface(object sender, SkiaSharp.Views.Forms.SKPaintSurfaceEventArgs e)
        {
            SKImageInfo info    = e.Info;
            SKSurface   surface = e.Surface;
            SKCanvas    canvas  = surface.Canvas;

            canvas.Clear();

            float maxRadius = 0.75f * Math.Min(info.Width, info.Height) / 2;
            float minRadius = 0.25f * maxRadius;

            float xRadius = minRadius * scale + maxRadius * (1 - scale);
            float yRadius = maxRadius * scale + minRadius * (1 - scale);

            using (SKPaint paint = new SKPaint())
            {
                paint.Style       = SKPaintStyle.Stroke;
                paint.Color       = SKColors.Blue;
                paint.StrokeWidth = 50;
                paint.IsAntialias = true;
                canvas.DrawOval(info.Width / 2, info.Height / 2, xRadius, yRadius, paint);

                paint.Style = SKPaintStyle.Fill;
                paint.Color = SKColors.SkyBlue;
                canvas.DrawOval(info.Width / 2, info.Height / 2, xRadius, yRadius, paint);
            }
        }
        void BoundingBox_PaintSurface(object sender, SkiaSharp.Views.Forms.SKPaintSurfaceEventArgs e)
        {
            if (ViewModel.lastPrediction?.BoundingBox == null)
            {
                return;
            }

            var boundingBox = ViewModel.lastPrediction.BoundingBox;

            e.Surface.Canvas.Clear();

            var SKSkiaView = sender as SKCanvasView;

            double scaleFactor     = e.Info.Width / SKSkiaView.Width;
            float  width           = (float)e.Info.Width;
            float  height          = (float)e.Info.Height;
            float  lineStrokeWidth = 2 * (float)scaleFactor;

            float boxX      = (float)((width * boundingBox.Left));
            float boxY      = (float)((height * boundingBox.Top));
            float boxWidth  = (float)((width * boundingBox.Width));
            float boxHeight = (float)((height * boundingBox.Height));


            var paint = new SkiaSharp.SKPaint()
            {
                Style       = SkiaSharp.SKPaintStyle.Stroke,
                StrokeWidth = lineStrokeWidth,
                Color       = SkiaSharp.SKColors.White,
                StrokeCap   = SKStrokeCap.Round,
            };

            e.Surface.Canvas.DrawRect(boxX, boxY, boxWidth, boxHeight, paint);
        }
Example #3
0
        private void Planedview_PaintSurface(object sender, SkiaSharp.Views.Forms.SKPaintSurfaceEventArgs e)
        {
            SKImageInfo info    = e.Info;
            SKSurface   surface = e.Surface;
            SKCanvas    canvas  = surface.Canvas;

            canvas.Clear();

            SKPaint paint = new SKPaint
            {
                Color = Color.LightCoral.ToSKColor(),
            };

            var items    = GetItems();
            var infoList = new List <int>();

            foreach (PlanList pList in items)
            {
                var NumCount = 0;
                foreach (Plan p in pList)
                {
                    NumCount += p.Count;
                }
                infoList.Add(NumCount);
            }

            for (int i = 0; i < infoList.Count; i++)
            {
                var left = (float)info.Width * i / (infoList.Count);
                var top  = info.Height * infoList[i] / infoList.Max();
                canvas.DrawRect(left, top, info.Width / infoList.Count, info.Height, paint);
            }
        }
Example #4
0
        private void SKCanvasView_PaintSurface(object sender, SkiaSharp.Views.Forms.SKPaintSurfaceEventArgs args)
        {
            SKImageInfo info    = args.Info;
            SKSurface   surface = args.Surface;
            SKCanvas    canvas  = surface.Canvas;

            canvas.Clear();

            //Fill in the whole grid space
            canvas.DrawRect(info.Rect, _accentPaint);

            // create path for dark color  AccentDarkPaint, dispose path when done.
            using (SKPath path = new SKPath())
            {
                //Assume drawing in a 10 by 10 coordinate system.
                path.MoveTo(0, 0);                          //Start at point (0,0)
                path.LineTo(info.Width * .7f, 0);           //Line from (0,0) to (0,7) ,Draw to the right to 70 % width of the rectangle(cell)
                path.LineTo(info.Width * .2f, info.Height); //Draw from point (0,7) to (2,10)
                path.LineTo(0, info.Height);                //Draw from point (2,10) to (0,10)
                path.Close();                               //Close the path, it knows to draw from 0,10 to 0,0
                canvas.DrawPath(path, _accentDarkPaint);    //Draw and fill path with accent dark paint color.
            }
            //Similarly, create path for Extra Dark color  AccentExtraDarkPaint
            using (SKPath path = new SKPath())
            {
                path.MoveTo(0, 0);
                path.LineTo(info.Width * .33f, 0);
                path.LineTo(0, info.Height * .6f);
                path.Close();
                canvas.DrawPath(path, _accentExtraDarkPaint);
            }
        }
Example #5
0
        private void canvasView_PaintSurface(object sender, SkiaSharp.Views.Forms.SKPaintSurfaceEventArgs e)
        {
            SKImageInfo info    = e.Info;
            SKSurface   surface = e.Surface;
            SKCanvas    canvas  = surface.Canvas;

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

            paint.Style = SKPaintStyle.Fill;
            paint.Color = SKColors.Red;
            float x, y;

            x = (float)(info.Height * Math.Sin(angle));
            y = (float)(info.Height * Math.Cos(angle));

            canvas.DrawLine(info.Width / 2, info.Height / 2, info.Width / 2 - x, info.Height - y, paint);
            paint.Color = SKColors.Yellow;
            canvas.DrawLine(info.Width / 2, info.Height / 2, info.Width / 2 + x, y, paint);
        }
        private void SKCanvasView_PaintSurface(object sender, SkiaSharp.Views.Forms.SKPaintSurfaceEventArgs e)
        {
            SKImageInfo info    = e.Info;
            SKSurface   surface = e.Surface;
            SKCanvas    canvas  = surface.Canvas;

            canvas.Clear();

            int cornerRadius = info.Width / 14;

            using (SKPath path = new SKPath())
            {
                path.MoveTo(0, 0);
                path.LineTo(info.Width - cornerRadius, 0);

                path.CubicTo(info.Width, 0, info.Width, info.Height, info.Width - cornerRadius, info.Height);
                path.LineTo(cornerRadius, info.Height);

                path.QuadTo(0, info.Height, 0, info.Height - cornerRadius);
                path.LineTo(0, 0);

                SKPaint paint = new SKPaint
                {
                    Style       = SKPaintStyle.StrokeAndFill,
                    Color       = ((Color)App.Current.Resources["secondMessage"]).ToSKColor(),
                    StrokeWidth = 1,
                    IsAntialias = true
                };

                canvas.DrawPath(path, paint);
            }
        }
        private void Paint_RoundRect_withoutBorder(object sender, SkiaSharp.Views.Forms.SKPaintSurfaceEventArgs args)
        {
            SKImageInfo info    = args.Info;
            SKSurface   surface = args.Surface;
            SKCanvas    canvas  = surface.Canvas;

            canvas.Clear();

            using (SKPaint paint = new SKPaint())
            {
                var    radius = info.Height / 2;
                SKRect rect;

                //half of the strokewidth to get border inside is added to left-top and subtracted from bottom-right
                rect = new SKRect(info.Rect.Left, info.Rect.Top, info.Rect.Right, info.Rect.Bottom);

                SKColor borderColor = ((Color)Application.Current.Resources["ButtonBackgroundColor"]).ToSKColor();
                paint.Color = borderColor;
                //paint.StrokeWidth = 5;
                //paint.Style = SKPaintStyle.Stroke;
                paint.IsAntialias = true;
                paint.Style       = SKPaintStyle.Fill;



                canvas.DrawRoundRect(rect, radius, radius, paint);
                //canvas.DrawColor(borderColor, SKBlendMode.ColorDodge);
            }
        }
Example #8
0
        private void SKCanvasView_PaintSurface(object sender, SkiaSharp.Views.Forms.SKPaintSurfaceEventArgs e)
        {
            SKSurface surface = e.Surface;
            SKCanvas  canvas  = surface.Canvas;

            var    scale = ((SKCanvasView)sender).CanvasSize.Width / 20;
            SKPath path  = new SKPath();

            path.MoveTo(-1 * scale, -1 * scale);
            path.LineTo(0 * scale, -1 * scale);
            path.LineTo(0 * scale, 0 * scale);
            path.LineTo(1 * scale, 0 * scale);
            path.LineTo(1 * scale, 1 * scale);
            path.LineTo(0 * scale, 1 * scale);
            path.LineTo(0 * scale, 0 * scale);
            path.LineTo(-1 * scale, 0 * scale);
            path.LineTo(-1 * scale, -1 * scale);

            SKMatrix matrix = SKMatrix.MakeScale(2 * scale, 2 * scale);
            SKPaint  paint  = new SKPaint();

            paint.PathEffect  = SKPathEffect.Create2DPath(matrix, path);
            paint.Color       = Color.LightGray.ToSKColor();
            paint.IsAntialias = true;

            var patternRect = new SKRect(0, 0, ((SKCanvasView)sender).CanvasSize.Width, ((SKCanvasView)sender).CanvasSize.Height);

            canvas.Save();
            canvas.DrawRect(patternRect, paint);
            canvas.Restore();
        }
        private void SKCanvasView_PaintSurface(object sender, SkiaSharp.Views.Forms.SKPaintSurfaceEventArgs e)
        {
            if (!isinit)
            {
                return;
            }
            SKCanvas canvas = e.Surface.Canvas;
            int      width  = e.Info.Width;
            int      height = e.Info.Height;

            canvas.Clear();
            canvas.Translate(width / 2, height / 2);
            for (int i = 0; i < 360; i = i + 360 / mpoint)
            {
                float cx = (float)(Math.Cos(i * Math.PI / 180) * cRadius);
                float cy = (float)(-Math.Sin(i * Math.PI / 180) * cRadius);
                canvas.DrawCircle(cx, cy, mPointRadius, p);
            }
            //WaveDataUpdate();

            FftDataVisualizer();
            if (fftdata == null)
            {
                return;
            }
            int step = (int)Math.Round((double)fftdata.Length / mpoint);
            int j    = 0;;

            for (int i = 0; i < 360; i = i + 360 / mpoint)
            {
                if (fftdata[j] < 0)
                {
                    fftdata[j] = 127;
                }
                var   value       = fftdata[j];
                var   meterHeight = value * (500 - cRadius) / 256;
                float cx          = (float)(Math.Cos(i * Math.PI / 180) * cRadius);
                float cy          = (float)(-Math.Sin(i * Math.PI / 180) * cRadius);
                float cx1         = (float)(Math.Cos(i * Math.PI / 180) * (cRadius + meterHeight));
                float cy1         = (float)(-Math.Sin(i * Math.PI / 180) * (cRadius + meterHeight));
                canvas.DrawLine(cx, cy, cx1, cy1, p);
                j++;
            }
            //double angle = 0;
            //using (SKPath path = new SKPath())
            //{
            //    path.Rewind();
            //    for (int i = 0; i < mpoint; i++, angle += (360f / mpoint))
            //    {
            //        float posX = (float)((cRadius + pointdata[i]) * Math.Cos(RadianToDegree(angle)));
            //        float posY = (float)((cRadius + pointdata[i]) * Math.Sin(RadianToDegree(angle)));
            //        if (i == 0)
            //            path.MoveTo(posX, posY);
            //        else
            //            path.LineTo(posX, posY);
            //    }
            //    path.Close();
            //    canvas.DrawPath(path, p);
            //}
        }
Example #10
0
        void rozzirefresh(object sender, SkiaSharp.Views.Forms.SKPaintSurfaceEventArgs e)
        {
            SKImageInfo info    = e.Info;
            SKSurface   surface = e.Surface;

            SKCanvas canvas = surface.Canvas;

            canvas.Clear();

            SKPath Diagonale1 = new SKPath();

            SKPoint p = new SKPoint(0, 0);

            Diagonale1.MoveTo(p);

            p = new SKPoint(200, 200);
            Diagonale1.LineTo(p);

            p = new SKPoint(400, 0);
            Diagonale1.LineTo(p);

            SKPaint paint1 = new SKPaint
            {
                Style       = SKPaintStyle.Stroke,
                Color       = SKColors.DarkGreen,
                StrokeWidth = 3
            };

            canvas.DrawPath(Diagonale1, paint1);
        }
        private void SKCanvasView_PaintSurface(object sender, SkiaSharp.Views.Forms.SKPaintSurfaceEventArgs e)
        {
            SKImageInfo info    = e.Info;
            SKSurface   surface = e.Surface;
            SKCanvas    canvas  = surface.Canvas;

            canvas.Clear();
            canvas.DrawRect(info.Rect, _accentPaint);
            using (SKPath path = new SKPath())
            {
                path.MoveTo(0, 0);
                path.LineTo(info.Width * 0.7f, 0);
                path.LineTo(info.Width * .2f, info.Height);
                path.LineTo(0, info.Height);
                path.Close();
                canvas.DrawPath(path, _accentDarkPaint);
            }

            using (SKPath path = new SKPath())
            {
                path.MoveTo(0, 0);
                path.LineTo(info.Width * 0.33f, 0);
                path.LineTo(0, info.Height * .6f);
                path.Close();
                canvas.DrawPath(path, _accentExtraDarkPaint);
            }
        }
        private void SKCanvasView_PaintSurface(object sender, SkiaSharp.Views.Forms.SKPaintSurfaceEventArgs args)
        {
            SKImageInfo info    = args.Info;
            SKSurface   surface = args.Surface;
            SKCanvas    canvas  = surface.Canvas;

            canvas.Clear();

            using (SKPaint paint = new SKPaint())
            {
                // define the color for the shadow

                SKColor shadowColor = ((Color)Application.Current.Resources["ButtonBackgroundColor"]).ToSKColor();

                paint.IsDither    = true;
                paint.IsAntialias = true;
                paint.Color       = shadowColor;

                // create filter for drop shadow
                paint.ImageFilter = SKImageFilter.CreateDropShadow(
                    dx: 0, dy: 0,
                    sigmaX: 40, sigmaY: 40,
                    color: shadowColor,
                    shadowMode: SKDropShadowImageFilterShadowMode.DrawShadowOnly);

                // define where I want to draw the object
                var margin       = info.Width / 10;
                var shadowBounds = new SKRect(margin, -40, info.Width - margin, 10);
                canvas.DrawRoundRect(shadowBounds, 10, 10, paint);
            }
        }
        private void BackgroundGradient_PaintSurface(object sender, SkiaSharp.Views.Forms.SKPaintSurfaceEventArgs e)
        {
            SKImageInfo info    = e.Info;
            SKSurface   surface = e.Surface;
            SKCanvas    canvas  = surface.Canvas;

            canvas.Clear();

            // get the brush based on the theme
            SKColor gradientStart = ((Color)Application.Current.Resources["BackgroundGradientStartColor"]).ToSKColor();
            SKColor gradientMid   = ((Color)Application.Current.Resources["BackgroundGradientMidColor"]).ToSKColor();
            SKColor gradientEnd   = ((Color)Application.Current.Resources["BackgroundGradientEndColor"]).ToSKColor();

            // gradient backround

            /*backgroundBrush.Shader = SKShader.CreateRadialGradient
             *  (new SKPoint(0, info.Height * .8f),
             *  info.Height * .8f,
             *  new SKColor[] { gradientStart, gradientMid, gradientEnd },
             *  new float[] { 0, .5f, 1 },
             *  SKShaderTileMode.Clamp);*/

            backgroundBrush.Shader = SKShader.CreateLinearGradient(
                new SKPoint(0, 0),
                new SKPoint(info.Width, info.Height),
                new SKColor[] {
                gradientStart, gradientEnd
            },
                new float[] { 0, 1 },
                SKShaderTileMode.Clamp);
            SKRect backgroundBounds = new SKRect(0, 0, info.Width, info.Height);

            canvas.DrawRect(backgroundBounds, backgroundBrush);
        }
Example #14
0
        private void OnCanvasViewPaintSurface(object sender, SkiaSharp.Views.Forms.SKPaintSurfaceEventArgs args)
        {
            SKImageInfo info    = args.Info;
            SKSurface   surface = args.Surface;
            SKCanvas    canvas  = surface.Canvas;

            canvas.Clear();

            SKPaint paint = new SKPaint()
            {
                Style       = SKPaintStyle.Stroke,
                Color       = Color.Red.ToSKColor(),
                StrokeWidth = 50,
                IsAntialias = true
            };

            canvas.DrawCircle(info.Width / 2, info.Height / 2, 100, paint);

            if (showFill)
            {
                paint.Style = SKPaintStyle.Fill;
                paint.Color = SKColors.Blue;
                canvas.DrawCircle(info.Width / 2, info.Height / 2, 100, paint);
            }
        }
        void canvasFront_PaintSurface(System.Object sender, SkiaSharp.Views.Forms.SKPaintSurfaceEventArgs e)
        {
            SKCanvas canvas = e.Surface.Canvas;

            canvas.Clear();

            SKMatrix matrix = DrawHelper.GetFullSvgScaledMatrix(e.Info.Width, e.Info.Height, pictureFront);

            canvas.DrawPicture(pictureFront, ref matrix);
            float offsetY = e.Info.Height / 5;

            foreach (DrawItem item in DrawData.DrawnPathsFront)
            {
                SKPath p           = new SKPath(item.Path);
                float  offsetCalcY = (float)DrawHelper.GetOffsetCalculationsForFullDisplay(item.Area, offsetY);
                float  offsetCalcX = ((e.Info.Width - matrix.TransX) / 2.0f) * 0.375f;

                p.Transform(SKMatrix.CreateScaleTranslation(0.25f, 0.25f, offsetCalcX, offsetCalcY));

                _data.Add(new SvgData
                {
                    BodyRegion  = item.Area.ToString(),
                    IsFront     = true,
                    StrokeColor = item.Paint.Color.ToFormsColor(),
                    StrokeWidth = item.Paint.StrokeWidth,
                    SvgPath     = p.ToSvgPathData(),
                    ConcernName = item.Name
                });

                canvas.DrawPath(p, DrawHelper.GetScaledPaintObject(item.Paint.Color, item.Paint.StrokeWidth));
            }

            imageDataF = e.Surface.Snapshot();
        }
Example #16
0
        private void SKCanvasView_PaintSurface(object sender, SkiaSharp.Views.Forms.SKPaintSurfaceEventArgs e)
        {
            var info   = e.Info;
            var canvas = e.Surface.Canvas;

            canvas.Clear();

            if (BackgroundColor != Color.Transparent)
            {
                var fillpaint = new SKPaint
                {
                    Style = SKPaintStyle.Fill,

                    Color = BackgroundColor.ToSKColor(),
                };
                var fillradius = Math.Min(info.Width, info.Height) / 2;
                canvas.DrawCircle(info.Width / 2, info.Height / 2, fillradius, fillpaint);
            }
            var paint = new SKPaint
            {
                Style       = SKPaintStyle.Stroke,
                Color       = BorderColor.ToSKColor(),
                StrokeWidth = (float)BorderWidth,
            };
            var radius = (Math.Min(info.Width, info.Height) / 2) - paint.StrokeWidth;

            canvas.DrawCircle(info.Width / 2, info.Height / 2, radius, paint);
        }
Example #17
0
        /// <summary>
        ///  CanvasView PaintSurface maiking a panel
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="args"></param>
        private void SKCanvasView_PaintSurface(object sender, SkiaSharp.Views.Forms.SKPaintSurfaceEventArgs args)
        {
            SKImageInfo info    = args.Info;
            SKSurface   surface = args.Surface;
            SKCanvas    canvas  = surface.Canvas;

            canvas.Clear();

            // paint object for circles
            SKPaint circlePaint = new SKPaint
            {
                Style       = SKPaintStyle.Stroke,
                Color       = Color.FromHex("#75D59F").ToSKColor(),
                StrokeWidth = 3,
                IsAntialias = true
            };

            SKPaint filledCirclePaint = new SKPaint
            {
                Style       = SKPaintStyle.StrokeAndFill,
                Color       = Color.FromHex("#75D59F").ToSKColor(),
                StrokeWidth = 3,
                IsAntialias = true
            };

            SKPaint dottendLinePaint = new SKPaint
            {
                Style       = SKPaintStyle.Stroke,
                Color       = Color.FromHex("#75D59F").ToSKColor(),
                StrokeWidth = 3,
                IsAntialias = true,
                PathEffect  = SKPathEffect.CreateDash(new float[] { 20, 15 }, 0)
            };

            float margin      = 40;
            float radius      = 15;
            float linePadding = 100;

            canvas.DrawCircle(new SKPoint(margin, info.Height / 2), radius, filledCirclePaint);
            canvas.DrawCircle(new SKPoint(margin, info.Height / 2), radius * 2, circlePaint);

            canvas.DrawLine(
                new SKPoint(linePadding, info.Height / 2),
                new SKPoint(info.Width / 2 - linePadding, +info.Height / 2),
                circlePaint
                );

            canvas.DrawCircle(new SKPoint(info.Width / 2, info.Height / 2), radius, circlePaint);

            canvas.DrawLine(
                new SKPoint(info.Width / 2 + linePadding, info.Height / 2),
                new SKPoint(info.Width - linePadding, info.Height / 2),
                dottendLinePaint
                );

            canvas.DrawCircle(new SKPoint(info.Width - margin, info.Height / 2), radius, circlePaint);
        }
Example #18
0
        void canvasView_PaintSurface(System.Object sender, SkiaSharp.Views.Forms.SKPaintSurfaceEventArgs e)
        {
            var imageInfo = e.Info;
            var surface   = e.Surface;
            var canvas    = surface.Canvas;

            canvas.Clear();

            if (webBitmap != null)
            {
                canvas.DrawBitmap(webBitmap, new SKRect(0, 0, imageInfo.Width, imageInfo.Height));
            }



            foreach (var contour in completedPaths)
            {
                paint.Color = contour.Color;
                if (contour.ToolType == "Pen")
                {
                    canvas.DrawPath(contour.Path, paint);
                }
                else if (contour.ToolType == "Box")
                {
                    x1 = contour.Path.Points.FirstOrDefault().X;
                    y1 = contour.Path.Points.FirstOrDefault().Y;

                    x2 = contour.Path.Points.Max(x => x.X);
                    y2 = contour.Path.Points.Max(y => y.Y);

                    canvas.DrawRect(new SKRect(x1, y1, x2, y2), paint);
                }
                else if (contour.ToolType == "Text")
                {
                    if (contour.Text != null)
                    {
                        var x = contour.Path.Points.FirstOrDefault().X;
                        var y = contour.Path.Points.FirstOrDefault().Y;
                        textPaint.Color = contour.Color;
                        canvas.DrawText(contour.Text, x, y, textPaint);
                    }
                    else
                    {
                        if (Device.RuntimePlatform == Device.iOS)
                        {
                            Entry.Focus();
                        }
                    }
                }
            }

            foreach (var path in inProgressPaths.Values)
            {
                canvas.DrawPath(path, paint);
            }
        }
Example #19
0
        private void DefaultCanvas_PaintSurface(object sender, SkiaSharp.Views.Forms.SKPaintSurfaceEventArgs e)
        {
            // Skia stuff happens
            SKImageInfo info    = e.Info;
            SKSurface   surface = e.Surface;
            SKCanvas    canvas  = surface.Canvas;

            var minSize       = Math.Min(info.Size.Height / 2, info.Size.Width / 2);
            var rulesDistance = 5;

            canvas.Clear();

            SKRect containerRectangle = new SKRect(0, 0, minSize, minSize);

            canvas.Translate((e.Info.Width / 2) - containerRectangle.MidX, (e.Info.Height / 2) - containerRectangle.MidY);

            using (SKPath path = new SKPath())
            {
                path.AddArc(containerRectangle, startDegree, endDegree);
                canvas.DrawPath(path, gaugleDefaultColor);
            }

            using (SKPath path = new SKPath())
            {
                var anglePercent = (endDegree * Percent) / 100;
                path.AddArc(containerRectangle, startDegree, (float)anglePercent);
                canvas.DrawPath(path, gaugleFillColor);
            }

            circleMidX = containerRectangle.MidX;
            circleMidY = containerRectangle.MidY;

            canvas.Translate(circleMidX, circleMidY);

            canvas.DrawCircle(0, 0, 8, rectFillColor);

            canvas.RotateDegrees(360);
            if (usePercentage)
            {
                angle = Math.PI * (startDegree + (endDegree * Percent) / 100) / 180.0;
            }

            radius = containerRectangle.Height / 2;
            cx     = (float)(radius * Math.Cos(angle));
            cy     = (float)(radius * Math.Sin(angle));

            canvas.DrawCircle(cx, cy, 35, rectFillColor); // x=cos(angle)*rayon et y =sin(angle)*rayon

            canvas.RotateDegrees(startDegree - 45);
            for (int angle = 0; angle <= endDegree; angle += 5)
            {
                var size = (float)(containerRectangle.Height / 2.5) + rulesDistance;
                canvas.DrawLine(size, size, size + 10, size + 10, blackFillColor);
                canvas.RotateDegrees(5);
            }
        }
Example #20
0
        private void onCanvasViewPaintSurface(object sender, SkiaSharp.Views.Forms.SKPaintSurfaceEventArgs e)
        {
            SKCanvas c = e.Surface.Canvas;

            if (this.bitmap != null)
            {
                c.Clear();
                c.DrawBitmap(this.bitmap, new SKPoint(0, 0));
            }
        }
Example #21
0
        private void onCanvasViewPaintSurface(object sender, SkiaSharp.Views.Forms.SKPaintSurfaceEventArgs e)
        {
            SKCanvas c = e.Surface.Canvas;

            c.Clear();
            drawBackgroundGrid(c);
            c.SetMatrix(matrix);
            if (this.Bitmap != null)
            {
                c.DrawBitmap(this.Bitmap, new SKPoint(0, 0));
            }
        }
Example #22
0
        void Handle_PaintSurface(object sender, SkiaSharp.Views.Forms.SKPaintSurfaceEventArgs e)
        {
            //throw new NotImplementedException();
            SKImageInfo info    = e.Info;
            SKSurface   surface = e.Surface;
            SKCanvas    canvas  = surface.Canvas;

            canvas.Clear();

            //SKBitmap sKBitmap = SKBitmap.Decode(stream);
            //canvas.DrawBitmap(sKBitmap, info.Rect);
        }
        private void Tela(object sender, SkiaSharp.Views.Forms.SKPaintSurfaceEventArgs e)
        {
            e.Surface.Canvas.Clear();
            SKPath linea = new SKPath();

            SKPoint p = new SKPoint(50, 50);

            linea.MoveTo(p);

            p = new SKPoint(250, 50);
            linea.LineTo(p);

            p = new SKPoint(250, 350);
            linea.LineTo(p);

            p = new SKPoint(50, 350);
            linea.LineTo(p);

            p = new SKPoint(50, 48);
            linea.LineTo(p);

            SKPoint poligono = new SKPoint(70 + 62, -25 + 200);

            linea.MoveTo(poligono);

            p = new SKPoint(105 + 62, -25 + 200);
            linea.LineTo(p);

            p = new SKPoint(120 + 62, 5 + 200);
            linea.LineTo(p);

            p = new SKPoint(105 + 62, 35 + 200);
            linea.LineTo(p);

            p = new SKPoint(70 + 62, 35 + 200);
            linea.LineTo(p);

            p = new SKPoint(55 + 62, 5 + 200);
            linea.LineTo(p);

            p = new SKPoint(70 + 62, -25 + 200);
            linea.LineTo(p);

            SKPaint paint = new SKPaint
            {
                Style       = SKPaintStyle.Stroke,
                Color       = SKColors.Red,
                StrokeWidth = 5,
            };


            e.Surface.Canvas.DrawPath(linea, paint);
        }
Example #24
0
        private void PaintSurface(object sender, SkiaSharp.Views.Forms.SKPaintSurfaceEventArgs args)
        {
            float max = 0;

            foreach (TotalEntry ent in totalDict.Values)
            {
                if (ent.mileSum > max)
                {
                    max = (float)ent.mileSum;
                }
            }

            SKImageInfo info    = args.Info;
            SKSurface   surface = args.Surface;
            SKCanvas    canvas  = surface.Canvas;

            canvas.Clear();
            SKPaint paintA = new SKPaint
            {
                Style       = SKPaintStyle.Fill,
                Color       = Color.Red.ToSKColor(),
                StrokeWidth = 3
            };
            SKPaint paintBG = new SKPaint
            {
                Style       = SKPaintStyle.Fill,
                Color       = Color.LightGray.ToSKColor(),
                StrokeWidth = 3
            };
            SKPaint font = new SKPaint
            {
                Style       = SKPaintStyle.Fill,
                Color       = Color.Black.ToSKColor(),
                StrokeWidth = 10,
                TextSize    = 40 * info.Width / info.Height
            };

            canvas.DrawRect(0, 0, info.Width, info.Height, paintBG);

            float width = (info.Width / ((totalDict.Values.Count * 2) + 1));
            int   i     = 1;

            foreach (TotalEntry ent in totalDict.Values)
            {
                float value  = (float)ent.mileSum;
                float perc   = value / (max * 1.2f);
                float height = info.Height * perc;
                canvas.DrawRect(width * i, info.Height - height, width, height, paintA);
                canvas.DrawText(ent.key.ToString().Substring(0, 3), width * i, info.Height - height, font);
                i += 2;
            }
        }
Example #25
0
        private void PaintSurface2(SK.SKPaintSurfaceEventArgs e)
        {
            var canvas = e.Surface.Canvas;

            canvas.Clear(SKColors.Green);

            var canvasSize = e.Info.Rect;

            var paint = new SKPaint
            {
                Color     = SKColors.SkyBlue,
                StrokeCap = SKStrokeCap.Round
            };

            //Path based on
            //https://docs.microsoft.com/en-us/xamarin/graphics-games/skiasharp/introduction
            var path = new SKPath();

            path.MoveTo(71.4311121f, 56f);
            path.CubicTo(68.6763107f, 56.0058575f, 65.9796704f, 57.5737917f, 64.5928855f, 59.965729f);
            path.LineTo(43.0238921f, 97.5342563f);
            path.CubicTo(41.6587026f, 99.9325978f, 41.6587026f, 103.067402f, 43.0238921f, 105.465744f);
            path.LineTo(64.5928855f, 143.034271f);
            path.CubicTo(65.9798162f, 145.426228f, 68.6763107f, 146.994582f, 71.4311121f, 147f);
            path.LineTo(114.568946f, 147f);
            path.CubicTo(117.323748f, 146.994143f, 120.020241f, 145.426228f, 121.407172f, 143.034271f);
            path.LineTo(142.976161f, 105.465744f);
            path.CubicTo(144.34135f, 103.067402f, 144.341209f, 99.9325978f, 142.976161f, 97.5342563f);
            path.LineTo(121.407172f, 59.965729f);
            path.CubicTo(120.020241f, 57.5737917f, 117.323748f, 56.0054182f, 114.568946f, 56f);
            path.Close();

            var pathSize = path.Bounds;

            canvas.Translate(canvasSize.MidX, canvasSize.MidY);
            var shortSideRatio = Math.Min(canvasSize.Width / pathSize.Width, canvasSize.Height / pathSize.Width);

            canvas.Scale(0.9f * shortSideRatio);
            canvas.RotateDegrees(rotation);
            canvas.Translate(-pathSize.MidX, -pathSize.MidY);

            canvas.DrawPath(path, paint);
            path        = SKPath.ParseSvgPathData("M71.4 78.75 L76.4 78.75 L92.99 101.5 L76.4 124.24 L71.4 124.25 L87.99 101.5 Z");
            paint.Color = SKColors.White;
            paint.Style = SKPaintStyle.Fill;
            canvas.DrawPath(path, paint);

            path = SKPath.ParseSvgPathData("M114.57 78.75 L109.54 78.75 L92.99 101.5 L109.57 124.24 L114.57 124.25 L97.99 101.5 Z");
            canvas.DrawPath(path, paint);
        }
Example #26
0
        private void CardBackground_PaintSurface(object sender, SkiaSharp.Views.Forms.SKPaintSurfaceEventArgs args)
        {
            // seems that PaintSurface is called before the
            // binding context is set sometimes
            if (_viewModel == null)
            {
                return;
            }

            SKImageInfo info    = args.Info;
            SKSurface   surface = args.Surface;
            SKCanvas    canvas  = surface.Canvas;

            canvas.Clear();

            // draw top hero color
            canvas.DrawRoundRect(
                rect: new SKRect(0, (float)_cardTopAnimPosition, info.Width, info.Height),
                r: new SKSize(_cornerRadius, _cornerRadius),
                paint: _heroPaint);

            // work out the gradient needs to be
            var gradientRect = new SKRect(0, _gradientTransitionY, info.Width,
                                          _gradientTransitionY + _gradientHeight);
            // create the gradient
            var gradientPaint = new SKPaint()
            {
                Style = SKPaintStyle.Fill
            };

            gradientPaint.Shader = SKShader.CreateLinearGradient
                                   (
                start: new SKPoint(0, _gradientTransitionY),
                end: new SKPoint(0, _gradientTransitionY + _gradientHeight),
                colors: new SKColor[] { _heroColor, SKColors.White },
                colorPos: new float[] { 0, 1 },
                SKShaderTileMode.Clamp
                                   );
            // draw the gradient
            canvas.DrawRect(gradientRect, gradientPaint);

            // draw the white bit
            SKRect bottomRect = new SKRect(0, _gradientTransitionY + _gradientHeight,
                                           info.Width, info.Height);

            canvas.DrawRect(bottomRect, new SKPaint()
            {
                Color = SKColors.White
            });
        }
        private void Section_PaintSurface(object sender, SkiaSharp.Views.Forms.SKPaintSurfaceEventArgs e)
        {
            SKImageInfo info    = e.Info;
            SKSurface   surface = e.Surface;
            SKCanvas    canvas  = surface.Canvas;

            canvas.Clear();

            double wid = DeviceDisplay.MainDisplayInfo.Width;
            double hei = DeviceDisplay.MainDisplayInfo.Height;

            // get density
            float density = info.Size.Width / (float)this.Width;

            DrawSvgAtPoint(canvas, new SKPoint(0, 0), new Size(wid, hei), "ICA_Gospel_App.SVGs.Section1.S1E1.svg");
        }
Example #28
0
        private void SKCanvasView_PaintSurface(object sender, SkiaSharp.Views.Forms.SKPaintSurfaceEventArgs e)
        {
            var skImageInfo = e.Info;
            var skSurface   = e.Surface;
            var skCanvas    = skSurface.Canvas;

            var skCanvasWidth  = skImageInfo.Width;
            var skCanvasHeight = skImageInfo.Height;

            skCanvas.Clear();

            skCanvas.Translate((float)skCanvasWidth / 2, (float)skCanvasHeight / 2);



            SKPaint skpaintWhiteStroke = new SKPaint()
            {
                Style       = SKPaintStyle.Stroke,
                Color       = SKColors.Red,
                StrokeWidth = 40,
                IsAntialias = true,
                StrokeCap   = SKStrokeCap.Round
            };

            SKRect skRectangle = new SKRect();

            skRectangle.Size     = new SKSize(300, 300);
            skRectangle.Location = new SKPoint(-150, -150);

            _sweepAngle = 0 * scale + 360 * (1 - scale);

            float startAngle = -90;
            float sweepAngle = _sweepAngle; // (75 / 100) * 360

            SKPath skPath = new SKPath();

            skPath.AddArc(skRectangle, startAngle, sweepAngle);
            skCanvas.DrawPath(skPath, skpaintWhiteStroke);

            // filler animation
            skpaintWhiteStroke.Style = SKPaintStyle.Fill;
            skpaintWhiteStroke.Color = SKColors.DarkOrange;

            _sweepRadius = 0 * scale + 130 * (1 - scale);

            skCanvas.DrawCircle(0, 0, _sweepRadius, skpaintWhiteStroke);
        }
        private void CanvasView_PaintSurface(object sender, SkiaSharp.Views.Forms.SKPaintSurfaceEventArgs e)
        {
            SKImageInfo info    = e.Info;
            SKSurface   surface = e.Surface;
            SKCanvas    canvas  = surface.Canvas;

            canvas.Clear();

            SKRect rect = new SKRect();

            rect.Top    = (float)0;
            rect.Bottom = (float)info.Height;
            rect.Left   = (float)0;
            rect.Right  = (float)info.Width;


            SKPaint paint = new SKPaint()
            {
                Style       = SKPaintStyle.StrokeAndFill,
                StrokeWidth = 10,
                IsAntialias = true,
            };


            SKPoint start = new SKPoint()
            {
                X = info.Width / 2,
                Y = (float)0
            };

            SKPoint end = new SKPoint()
            {
                X = info.Width / 2,
                Y = (float)rect.Bottom
            };

            paint.Shader = SKShader.CreateLinearGradient(
                start,
                end,
                new SKColor[] { SKColors.Blue, SKColors.Transparent },
                null,
                SKShaderTileMode.Clamp
                );


            canvas.DrawRect(rect, paint);
        }
Example #30
0
        private void PaintSample_PaintSurface(object sender, SkiaSharp.Views.Forms.SKPaintSurfaceEventArgs e)
        {
            // 1 - Getting current surface
            var surface = e.Surface;

            // 2 - Getting the canvas to draw
            var canvas = surface.Canvas;

            //  3. Clearing the canvas
            canvas.Clear(SKColors.Bisque);
            stroke.StrokeWidth = 2;
            stroke.Style       = SKPaintStyle.Stroke;
            foreach (var touchPath in temporaryPaths)
            {
                canvas.DrawPath(touchPath.Value, stroke);
            }
        }