Esempio n. 1
0
        private void DrawMarker(SKCanvas canvas, Models.FishModel fish)
        {
            // position of the marker
            SKPoint markerPos = new SKPoint()
            {
                X = (float)(backgroundBitmap.Width * fish.AnchorX),
                Y = (float)(backgroundBitmap.Height * fish.AnchorY)
            };

            markerPos.Offset(-ScrollPosition, 0);

            // draw the marker
            canvas.DrawOval(markerPos, new SKSize(50, 20), markerRing);
            canvas.DrawOval(markerPos, new SKSize(25, 10), markerPaint);
            int lineLength = 300;

            canvas.DrawLine(markerPos, new SKPoint(markerPos.X, markerPos.Y - lineLength),
                            linePaint);

            // draw the fish
            if (fishAnnotations.ContainsKey(fish))
            {
                var     annotation = fishAnnotations[fish].OnscreenAnnotation;
                SKPoint fishPos    = markerPos;
                fishPos.Offset(-(annotation.Width / 2), -(annotation.Height / 2 + lineLength));
                canvas.DrawBitmap(annotation, fishPos);
            }
        }
        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);
            }
        }
        public static void DrawSmiley(this SKCanvas thisCanvas, SKRect thisRect, SKPaint solidPaint, SKPaint borderPaint, SKPaint eyePaint)
        {
            if (borderPaint == null)
            {
                throw new BasicBlankException("Must specify borders.  Otherwise, can't draw the happy face obviously");
            }
            if (eyePaint == null)
            {
                throw new BasicBlankException("Must use a paint for the eyes.  Otherwise, eyes will not be drawn obviously");
            }
            SKPath thisPath   = new SKPath();
            var    firstPoint = new SKPoint(thisRect.Location.X + (thisRect.Width * 0.1f), thisRect.Location.Y + (thisRect.Height * 4 / 7));

            thisPath.MoveTo(firstPoint);
            SKPoint secondPoint;
            SKPoint thirdPoint;

            secondPoint = new SKPoint(thisRect.Location.X + (thisRect.Width / 2), thisRect.Location.Y + (thisRect.Height * 1.1f));
            thirdPoint  = new SKPoint(thisRect.Location.X + (thisRect.Width * 0.9f), thisRect.Location.Y + (thisRect.Height * 4 / 7));
            thisPath.QuadTo(secondPoint, thirdPoint);
            if (solidPaint == null == false)
            {
                thisCanvas.DrawOval(thisRect, solidPaint);
            }
            thisCanvas.DrawPath(thisPath, borderPaint);
            thisCanvas.DrawOval(thisRect, borderPaint);
            var rect_Eye = SKRect.Create(thisRect.Location.X + (thisRect.Width / 4), thisRect.Location.Y + (thisRect.Height / 4), thisRect.Width / 10, thisRect.Width / 10);

            thisCanvas.DrawOval(rect_Eye, eyePaint);
            rect_Eye = SKRect.Create(thisRect.Location.X + (thisRect.Width * 3 / 4) - (thisRect.Width / 10), thisRect.Location.Y + (thisRect.Height / 4), thisRect.Width / 10, thisRect.Width / 10);
            thisCanvas.DrawOval(rect_Eye, eyePaint);
        }
Esempio n. 4
0
        void OnCanvasViewPaintSurface(object sender, SKPaintSurfaceEventArgs args)
        {
            SKImageInfo info    = args.Info;
            SKSurface   surface = args.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);

            SKPaint paint = new SKPaint
            {
                Style       = SKPaintStyle.Stroke,
                Color       = SKColors.Blue,
                StrokeWidth = 50
            };

            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);
        }
        public override void DrawImage(SKCanvas dc)
        {
            var thisRect = GetMainRect();

            if (NeedsWhiteBorders == true)
            {
                dc.DrawRect(thisRect, _whitePaint);
                dc.DrawRect(thisRect, _thickBorder);
                thisRect = SKRect.Create(thisRect.Location.X + 5, thisRect.Location.Y + 5, thisRect.Width - 10, thisRect.Width - 10);
            }
            else
            {
                thisRect = SKRect.Create(thisRect.Location.X + 2, thisRect.Location.Y + 2, thisRect.Width - 4, thisRect.Height - 4);
            }
            if (thisRect.Width != thisRect.Height)
            {
                throw new BasicBlankException("Rethink because width and height is not the same so its not a true circle.  Values are " + thisRect.Width + ", " + thisRect.Height + ".  Actual Was " + ActualWidth + ", " + ActualHeight + ".  Needs White Borders Is " + NeedsWhiteBorders);
            }
            if (MainColor.Equals(cs.Transparent) == true)
            {
                if (NeedsWhiteBorders == false)
                {
                    throw new Exception("Will cause blank.  If we want that, rethink");
                }
                return;
            }
            dc.DrawOval(thisRect, MainPaint);
            dc.DrawOval(thisRect, _borderPaint);
        }
Esempio n. 6
0
        public Elipse(int x, int y, int width, int height, int widthBorder, Color borderColor, Color color)
        {
            BorderColor = borderColor;
            FillColor   = color;
            X           = x;
            Y           = y;
            SKPaint paint = new SKPaint
            {
                Style       = SKPaintStyle.Fill,
                Color       = borderColor.ToSKColor(),
                StrokeWidth = widthBorder
            };

            paint.IsAntialias = true;
            SKBitmap sKBitmap = new SKBitmap(width, height);

            using (SKCanvas bitmapCanvas = new SKCanvas(sKBitmap))
            {
                bitmapCanvas.Clear();
                bitmapCanvas.DrawOval(width / 2, height / 2, width / 2, height / 2, paint);
                paint.Color = color.ToSKColor();
                bitmapCanvas.DrawOval(width / 2, height / 2, width / 2 - widthBorder, height / 2 - widthBorder, paint);
            }
            Bitmap = sKBitmap;
        }
        public void Render(SKCanvas canvas, MapDataContext mapDataContext)
        {
            using (var paint = new SKPaint())
            {
                paint.Style       = SKPaintStyle.StrokeAndFill;
                paint.IsAntialias = true;

                foreach (var solarSystem in mapDataContext.SolarSystems)
                {
                    if (solarSystem.allianceID != null && solarSystem.allianceID != 0)
                    {
                        var md5  = MD5.Create();
                        var hash = md5.ComputeHash(Encoding.UTF8.GetBytes(solarSystem.allianceID.ToString()));
                        paint.Color = new SKColor(hash[0], hash[1], hash[2]);
                        canvas.DrawOval(MapRenderUtils.EveCartesianToScreenPoint(solarSystem.x, solarSystem.z), new SKSize(2.0f, 1.0f), paint);
                    }
                    else
                    {
                        paint.Color = new SKColor(0xB0, 0xB0, 0xFF);
                        canvas.DrawOval(MapRenderUtils.EveCartesianToScreenPoint(solarSystem.x, solarSystem.z), new SKSize(1.0f, 0.5f), paint);
                    }

                    // paint.Color = new SKColor(randomBytes[0], randomBytes[1], randomBytes[2]);
                }
                canvas.DrawLine(new SKPoint(0.0f, 0.0f), new SKPoint(100.0f, 100.0f), paint);
            }
        }
        public override void DrawImage(SKCanvas dc)
        {
            if (ShapeUsed == (int)EnumShapes.None)
            {
                return;
            }
            dc.Clear();                                                                              // i think
            DrawSelector(dc);                                                                        // i think
            var thisHeight = GetFontSize(40);                                                        // well see how this goes.
            var thisSize   = new SKSize(thisHeight, thisHeight);
            var pointList  = ImageHelpers.GetPoints(ShapeUsed, HowMany, Location, true, thisHeight); // can always be adjusted.   test on desktop first anyways.

            foreach (var thisPoint in pointList)
            {
                var thisRect = SKRect.Create(thisPoint, thisSize);
                if ((int)ShapeUsed == (int)EnumShapes.Balls)
                {
                    dc.DrawOval(thisRect, _redPaint);
                    dc.DrawOval(thisRect, _borderPaint);
                }
                else if ((int)ShapeUsed == (int)EnumShapes.Cones)
                {
                    ImageHelpers.DrawCone(dc, thisRect);
                }
                else if ((int)ShapeUsed == (int)EnumShapes.Cubes)
                {
                    ImageHelpers.DrawCube(dc, thisRect);
                }
                else if ((int)ShapeUsed == (int)EnumShapes.Stars)
                {
                    dc.DrawStar(thisRect, _yellowPaint, _borderPaint);
                }
            }
        }
Esempio n. 9
0
        public void Render(SKCanvas canvas, IGeometryVisual geometry, double scale)
        {
            var oval = geometry as IOval;

            if (oval == null || !oval.IsValid)
            {
                return;
            }
            using (var paint = new SKPaint())
            {
                // Draw Oval
                paint.Color       = oval.ToolSettings.SelectedColor.ToSkiaColor();
                paint.IsAntialias = true;
                paint.IsStroke    = true;
                paint.StrokeWidth = (float)(oval.Size * scale);
                canvas.DrawOval((float)(oval.Start.X * scale), (float)(oval.Start.Y * scale), (float)(oval.End.X - oval.Start.X) * (float)scale, (float)(oval.End.Y - oval.Start.Y) * (float)scale, paint);
                // Fill Oval
                paint.Color    = oval.ToolSettings.SelectedColor.ToFillColor().ToSkiaColor();
                paint.IsStroke = false;
                if (oval.IsFilled)
                {
                    canvas.DrawOval((float)(oval.Start.X * scale), (float)(oval.Start.Y * scale), (float)(oval.End.X - oval.Start.X) * (float)scale, (float)(oval.End.Y - oval.Start.Y) * (float)scale, paint);
                }
                if (oval.IsStenciled)
                {
                    using (var shader = ShaderFactory.Line(oval.ToolSettings.SelectedColor.ToSkiaColor()))
                    {
                        paint.Shader = shader;
                    }
                    canvas.DrawOval((float)(oval.Start.X * scale), (float)(oval.Start.Y * scale), (float)(oval.End.X - oval.Start.X) * (float)scale, (float)(oval.End.Y - oval.Start.Y) * (float)scale, paint);
                }
            }
        }
Esempio n. 10
0
        public void Render(SKCanvas canvas, IGeometryVisual geometry, double scale)
        {
            var oval = geometry as IOval;

            if (oval == null || !oval.IsValid)
            {
                return;
            }
            using (var paint = new SKPaint())
            {
                // Draw Oval
                paint.Color       = oval.Color.ToSkiaColor();
                paint.IsAntialias = true;
                paint.IsStroke    = true;
                paint.StrokeWidth = (float)(oval.Size * scale);
                canvas.DrawOval((float)(oval.Start.X * scale), (float)(oval.Start.Y * scale), (float)(oval.End.X - oval.Start.X) * (float)scale, (float)(oval.End.Y - oval.Start.Y) * (float)scale, paint);
                // Fill Oval
                if (!oval.IsFilled)
                {
                    return;
                }
                paint.Color    = oval.Color.ToFillColor().ToSkiaColor();
                paint.IsStroke = false;
                canvas.DrawOval((float)(oval.Start.X * scale), (float)(oval.Start.Y * scale), (float)(oval.End.X - oval.Start.X) * (float)scale, (float)(oval.End.Y - oval.Start.Y) * (float)scale, paint);
            }
        }
Esempio n. 11
0
 public override void DrawEllipse(RectangleF rect, Color color, float thickness)
 {
     PreparePaint(skPaint);
     skPaint.Color       = color.ToSkia();
     skPaint.IsStroke    = true;
     skPaint.StrokeWidth = thickness;
     skCanvas.DrawOval(rect.ToSkia(), skPaint);
 }
Esempio n. 12
0
        public void DrawEllipse(Pen pen, RectangleF rect)
        {
            pen.ApplyToSKPaint(skPaint);
            skPaint.IsAntialias = true;
            var r = Convert(rect);

            skCanvas.DrawOval(r, skPaint);
        }
Esempio n. 13
0
        public void DrawEllipse(float left, float top, float width, float height)
        {
            var skiaRect = new SKRect(left, top, left + width, top - width);

            SetFillStyle();
            _skiaCanvas.DrawOval(skiaRect, _skiaPaint);
            SetLineStyle();
            _skiaCanvas.DrawOval(skiaRect, _skiaPaint);
        }
Esempio n. 14
0
        public void DrawEllipse(SvgEllipse svgEllipse, bool ignoreDisplay)
        {
            if (!CanDraw(svgEllipse, ignoreDisplay))
            {
                return;
            }

            float cx = svgEllipse.CenterX.ToDeviceValue(null, UnitRenderingType.Horizontal, svgEllipse);
            float cy = svgEllipse.CenterY.ToDeviceValue(null, UnitRenderingType.Vertical, svgEllipse);
            float rx = svgEllipse.RadiusX.ToDeviceValue(null, UnitRenderingType.Other, svgEllipse);
            float ry = svgEllipse.RadiusY.ToDeviceValue(null, UnitRenderingType.Other, svgEllipse);

            if (rx <= 0f || ry <= 0f)
            {
                return;
            }

            var skRectBounds = SKRect.Create(cx - rx, cy - ry, rx + rx, ry + ry);

            _skCanvas.Save();

            var skMatrix = SkiaUtil.GetSKMatrix(svgEllipse.Transforms);

            SetTransform(skMatrix);
            SetClipPath(svgEllipse, _disposable);

            var skPaintOpacity = SetOpacity(svgEllipse, _disposable);

            var skPaintFilter = SetFilter(svgEllipse, _disposable);

            if (SkiaUtil.IsValidFill(svgEllipse))
            {
                var skPaintFill = SkiaUtil.GetFillSKPaint(svgEllipse, _skSize, skRectBounds, _disposable);
                _skCanvas.DrawOval(cx, cy, rx, ry, skPaintFill);
            }

            if (SkiaUtil.IsValidStroke(svgEllipse))
            {
                var skPaintStroke = SkiaUtil.GetStrokeSKPaint(svgEllipse, _skSize, skRectBounds, _disposable);
                _skCanvas.DrawOval(cx, cy, rx, ry, skPaintStroke);
            }

            if (skPaintFilter != null)
            {
                _skCanvas.Restore();
            }

            if (skPaintOpacity != null)
            {
                _skCanvas.Restore();
            }

            _skCanvas.Restore();
        }
 private void DrawEllipse(SKCanvas canvas, EllipseDrawingFigure ellipse)
 {
     _paint.Color = new SKColor(0, 0, 0);
     canvas.DrawOval(ellipse.Rectangle.Margin(2), _paint);
     _paint.Color = new SKColor(255, 255, 255);
     canvas.DrawOval(ellipse.Rectangle, _paint);
     _paint.Color     = new SKColor(0, 0, 0);
     _paint.TextAlign = SKTextAlign.Center;
     _paint.TextSize  = GridWidth;
     DrawText(canvas, ellipse.Center, ellipse.Text);
 }
Esempio n. 16
0
        private void DrawEllipseInternal(SKCanvas canvas, SKPaint brush, SKPaint pen, bool isStroked, bool isFilled, ref SKRect rect)
        {
            if (isFilled)
            {
                canvas.DrawOval(rect, brush);
            }

            if (isStroked)
            {
                canvas.DrawOval(rect, pen);
            }
        }
        void OnCanvasViewPaintSurface(object sender, SKPaintSurfaceEventArgs args)
        {
            SKImageInfo info    = args.Info;
            SKSurface   surface = args.Surface;
            SKCanvas    canvas  = surface.Canvas;

            canvas.Clear();

            // Transform for 100-radius circle in center
            canvas.Translate(info.Width / 2, info.Height / 2);
            canvas.Scale(Math.Min(info.Width / 200, info.Height / 200));

            // Draw circles for hour and minute marks
            SKRect rect = new SKRect(-90, -90, 90, 90);

            canvas.DrawOval(rect, minuteMarkPaint);
            canvas.DrawOval(rect, hourMarkPaint);

            // Get time
            DateTime dateTime = DateTime.Now;

            // Draw hour hand
            canvas.Save();
            canvas.RotateDegrees(30 * dateTime.Hour + dateTime.Minute / 2f);
            canvas.DrawPath(hourHandPath, handStrokePaint);
            canvas.DrawPath(hourHandPath, handFillPaint);
            canvas.Restore();

            // Draw minute hand
            canvas.Save();
            canvas.RotateDegrees(6 * dateTime.Minute + dateTime.Second / 10f);
            canvas.DrawPath(minuteHandPath, handStrokePaint);
            canvas.DrawPath(minuteHandPath, handFillPaint);
            canvas.Restore();

            // Draw second hand
            double t = dateTime.Millisecond / 1000.0;

            if (t < 0.5)
            {
                t = 0.5 * Easing.SpringIn.Ease(t / 0.5);
            }
            else
            {
                t = 0.5 * (1 + Easing.SpringOut.Ease((t - 0.5) / 0.5));
            }

            canvas.Save();
            canvas.RotateDegrees(6 * (dateTime.Second + (float)t));
            canvas.DrawPath(secondHandPath, handStrokePaint);
            canvas.Restore();
        }
Esempio n. 18
0
        protected override void DrawBoard(SKCanvas canvas)
        {
            canvas.Clear();
            canvas.DrawRect(_whiteRect, _whitePaint);
            foreach (var thisLine in _gameContainer.LineList !.Values)
            {
                SKPaint thisPen;
                if (thisLine.IsTaken)
                {
                    if (thisLine.Equals(_gameContainer.PreviousLine))
                    {
                        thisPen = _greenLine !;
                    }
                    else
                    {
                        thisPen = _brownLine !;
                    }
                    canvas.DrawLine(thisLine.StartingPoint, thisLine.FinishingPoint, thisPen);
                }
            }
            var tempList = _gameContainer.SquareList !.Values.Where(items => items.Player > 0).ToCustomBasicList();

            tempList.ForEach(thisSquare =>
            {
                SKPaint thisPaint;
                if (thisSquare.Color == 1)
                {
                    thisPaint = _blueSolid !;
                }
                else if (thisSquare.Color == 2)
                {
                    thisPaint = _redSolid !;
                }
                else
                {
                    throw new BasicBlankException("Must fill in color");
                }
                canvas.DrawOval(thisSquare.Rectangle, thisPaint);
            });
            foreach (var thisDot in _gameContainer.DotList !.Values)
            {
                if (thisDot.IsSelected)
                {
                    canvas.DrawOval(thisDot.Bounds, _yellowPaint);
                    canvas.DrawOval(thisDot.Bounds, _thickSelect);
                }
                else
                {
                    canvas.DrawOval(thisDot.Dot, _blackPaint);
                }
            }
        }
Esempio n. 19
0
        protected override void InternalDraw(SKCanvas canvas)
        {
            base.InternalDraw(canvas);

            using (var paint = new SKPaint())
            {
                paint.IsAntialias = true;

                if (HasShadow)
                {
                    using (var filter = SKMaskFilter.CreateBlur(SKBlurStyle.Normal, 2.0f))
                    {
                        paint.MaskFilter = filter;
                        paint.Color      = Color.Gray.ToSKColor();

                        switch (Shape)
                        {
                        case MycoShapes.Rectangle:
                            canvas.DrawRect(RenderBounds.ToSKRect(), paint);
                            break;

                        case MycoShapes.RoundedRectangle:
                            canvas.DrawRoundRect(RenderBounds.ToSKRect(), RoundedRectRadius, RoundedRectRadius, paint);
                            break;

                        case MycoShapes.Oval:
                            canvas.DrawOval(RenderBounds.ToSKRect(), paint);
                            break;
                        }

                        paint.MaskFilter = null;
                    }
                }

                paint.Color = ShapeColor.ToSKColor();

                switch (Shape)
                {
                case MycoShapes.Rectangle:
                    canvas.DrawRect(RenderBounds.ToSKRect(), paint);
                    break;

                case MycoShapes.RoundedRectangle:
                    canvas.DrawRoundRect(RenderBounds.ToSKRect(), RoundedRectRadius, RoundedRectRadius, paint);
                    break;

                case MycoShapes.Oval:
                    canvas.DrawOval(RenderBounds.ToSKRect(), paint);
                    break;
                }
            }
        }
        public void Draw(SKCanvas canvas, SKPaint paint, int posH, int PosV)
        {
            foreach (IFragments fragment in items)
            {
                IShape item = fragment.GetFragment();
                item.UpdatePoints(posH, PosV);

                int type = item.GetType();

                if (type == 1)
                {
                    Bezier bezier = item as Bezier;

                    SKPath path = new SKPath();
                    path.MoveTo(bezier.x);

                    path.CubicTo(bezier.x, bezier.y, bezier.z);

                    canvas.DrawPath(path, paint);
                }
                else if (type == 0)
                {
                    Line line = item as Line;

                    canvas.DrawLine(line.x, line.y, paint);
                }
                else
                {
                    Oval oval = item as Oval;

                    canvas.DrawOval(oval.x.X, oval.x.Y, oval.rx, oval.ry, paint);
                }
            }
        }
        private void DrawTrouble(SKCanvas canvas, SKRect bounds)
        {
            SKPath  gp = new SKPath();
            SKColor firstColor;
            SKColor secondColor;

            firstColor  = new SKColor(255, 255, 255, 150); // 60 instead of 100 seems to do the trick
            secondColor = new SKColor(0, 0, 0, 150);
            var    br_Fill = MiscHelpers.GetLinearGradientPaint(firstColor, secondColor, bounds, MiscHelpers.EnumLinearGradientPercent.Angle180);
            SKRect rect_Temp;
            float  int_Offset = bounds.Width / 6;

            gp.AddLine(new SKPoint(bounds.Left + int_Offset, bounds.Top + (bounds.Height / 4)), new SKPoint((bounds.Left + bounds.Width) - (int_Offset), bounds.Top + (bounds.Height / 4)), true);
            gp.ArcTo(SKRect.Create(bounds.Left + int_Offset, (bounds.Top + (bounds.Height / 2)) - int_Offset, bounds.Width - (int_Offset * 2), bounds.Height / 2), 0, 180, false);
            gp.Close();
            canvas.DrawPath(gp, MainPaint);
            canvas.DrawPath(gp, br_Fill);
            gp        = new SKPath();
            rect_Temp = SKRect.Create(bounds.Left + int_Offset, bounds.Top, bounds.Width - (int_Offset * 2), bounds.Height / 2);
            gp.AddOval(rect_Temp);
            gp.Close();
            canvas.DrawPath(gp, MainPaint);
            rect_Temp = SKRect.Create(rect_Temp.Left + (rect_Temp.Width / 4), rect_Temp.Top + (rect_Temp.Height / 4), (rect_Temp.Width / 2), rect_Temp.Height / 2);
            br_Fill   = MiscHelpers.GetLinearGradientPaint(secondColor, firstColor, bounds, MiscHelpers.EnumLinearGradientPercent.Angle180);
            canvas.DrawOval(rect_Temp, br_Fill);
        }
Esempio n. 22
0
        private void RedrawParticles(SKBitmap grphxDrawerParticles)
        {
            int alpha = 0;

            for (var ii = 0; ii < oSmoker.Particles.Count; ii++)
            {
                Particle p = oSmoker.Particles[ii];
                p.GetColorToLife(ref alpha, ref m_color, m_direction);

                using (SKPaint skpaint = new SKPaint {
                    Color = new SKColor((byte)m_color, (byte)m_color, (byte)m_color, (byte)alpha)
                })
                {
                    var pX = (p.Location.X - SettingsHolder.Instance.ParticleSize / 2F);

                    var pY = (p.Location.Y - SettingsHolder.Instance.ParticleSize / 2F);
                    if (pX < grphxDrawerParticles.Width && pX > 0 &&
                        pY < grphxDrawerParticles.Height && pY > 0)
                    {
                        using (SKCanvas skcanvas = new SKCanvas(grphxDrawerParticles))
                        {
                            skcanvas.DrawOval(pX, pY, SettingsHolder.Instance.ParticleSize, SettingsHolder.Instance.ParticleSize, skpaint);
                        }
                    }
                }
            }
        }
Esempio n. 23
0
        //public void IncorrectSignal()
        //{

        //}

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

            canvas.Clear();

            var sectionWidth = info.Width / IndicatorsCount;
            var centers      = new List <SKPoint>();

            for (int i = 0; i < IndicatorsCount; i++)
            {
                centers.Add(new SKPoint(sectionWidth * i + sectionWidth / 2, info.Height / 2));
            }

            float radius = Math.Min(sectionWidth, info.Height) * 0.2f;

            for (int i = 0; i < IndicatorsCount; i++)
            {
                using (var curIndicator = new SKPaint())
                {
                    var curCenter = centers[i];

                    curIndicator.StrokeWidth = radius / 2;
                    curIndicator.IsAntialias = true;

                    curIndicator.Style = SKPaintStyle.StrokeAndFill;
                    curIndicator.Color = SKColors.Gray;
                    canvas.DrawOval(curCenter.X, curCenter.Y, radius, radius, curIndicator);

                    if (ActiveIndicatorsCount > i)
                    {
                        curIndicator.Style = SKPaintStyle.Fill;
                        curIndicator.Color = SKColors.White;
                        canvas.DrawOval(curCenter.X, curCenter.Y, radius, radius, curIndicator);
                    }
                    else
                    {
                        curIndicator.Style = SKPaintStyle.Fill;
                        curIndicator.Color = SKColors.LightGray;
                        canvas.DrawOval(curCenter.X, curCenter.Y, radius, radius, curIndicator);
                    }
                }
            }
        }
        void OnCanvasViewPaintSurface(object sender, SKPaintSurfaceEventArgs args)
        {
            SKCanvas canvas = args.Surface.Canvas;

            canvas.Clear();

            foreach (EllipseDrawingFigure figure in completedFigures)
            {
                paint.Color = figure.Color;
                canvas.DrawOval(figure.Rectangle, paint);
            }
            foreach (EllipseDrawingFigure figure in inProgressFigures.Values)
            {
                paint.Color = figure.Color;
                canvas.DrawOval(figure.Rectangle, paint);
            }
        }
        public void DrawOval(SKRect rect, SKPaint paint)
        {
            canvas.DrawOval(rect, paint);

            if (calculateBounds)
            {
                displayObject.addBoundingRect(rect);
            }
        }
        void OnCanvasViewPaintSurface(object sender, SKPaintSurfaceEventArgs args)
        {
            SKImageInfo info    = args.Info;
            SKSurface   surface = args.Surface;
            SKCanvas    canvas  = surface.Canvas;

            canvas.Clear();

            if (viewModel.Engine != null)
            {
                canvas.DrawOval(viewModel.Engine.PlayerBall.Position.X, viewModel.Engine.PlayerBall.Position.Y, viewModel.Engine.PlayerBall.Radius, viewModel.Engine.PlayerBall.Radius, viewModel.Engine.PlayerBall.Paint);

                foreach (Ball ball in viewModel.Engine.DeadlyBalls)
                {
                    canvas.DrawOval(ball.Position.X, ball.Position.Y, ball.Radius, ball.Radius, ball.Paint);
                }
            }
        }
Esempio n. 27
0
        public void FillEllipse(double x1, double y1, double w, double h, ColorValue FillColor, ColorValue BorderColor)
        {
            using (var paint = new SKPaint())
            {
                paint.IsAntialias = true;

                var rect = new SKRect((float)x1, (float)y1, (float)(x1 + w), (float)(y1 + h));
                paint.Color    = GetColorFromColorValue(FillColor);
                paint.IsStroke = false;

                canvas.DrawOval(rect, paint);

                paint.Color       = GetColorFromColorValue(BorderColor);
                paint.IsStroke    = true;
                paint.StrokeWidth = 0.5f;
                canvas.DrawOval(rect, paint);
            }
        }
Esempio n. 28
0
        private void CanvasView_PaintSurface(object sender, SkiaSharp.Views.Forms.SKPaintSurfaceEventArgs e)
        {
            SKImageInfo info   = e.Info;
            SKCanvas    canvas = e.Surface.Canvas;

            SKPaint strokePaint = GetPaintColor(SKPaintStyle.Stroke, null, 10, SKStrokeCap.Square);
            SKPaint dotPaint    = GetPaintColor(SKPaintStyle.Fill, "#DE0469");

            canvas.Clear();

            SKRect arcRect = new SKRect(10, 10, info.Width - 10, info.Height - 10);

            canvas.DrawOval(new SKRect(25, 25, info.Width - 25, info.Height - 25), GetPaintColor(SKPaintStyle.Fill, "#FFFFFF"));

            strokePaint.Shader = SKShader.CreateLinearGradient(
                new SKPoint(arcRect.Left, arcRect.Top),
                new SKPoint(arcRect.Right, arcRect.Bottom),
                new SKColor[] { SKColor.Parse("#DE0469"), SKColors.Transparent },
                new float[] { 0, 1 },
                SKShaderTileMode.Repeat);

            Path.ArcTo(arcRect, 45, 105, true);
            canvas.DrawPath(Path, strokePaint);

            canvas.Translate(info.Width / 2, info.Height / 2);
            canvas.Scale(info.Width / 200f);

            canvas.Save();
            canvas.RotateDegrees(240);
            canvas.DrawCircle(0, -75, 2, dotPaint);
            canvas.Restore();

            DateTime dateTime = DateTime.Now;

            //Draw hour hand
            canvas.Save();
            canvas.RotateDegrees(30 * dateTime.Hour + dateTime.Minute / 2f);
            canvas.DrawLine(0, 5, 0, -60, GetPaintColor(SKPaintStyle.Stroke, "#262626", 4, SKStrokeCap.Square));
            canvas.Restore();

            //Draw minute hand
            canvas.Save();
            canvas.RotateDegrees(6 * dateTime.Minute + dateTime.Second / 10f);
            canvas.DrawLine(0, 10, 0, -90, GetPaintColor(SKPaintStyle.Stroke, "#DE0469", 2, SKStrokeCap.Square));
            canvas.Restore();

            canvas.DrawCircle(0, 0, 5, dotPaint);

            SecondsTxt.Text = dateTime.Second.ToString("00");
            TimeTxt.Text    = dateTime.ToString("hh:mm");
            PeriodTxt.Text  = dateTime.Hour >= 12 ? "PM" : "AM";

            var alarmDiff = GetNextAlarm() - dateTime;

            AlarmTxt.Text = $"{alarmDiff.Hours}h {alarmDiff.Minutes}m until next alarm";
        }
Esempio n. 29
0
        protected override void DrawTool(SKCanvas c)
        {
            // Draw oval
            var rx = (p1.X - p0.X) / 2f;
            var ry = (p1.Y - p0.Y) / 2f;
            var cx = p0.X + rx;
            var cy = p0.Y + ry;

            c.DrawOval(cx, cy, rx, ry, PaintTool);
        }
Esempio n. 30
0
        void Paintbitmap(SKCanvas canvas)
        {
            //SKCanvas canvas = _surface.Canvas;
            canvas.Clear();

            float maxRadius = 0.75f * Math.Min(100, 100) / 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;
                canvas.DrawOval(Width / 2, Height / 2, xRadius, yRadius, paint);

                paint.Style = SKPaintStyle.Fill;
                paint.Color = SKColors.SkyBlue;
                canvas.DrawOval(Width / 2, Height / 2, xRadius, yRadius, paint);
            }
            // GetImageSource();
            // Painted?.Invoke(this, new EventArgs());


            /*   if (color == Color.Green)
            *      color = Color.Red;
            *  else color = Color.Green;
            *  SKPaint paint = new SKPaint
            *  {
            *      IsAntialias=true,
            *      Style = SKPaintStyle.Stroke,
            *      Color = color.ToSKColor(),
            *      StrokeWidth = 2
            *  };
            *  sKCanvas.Scale((float)scale);
            *  // canvas.DrawCircle(info.Width / 2, info.Height / 2, 100, paint);
            *  canvas.DrawCircle(50, 50, 25, paint);
            *
            *  // snapshot = surface.Snapshot();
            *  OnPropertyChanged("Source");*/
        }