コード例 #1
0
        public void DrawGraph(SKCanvas _canvasGraph)
        {
            if (refreshCounter >= GraphicsClearanceRate)
            {
                _canvasGraph.Clear(SKColors.Transparent);
                refreshCounter = 0;
            }
            refreshCounter += GraphicsUpdateRate;

            if (Graph1Enabled && displayArray1 != null)
            {
                _canvasGraph.DrawPoints(PointMode1, displayArray1, GraphPaint1);
            }
            if (Graph2Enabled && displayArray2 != null)
            {
                _canvasGraph.DrawPoints(PointMode2, displayArray2, GraphPaint2);
            }
            if (Graph3Enabled && displayArray3 != null)
            {
                _canvasGraph.DrawPoints(PointMode3, displayArray3, GraphPaint3);
            }
            if (Graph4Enabled && displayArray4 != null)
            {
                _canvasGraph.DrawPoints(PointMode4, displayArray4, GraphPaint4);
            }
            if (Graph5Enabled && displayArray5 != null)
            {
                _canvasGraph.DrawPoints(PointMode5, displayArray5, GraphPaint5);
            }
        }
コード例 #2
0
        public void Draw(SKCanvas canvas)
        {
            canvas.Clear(new SKColor(255, 255, 255));



            using (var Pen = new SKPaint
            {
                Color = new SKColor(0, 0, 0),
                Style = SKPaintStyle.Stroke,
                IsAntialias = true,
                StrokeWidth = 5
            })
                using (var Selected = new SKPaint
                {
                    Color = new SKColor(64, 64, 255),
                    IsAntialias = true,
                    Style = SKPaintStyle.Fill,
                    StrokeWidth = 15
                })
                {
                    foreach (var floor in _displayModel.Floors)
                    {
                        if (!floor.Visible)
                        {
                            continue;
                        }

                        foreach (var space in floor.Spaces)
                        {
                            foreach (var polygon in space.Polygons)
                            {
                                var points = polygon.Points
                                             .Select(_viewPort.WorldToScreen)
                                             .Select(p => new SKPoint(p.X, p.Y))
                                             .ToList();
                                points.Add(points[0]);

                                canvas.DrawPoints(SKPointMode.Polygon, points.ToArray(), Pen);

                                if (space.Selected)
                                {
                                    canvas.DrawPoints(SKPointMode.Polygon, points.ToArray(), Selected);
                                }
                            }
                        }
                    }
                }
        }
コード例 #3
0
    private void DrawCore(string captcha, Action <SKData> postAction)
    {
        var sizeAndPoints = ComputeSizeAndPoints(captcha);
        var imageSize     = sizeAndPoints.Size;
        var imageInfo     = new SKImageInfo(imageSize.Width, imageSize.Height,
                                            SKColorType.Bgra8888, SKAlphaType.Premul);

        using (var bmp = new SKBitmap(imageInfo))
            using (var canvas = new SKCanvas(bmp))
            {
                // Clear
                canvas.DrawColor(_backgroundColor);

                // 绘制噪点
                var points = _options.Captcha.BackgroundNoise.CreatePoints(imageSize);
                canvas.DrawPoints(SKPointMode.Points, points, _noisePaint);

                // 绘制验证码
                foreach (var p in sizeAndPoints.Points)
                {
                    var i         = p.Key;
                    var character = p.Value.Key;
                    var point     = p.Value.Value;

                    canvas.DrawText(character, point.X, point.Y,
                                    i % 2 > 0 ? _alternPaint : _forePaint);
                }

                using (var img = SKImage.FromBitmap(bmp))
                    using (var data = img.Encode(_imageFormat, _options.EncodeQuality))
                    {
                        postAction(data);
                    }
            }
    }
コード例 #4
0
        void OnCanvasViewPaintSurface(object sender, SKPaintSurfaceEventArgs args)
        {
            SKImageInfo info    = args.Info;
            SKSurface   surface = args.Surface;
            SKCanvas    canvas  = surface.Canvas;

            canvas.Clear();

            // Create an array of points scattered through the page
            SKPoint[] points = new SKPoint[10];

            for (int i = 0; i < 2; i++)
            {
                float x = (0.1f + 0.8f * i) * info.Width;

                for (int j = 0; j < 5; j++)
                {
                    float y = (0.1f + 0.2f * j) * info.Height;
                    points[2 * j + i] = new SKPoint(x, y);
                }
            }

            SKPaint paint = new SKPaint
            {
                Style       = SKPaintStyle.Stroke,
                Color       = SKColors.DarkOrchid,
                StrokeWidth = 50,
                StrokeCap   = GetPickerItem <SKStrokeCap>(strokeCapPicker)
            };

            // Render the points by calling DrawPoints
            SKPointMode pointMode = GetPickerItem <SKPointMode>(pointModePicker);

            canvas.DrawPoints(pointMode, points, paint);
        }
コード例 #5
0
        private void Draw_Triangle(SKCanvas skCanvas)
        {
            // Draw Rectangle
            SKPaint skPaint = new SKPaint()
            {
                Style       = SKPaintStyle.Stroke,
                Color       = SKColors.DeepSkyBlue,
                StrokeWidth = 10,
                IsAntialias = true,
                StrokeCap   = SKStrokeCap.Round
            };

            SKPoint[] skPointsList = new SKPoint[]
            {
                // Path 1
                new SKPoint(+50, 0),
                new SKPoint(0, -70),

                // path 2
                new SKPoint(0, -70),
                new SKPoint(-50, 0),

                // path 3
                new SKPoint(-50, 0),
                new SKPoint(+50, 0),
            };

            skCanvas.DrawPoints(SKPointMode.Lines, skPointsList, skPaint);
        }
コード例 #6
0
 public void DrawPoints(SKPointMode mode, SKPoint[] points, SKPaint paint)
 {
     canvas.DrawPoints(mode, points, paint);
     if (calculateBounds)
     {
         displayObject.addBoundingPoints(points);
     }
 }
コード例 #7
0
ファイル: StrokeRenderer.cs プロジェクト: xeterixon/Sketching
        public void Render(SKCanvas canvas, IGeometryVisual gemoetry, double scale)
        {
            var stroke = gemoetry as IStroke;

            if (stroke == null || !stroke.IsValid)
            {
                return;
            }
            using (var paint = new SKPaint())
            {
                paint.IsStroke    = true;
                paint.StrokeCap   = SKStrokeCap.Round;
                paint.StrokeWidth = (float)(stroke.Size * scale);
                paint.IsAntialias = true;
                paint.Color       = stroke.ToolSettings.SelectedColor.ToSkiaColor();

                var points = stroke.Points.Select(arg => Helper.Converter.ToSKPoint(arg, scale)).ToArray();
                // Draw HighLight or Stroke
                if (stroke.HighLight)
                {
                    paint.StrokeCap = SKStrokeCap.Butt;
                    if (stroke.IsStenciled)
                    {
                        using (var shader = ShaderFactory.Line(stroke.ToolSettings.SelectedColor.ToSkiaColor()))
                        {
                            paint.Shader = shader;
                        }
                    }
                    paint.Color = stroke.ToolSettings.SelectedColor.ToFillColor().ToSkiaColor();
                    canvas.DrawPointsInPath(paint, points);
                    return;
                }
                else
                {
                    canvas.DrawPoints(SKPointMode.Polygon, points, paint);
                }
                if (!points.Any())
                {
                    return;
                }
                paint.Color    = stroke.ToolSettings.SelectedColor.ToFillColor().ToSkiaColor();
                paint.IsStroke = false;
                if (stroke.IsFilled)
                {
                    canvas.DrawPointsInPath(paint, points);
                }
                if (stroke.IsStenciled)
                {
                    using (var shader = ShaderFactory.Line(stroke.ToolSettings.SelectedColor.ToSkiaColor()))
                    {
                        paint.Shader = shader;
                    }
                    canvas.DrawPointsInPath(paint, points);
                }
            }
        }
コード例 #8
0
        public static void DrawLineThroughPoints(this SKCanvas canvas, IEnumerable <Point> points, SKPaint paint)
        {
            var allPoints = points.ToList();

            if (allPoints.Count > 0)
            {
                var renderingPoints = allPoints.Select(p => new SKPoint((float)p.X, (float)p.Y)).ToArray();

                canvas.DrawPoints(SKPointMode.Polygon, renderingPoints, paint);
            }
        }
コード例 #9
0
        public void DrawRect(double x, double y, double w, double h, bool Fill, Color PenColor)
        {
            try
            {
                if (!Rotating)
                {
                    DrawNonRotatedRect(x, y, w, h, Fill, PenColor);
                    return;
                }

                Rotate_point(x, y, out var rx1, out var ry1);
                Rotate_point(x, y + h, out var rx2, out var ry2);
                Rotate_point(x + w, y + h, out var rx3, out var ry3);
                Rotate_point(x + w, y, out var rx4, out var ry4);

                //The coordinates are in world units. We must first transform them to pixel coordinates.
                DrawRectPoints[0].X = XAxisAdjust + XAxesDirection * (int)Math.Truncate((rx1 - OriginX) * DQMScaleX);
                DrawRectPoints[0].Y = YAxisAdjust - YAxesDirection * (int)Math.Truncate((ry1 - OriginY) * DQMScaleY);
                DrawRectPoints[1].X = XAxisAdjust + XAxesDirection * (int)Math.Truncate((rx2 - OriginX) * DQMScaleX);
                DrawRectPoints[1].Y = YAxisAdjust - YAxesDirection * (int)Math.Truncate((ry2 - OriginY) * DQMScaleY);
                DrawRectPoints[2].X = XAxisAdjust + XAxesDirection * (int)Math.Truncate((rx3 - OriginX) * DQMScaleX);
                DrawRectPoints[2].Y = YAxisAdjust - YAxesDirection * (int)Math.Truncate((ry3 - OriginY) * DQMScaleY);
                DrawRectPoints[3].X = XAxisAdjust + XAxesDirection * (int)Math.Truncate((rx4 - OriginX) * DQMScaleX);
                DrawRectPoints[3].Y = YAxisAdjust - YAxesDirection * (int)Math.Truncate((ry4 - OriginY) * DQMScaleY);

                if (Fill)
                {
                    SetBrushColor(PenColor);
                    DrawCanvas.DrawPoints(SKPointMode.Polygon, DrawRectPoints, DrawCanvasPen);
                }
                else
                {
                    SetBrushColor(PenColor);
                    DrawCanvas.DrawPoints(SKPointMode.Polygon, DrawRectPoints, DrawCanvasBrush);
                }
            }
            catch
            {
                // Ignore it
            }
        }
コード例 #10
0
ファイル: CaptchaService.cs プロジェクト: librame/extensions
        public void DrawCore(string captcha, Action <SKData> postAction)
        {
            Logger.LogInformation($"Captcha text: {captcha}");

            var colors = Options.Captcha.Colors;

            var sizeAndPoints = ComputeSizeAndPoints(captcha);
            var imageSize     = sizeAndPoints.Size;
            var imageInfo     = new SKImageInfo(imageSize.Width, imageSize.Height,
                                                SKColorType.Bgra8888, SKAlphaType.Premul);

            using (var bmp = new SKBitmap(imageInfo))
                using (var canvas = new SKCanvas(bmp))
                {
                    // Clear
                    canvas.DrawColor(colors.Background);

                    // 绘制噪点
                    using (var noisePaint = CreateNoisePaint())
                    {
                        var points = CreateNoisePoints(imageSize);
                        canvas.DrawPoints(SKPointMode.Points, points, noisePaint);
                    }

                    // 绘制验证码
                    using (var forePaint = CreatePaint(colors.Fore))
                        using (var alternPaint = CreatePaint(colors.Alternate))
                        {
                            foreach (var p in sizeAndPoints.Points)
                            {
                                var i         = p.Key;
                                var character = p.Value.Key;
                                var point     = p.Value.Value;

                                canvas.DrawText(character, point.X, point.Y,
                                                i % 2 > 0 ? alternPaint : forePaint);
                            }
                        }

                    using (var img = SKImage.FromBitmap(bmp))
                        using (var data = img.Encode(CurrentImageFormat, Options.Quality))
                        {
                            if (data.IsNull())
                            {
                                throw new InvalidOperationException(InternalResource.InvalidOperationExceptionUnsupportedImageFormat);
                            }

                            postAction.Invoke(data);
                        }
                }
        }
コード例 #11
0
ファイル: BaseChart.cs プロジェクト: benlundberg/MapsXF
        protected void DrawPoints(SKCanvas canvas, SKPoint[] points, ChartItem entry)
        {
            if (points?.Any() != true)
            {
                return;
            }

            canvas.DrawPoints(SKPointMode.Points, points, new SKPaint
            {
                Color       = entry.PointColor.ToSKColor(),
                StrokeWidth = entry.PointSize,
                StrokeCap   = entry.StrokeCap
            });
        }
コード例 #12
0
ファイル: SkiaCanvas.cs プロジェクト: SkitanaTeam/Skitana
        public void FillPolygon(Color color, params Vector2[] points)
        {
            var count        = points.Length;
            var targetPoints = helperPoints[count];

            for (var idx = 0; idx < count; ++idx)
            {
                targetPoints[idx] = points[idx].ToSKPoint();
            }

            skPaint.IsStroke = false;
            skPaint.Color    = color.ToSKColor();

            skCanvas.DrawPoints(SKPointMode.Polygon, targetPoints, skPaint);
        }
コード例 #13
0
 internal override void Draw(SKCanvas c)
 {
     if (Points.Length >= 2)
     {
         SKPoint[] points = SKPoints(Points);
         using (var paint = new SKPaint {
             IsAntialias = Owner.IsAntialias
         }) {
             if (points.Length == 2)
             {
                 if (StrokeColor != Color.Empty)
                 {
                     paint.Style       = SKPaintStyle.Stroke;
                     paint.Color       = SKColor(StrokeColor);
                     paint.StrokeWidth = StrokeWidth;
                     c.DrawPoints(SKPointMode.Lines, points, paint);
                 }
             }
             else
             {
                 SKPath path = new SKPath();
                 path.MoveTo(points[0]);
                 for (int i = 1; i < points.Length; ++i)
                 {
                     path.LineTo(points[i]);
                 }
                 if (Close)
                 {
                     path.Close();
                 }
                 if (FillColor != Color.Empty)
                 {
                     paint.Style = SKPaintStyle.Fill;
                     paint.Color = SKColor(FillColor);
                     c.DrawPath(path, paint);
                 }
                 if (StrokeColor != Color.Empty)
                 {
                     paint.Style       = SKPaintStyle.Stroke;
                     paint.Color       = SKColor(StrokeColor);
                     paint.StrokeWidth = StrokeWidth;
                     c.DrawPath(path, paint);
                 }
             }
         }
     }
     base.Draw(c);
 }
コード例 #14
0
        public void Render(SKCanvas canvas, IGeometryVisual gemoetry, double scale)
        {
            var stroke = gemoetry as IStroke;

            if (stroke == null || !stroke.IsValid)
            {
                return;
            }
            using (var paint = new SKPaint())
            {
                // Draw Stroke
                paint.IsStroke    = true;
                paint.StrokeCap   = SKStrokeCap.Round;
                paint.StrokeWidth = (float)(stroke.Size * scale);
                paint.IsAntialias = true;
                paint.Color       = stroke.Color.ToSkiaColor();
                if (stroke.HighLight)
                {
                    paint.BlendMode = SKBlendMode.Darken;                                   //TODO: Maybe use filters, paint.ColorFilter = SKColorFilter.CreateLighting()
                }
                var points = stroke.Points.Select(arg => Helper.Converter.ToSKPoint(arg, scale)).ToArray();
                canvas.DrawPoints(SKPointMode.Polygon, points, paint);
                // Fill Stroke
                if (!stroke.IsFilled)
                {
                    return;
                }
                if (!points.Any())
                {
                    return;
                }
                paint.Color    = stroke.Color.ToFillColor().ToSkiaColor();
                paint.IsStroke = false;
                var path = new SKPath();
                foreach (var skPoint in points)
                {
                    if (!path.Points.Any())
                    {
                        path.MoveTo(skPoint);
                    }
                    path.LineTo(skPoint);
                }
                canvas.DrawPath(path, paint);
            }
        }
コード例 #15
0
        public static void Show(int width, int height, IEnumerable <float> values)
        {
            var bmp = new SKBitmap(width, height, true);

            var cnv = new SKCanvas(bmp);

            cnv.Clear(SKColor.Parse("000000"));

            var vArray = values.ToArray();

            var yMax   = vArray.Max();
            var yMin   = vArray.Min();
            var yRange = yMax - yMin;
            var xRange = vArray.Length;

            cnv.DrawPoints(SKPointMode.Polygon,
                           vArray
                           .Select((v, i) =>
                                   new SKPoint(
                                       i * width / xRange,
                                       height - (v - yMin) * height / yRange))
                           .ToArray(),
                           new SKPaint()
            {
                StrokeWidth = 3f,
                IsAntialias = true,
                Color       = SKColor.Parse("FF8000")
            });

            cnv.DrawRect(0f, 0f, width - 1, height - 1, new SKPaint()
            {
                IsStroke = true,
                Color    = SKColor.Parse("FFFFFF")
            });

            var tmpFileName = Path.GetTempPath() + "NevronaImage.png";
            var tmpFile     = File.Create(tmpFileName);

            SKImage.FromBitmap(bmp).Encode(SKEncodedImageFormat.Png, 80)
            .SaveTo(tmpFile);

            tmpFile.Close();

            Process.Start("explorer.exe", tmpFileName);
        }
コード例 #16
0
        void DrawCircle(SKCanvas canvas, SKPaint paint, int xc, int yc, int radius)
        {
            if (radius <= 0)
            {
                return;
            }

            int x   = radius;
            int y   = 0;
            int cd2 = 0;

            var points = new List <SKPoint> ();

            points.Add(new SKPoint(xc - radius, yc));
            points.Add(new SKPoint(xc + radius, yc));
            points.Add(new SKPoint(xc, yc - radius));
            points.Add(new SKPoint(xc, yc + radius));

            while (x > y)
            {
                cd2 -= (--x) - (++y);

                if (cd2 < 0)
                {
                    cd2 += x++;
                }

                // 8 octants - listed clockwise

                // right hemisphere, starting at the top
                points.Add(new SKPoint(xc + y, yc - x));
                points.Add(new SKPoint(xc + x, yc - y));
                points.Add(new SKPoint(xc + x, yc + y));
                points.Add(new SKPoint(xc + y, yc + x));

                // left hemisphere, continuing around from the bottom
                points.Add(new SKPoint(xc - y, yc + x));
                points.Add(new SKPoint(xc - x, yc + y));
                points.Add(new SKPoint(xc - x, yc - y));
                points.Add(new SKPoint(xc - y, yc - x));
            }

            canvas.DrawPoints(SKPointMode.Points, points.ToArray(), paint);
        }
コード例 #17
0
ファイル: MainPage.xaml.cs プロジェクト: R-dawg/SkiaSharpDemo
        private void TrendView7(object sender, SKPaintSurfaceEventArgs e)
        {
            SKSurface surface = e.Surface;
            SKCanvas  canvas  = surface.Canvas;

            DrawGraph(canvas, e);

            // draw trend line
            trendLinePaint.Color = SKColors.Red;
            canvas.DrawPoints(SKPointMode.Lines, _SKPointsVS7.ToArray(), trendLinePaint);
            foreach (SKPoint point in _SKPointsVS7)
            {
                dataPointPaint.Style = SKPaintStyle.Stroke;
                dataPointPaint.Color = SKColors.Red;
                canvas.DrawCircle(point, 6, dataPointPaint);
                dataPointPaint.Style = SKPaintStyle.Fill;
                dataPointPaint.Color = SKColors.White;
                canvas.DrawCircle(point, 6, dataPointPaint);
            }
        }
コード例 #18
0
ファイル: AboutPage.xaml.cs プロジェクト: vnatalya/TF
        void OnCanvasViewPaintSurface(object sender, SKPaintSurfaceEventArgs args)
        {
            SKImageInfo info    = args.Info;
            SKSurface   surface = args.Surface;
            SKCanvas    canvas  = surface.Canvas;

            canvas.Clear();

            SKPaint textPaint = new SKPaint
            {
                Color     = SKColors.Black,
                TextSize  = 14,
                TextAlign = SKTextAlign.Center
            };

            var pointsCount = viewModel.Trainings.Count;

            var pictureWidth  = info.Width;
            var pictureHeight = info.Height;

            var    pointWidth  = pictureWidth / pointsCount;
            double pointHeight = 1;

            double biggestValue = 0;

            #region draw distance and time

            SKPaint timePaint = new SKPaint
            {
                Style       = SKPaintStyle.Stroke,
                TextSize    = 16,
                Color       = Color.Red.ToSKColor(),
                StrokeWidth = 1
            };

            SKPaint timePointPaint = new SKPaint {
                Style       = SKPaintStyle.Stroke,
                Color       = Color.Red.ToSKColor(),
                StrokeWidth = 4
            };


            SKPaint distancePaint = new SKPaint {
                Style       = SKPaintStyle.Stroke,
                TextSize    = 16,
                Color       = Color.Blue.ToSKColor(),
                StrokeWidth = 1
            };

            SKPaint distancePointPaint = new SKPaint {
                Style       = SKPaintStyle.Stroke,
                Color       = Color.Blue.ToSKColor(),
                StrokeWidth = 2
            };

            for (int i = 0; i < pointsCount; ++i)
            {
                biggestValue = viewModel.Trainings [i].Time.TotalHours > biggestValue ? viewModel.Trainings [i].Time.TotalHours : biggestValue;
                biggestValue = viewModel.Trainings [i].Distance > biggestValue ? viewModel.Trainings [i].Distance : biggestValue;
            }

            List <SKPoint> timePoints     = new List <SKPoint>();
            List <SKPoint> distancePoints = new List <SKPoint> ();

            for (int i = 0; i < pointsCount; ++i)
            {
                pointHeight = (pictureHeight - bottomOffset) / biggestValue;
                canvas.DrawText(viewModel.Trainings[i].DisplayDate, leftOffset + i * pointWidth, pictureHeight, textPaint);
                canvas.DrawText(String.Format("{0:0.0}", viewModel.Trainings[i].Time.TotalHours), 20, pictureHeight - bottomOffset - (int)(viewModel.Trainings[i].Time.TotalHours * pointHeight), textPaint);

                timePoints.Add(new SKPoint(leftOffset + i * pointWidth, pictureHeight - bottomOffset - (int)(viewModel.Trainings[i].Time.TotalHours * pointHeight)));

                canvas.DrawText(viewModel.Trainings [i].Distance.ToString(), 20, pictureHeight - (int)(viewModel.Trainings [i].Distance * pointHeight), textPaint);

                distancePoints.Add(new SKPoint(leftOffset + i * pointWidth, pictureHeight - bottomOffset - (int)(viewModel.Trainings [i].Distance * pointHeight)));
            }

            canvas.DrawPoints(SKPointMode.Points, timePoints.ToArray(), timePointPaint);

            canvas.DrawPoints(SKPointMode.Polygon, timePoints.ToArray(), timePaint);

            if (timePoints.Count > 0)
            {
                canvas.DrawText(StringService.Instance.Time, timePoints [timePoints.Count - 1].X, timePoints [timePoints.Count - 1].Y, timePaint);
            }

            canvas.DrawPoints(SKPointMode.Points, distancePoints.ToArray(), distancePointPaint);

            if (distancePoints.Count > 0)
            {
                canvas.DrawText(StringService.Instance.Distance, distancePoints[distancePoints.Count - 1].X, distancePoints [distancePoints.Count - 1].Y, distancePaint);
            }

            canvas.DrawPoints(SKPointMode.Polygon, distancePoints.ToArray(), distancePaint);

            #endregion

            SKPaint axesPaint = new SKPaint
            {
                Style       = SKPaintStyle.Stroke,
                Color       = Color.Aqua.ToSKColor(),
                StrokeWidth = 3
            };

            canvas.DrawLine(leftOffset, pictureHeight - bottomOffset, pictureWidth, pictureHeight - bottomOffset, axesPaint);
            canvas.DrawLine(leftOffset, pictureHeight - bottomOffset, leftOffset, 0, axesPaint);
        }
コード例 #19
0
        void DrawArcFromTo(SKCanvas canvas, SKPaint paint, int xc, int yc, int radius,
                           float startAngleInDegrees, float endAngleInDegrees)
        {
            if (radius <= 0)
            {
                return;
            }

            int x   = radius;
            int y   = 0;
            int cd2 = 0;

            // convert degrees to radians
            var startAngleRadians = startAngleInDegrees * Math.PI / 180;
            var endAngleRadians   = endAngleInDegrees * Math.PI / 180;

            // find x,y coordinates for start and end points
            var startx     = xc + radius * (float)Math.Cos(startAngleRadians);
            var starty     = yc + radius * (float)Math.Sin(startAngleRadians);
            var startPoint = new SKPoint(startx, starty);

            var endx     = xc + radius * (float)Math.Cos(endAngleRadians);
            var endy     = yc + radius * (float)Math.Sin(endAngleRadians);
            var endPoint = new SKPoint(endx, endy);

            // build the path
            var points = new List <SKPoint> ();

            // 4 cardinal points

            var p00  = new SKPoint(xc - radius, yc);
            var ap00 = Math.Atan2(p00.Y - yc, p00.X - xc) * 180 / Math.PI;

            if (IsAngleBetween((int)ap00, (int)startAngleInDegrees, (int)endAngleInDegrees))
            {
                points.Add(p00);
            }

            var p01  = new SKPoint(xc + radius, yc);
            var ap01 = Math.Atan2(p01.Y - yc, p01.X - xc) * 180 / Math.PI;

            if (IsAngleBetween((int)ap01, (int)startAngleInDegrees, (int)endAngleInDegrees))
            {
                points.Add(p01);
            }

            var p02  = new SKPoint(xc, yc - radius);
            var ap02 = Math.Atan2(p02.Y - yc, p02.X - xc) * 180 / Math.PI;

            if (IsAngleBetween((int)ap02, (int)startAngleInDegrees, (int)endAngleInDegrees))
            {
                points.Add(p02);
            }

            var p03  = new SKPoint(xc, yc + radius);
            var ap03 = Math.Atan2(p03.Y - yc, p03.X - xc) * 180 / Math.PI;

            if (IsAngleBetween((int)ap03, (int)startAngleInDegrees, (int)endAngleInDegrees))
            {
                points.Add(p03);
            }

            while (x > y)
            {
                x--;
                y++;

                cd2 -= x - y;
                if (cd2 < 0)
                {
                    cd2 += x++;
                }

                // 8 octants - listed clockwise

                // right hemisphere, starting at the top

                var p0   = new SKPoint(xc + y, yc - x);
                var arp0 = Math.Atan2(p0.Y - yc, p0.X - xc) * 180 / Math.PI;
                if (IsAngleBetween((int)arp0, (int)startAngleInDegrees, (int)endAngleInDegrees))
                {
                    points.Add(p0);
                }

                var p1   = new SKPoint(xc + x, yc - y);
                var arp1 = Math.Atan2(p1.Y - yc, p1.X - xc) * 180 / Math.PI;
                if (IsAngleBetween((int)arp1, (int)startAngleInDegrees, (int)endAngleInDegrees))
                {
                    points.Add(p1);
                }

                var p2   = new SKPoint(xc + x, yc + y);
                var arp2 = Math.Atan2(p2.Y - yc, p2.X - xc) * 180 / Math.PI;
                if (IsAngleBetween((int)arp2, (int)startAngleInDegrees, (int)endAngleInDegrees))
                {
                    points.Add(p2);
                }

                var p3   = new SKPoint(xc + y, yc + x);
                var arp3 = Math.Atan2(p3.Y - yc, p3.X - xc) * 180 / Math.PI;
                if (IsAngleBetween((int)arp3, (int)startAngleInDegrees, (int)endAngleInDegrees))
                {
                    points.Add(p3);
                }

                // left hemisphere, continuing around from the bottom

                var p4   = new SKPoint(xc - y, yc + x);
                var arp4 = Math.Atan2(p4.Y - yc, p4.X - xc) * 180 / Math.PI;
                if (IsAngleBetween((int)arp4, (int)startAngleInDegrees, (int)endAngleInDegrees))
                {
                    points.Add(p4);
                }

                var p5   = new SKPoint(xc - x, yc + y);
                var arp5 = Math.Atan2(p5.Y - yc, p5.X - xc) * 180 / Math.PI;
                if (IsAngleBetween((int)arp5, (int)startAngleInDegrees, (int)endAngleInDegrees))
                {
                    points.Add(p5);
                }

                var p6   = new SKPoint(xc - x, yc - y);
                var arp6 = Math.Atan2(p6.Y - yc, p6.X - xc) * 180 / Math.PI;
                if (IsAngleBetween((int)arp6, (int)startAngleInDegrees, (int)endAngleInDegrees))
                {
                    points.Add(p6);
                }

                var p7   = new SKPoint(xc - y, yc - x);
                var arp7 = Math.Atan2(p7.Y - yc, p7.X - xc) * 180 / Math.PI;
                if (IsAngleBetween((int)arp7, (int)startAngleInDegrees, (int)endAngleInDegrees))
                {
                    points.Add(p7);
                }
            }

            canvas.DrawPoints(SKPointMode.Points, points.ToArray(), paint);
        }
コード例 #20
0
        private void OnPaintSurface(object sender, SKPaintSurfaceEventArgs args)
        {
            // the the canvas and properties
            SKImageInfo info    = args.Info;
            SKSurface   surface = args.Surface;
            SKCanvas    canvas  = args.Surface.Canvas;

            // get the screen density for scaling
            var scale = Resources.DisplayMetrics.Density;

            // get the scaled size of the screen in density-indep pixals
            // pixals = (dp pixals) * DisplayMetrics.Density
            // (dp pixals) = pixals / DisplayMetrics.Density
            var scaledSize = new SKSize(info.Width / scale, info.Height / scale);

            // handle the device screen density
            canvas.Scale(scale);

            // make sure the canvas is blank
            canvas.Clear(SKColors.White);

            // draw some text
            var paint = new SKPaint
            {
                Color       = SKColors.Black,
                Style       = SKPaintStyle.Stroke,
                StrokeWidth = 10,                 //in dp
                IsAntialias = true,
            };

            var paint_red = new SKPaint
            {
                Style       = SKPaintStyle.Stroke,
                Color       = SKColors.OrangeRed,
                StrokeWidth = 10,                 // in dp
                StrokeCap   = SKStrokeCap.Butt,
                IsAntialias = true,
            };

            var paint_blue = new SKPaint
            {
                Style = SKPaintStyle.Stroke,
                Color = SKColors.Blue,

                StrokeWidth = 35,                 //in dp
                StrokeCap   = SKStrokeCap.Round,
                IsAntialias = true,
            };
            // Create an SKPaint object to display the text
            var textPaint = new SKPaint
            {
                Style        = SKPaintStyle.Stroke,
                FakeBoldText = true,
                StrokeWidth  = 3f,
                Color        = SKColors.Blue,
                IsAntialias  = true,
            };

            /*
             * Coordinates are specified relative to the upper-left corner of the display surface.
             * X coordinates increase to the right and Y coordinates increase going down.
             * In discussion about graphics, often the mathematical notation (x, y) is used to denote a point.
             * The point (0, 0) is the upper-left corner of the display surface and is often called the origin.
             */
            // Adjust TextSize property so text is 95% of screen width


            // 95% of width * (Height for width ratio)
            textPaint.TextSize = 0.15f * scaledSize.Height;

            // Find the text bounds
            SKRect textBounds = new SKRect();

            textPaint.MeasureText(m_ChordName, ref textBounds);

            // Calculate offsets to center the text on the screen
            float xText = scaledSize.Width / 2 - textBounds.MidX;
            float yText = scaledSize.Height / 7.5f - textBounds.MidY;

            // And draw the text
            canvas.DrawText(m_ChordName, xText, yText, textPaint);



            // 10& of height
            textPaint.TextSize = 0.1f * scaledSize.Height;

            // Find the text bounds
            textBounds = new SKRect();
            textPaint.MeasureText(m_Dis_ChordPos.ToString(), ref textBounds);

            // Calculate offsets to center the text on the screen
            xText = scaledSize.Width / 9 - textBounds.MidX;
            yText = scaledSize.Height / 2.5f - textBounds.MidY;

            // And draw the text
            textPaint.Color = SKColors.Black;
            textPaint.Style = SKPaintStyle.StrokeAndFill;
            canvas.DrawText(m_Dis_ChordPos.ToString(), xText, yText, textPaint);


            // divide the scaled size width into 7 spaces
            m_space          = ((scaledSize.Width) / 7);
            m_x_start        = m_space + 25;
            m_y_start        = 200;
            m_string_len     = (scaledSize.Height - m_y_start / 2);
            m_fret_len_space = (m_string_len - 110) / 4;



            // Strings
            SKPoint[] string_points = new SKPoint[12];
            for (int i = 0; i < 2; i++)
            {
                float y = m_y_start + (m_string_len * i) - (m_fret_len_space * i);

                for (int j = 0; j < 6; j++)
                {
                    float x = m_x_start + m_space * j;
                    string_points[2 * j + i] = new SKPoint(x, y);
                }
            }
            // Render the points by calling DrawPoints
            SKPointMode pointMode = SKPointMode.Lines;

            canvas.DrawPoints(pointMode, string_points, paint);


            //	Frets
            SKPoint[] fret_points = new SKPoint[10];
            for (int i = 0; i < 2; i++)
            {
                float x = (m_x_start + (5 * m_space * i));

                for (int j = 0; j < 5; j++)
                {
                    float y = m_y_start + (m_fret_len_space - 2.5f) * j;                    // A slight adj with -2.5
                    fret_points[2 * j + i] = new SKPoint(x, y);
                }
            }

            // Render the points by calling DrawPoints
            pointMode = SKPointMode.Lines;
            canvas.DrawPoints(pointMode, fret_points, paint);


            // Notes on each string
            SKPoint[] str_6 = new SKPoint[4];
            SKPoint[] str_5 = new SKPoint[4];
            SKPoint[] str_4 = new SKPoint[4];
            SKPoint[] str_3 = new SKPoint[4];
            SKPoint[] str_2 = new SKPoint[4];
            SKPoint[] str_1 = new SKPoint[4];

            // 6th string E note positions
            gen_note_str(out str_6, 6);

            // 5th string A note positions
            gen_note_str(out str_5, 5);

            // 4th string D
            gen_note_str(out str_4, 4);

            // 3rd string G
            gen_note_str(out str_3, 3);

            // 2nd string B
            gen_note_str(out str_2, 2);

            // 1st string E
            gen_note_str(out str_1, 1);



            // Chord Notes ::::
            // Converts the chords frets to actual positions on screen
            // subtracts position - 1 to get relative position
            // then adds the relative position to an array

            SKPoint[] chord_prts = new SKPoint[6];
            for (int i = 0; i < m_chord_frets_parsed.Count; i++)
            {
                // error with larger chords tried m_ChordPos to solve problem
                if (!(m_chord_frets_parsed[i] >= 100 | m_chord_frets_parsed[i] <= 0))                //100 represents "^"
                {
                    int parse_temp = m_chord_frets_parsed[i];
                    parse_temp = parse_temp - 1 - m_ChordPos;                     // -1 for array

                    switch (i)
                    {
                    case 0:
                        chord_prts[i] = str_6[parse_temp];
                        break;

                    case 1:
                        chord_prts[i] = str_5[parse_temp];
                        break;

                    case 2:
                        chord_prts[i] = str_4[parse_temp];
                        break;

                    case 3:
                        chord_prts[i] = str_3[parse_temp];
                        break;

                    case 4:
                        chord_prts[i] = str_2[parse_temp];
                        break;

                    case 5:
                        chord_prts[i] = str_1[parse_temp];
                        break;

                    default:
                        System.Console.WriteLine("Exep: More than 6 notes");
                        break;
                    }
                }
                else if (m_chord_frets_parsed[i] <= 100)
                {
                    SKPoint temp_adj = new SKPoint();
                    SKPath  x_path   = new SKPath();


                    switch (i)
                    {
                    case 0:
                        temp_adj   = str_6[0];
                        temp_adj.Y = temp_adj.Y - m_fret_len_space / 2;
                        x_path     = DrawX(temp_adj);
                        canvas.DrawPath(x_path, paint_red);
                        break;

                    case 1:
                        temp_adj   = str_5[0];
                        temp_adj.Y = temp_adj.Y - m_fret_len_space / 2;
                        x_path     = DrawX(temp_adj);
                        canvas.DrawPath(x_path, paint_red);
                        break;

                    case 2:
                        temp_adj   = str_4[0];
                        temp_adj.Y = temp_adj.Y - m_fret_len_space / 2;;
                        x_path     = DrawX(temp_adj);
                        canvas.DrawPath(x_path, paint_red);;
                        break;

                    case 3:
                        temp_adj   = str_3[0];
                        temp_adj.Y = temp_adj.Y - m_fret_len_space / 2;;
                        x_path     = DrawX(temp_adj);
                        canvas.DrawPath(x_path, paint_red);
                        break;

                    case 4:
                        temp_adj   = str_2[0];
                        temp_adj.Y = temp_adj.Y - m_fret_len_space / 2;;
                        x_path     = DrawX(temp_adj);
                        canvas.DrawPath(x_path, paint_red);
                        break;

                    case 5:
                        temp_adj   = str_1[0];
                        temp_adj.Y = temp_adj.Y - m_fret_len_space / 2;;
                        x_path     = DrawX(temp_adj);
                        canvas.DrawPath(x_path, paint_red);
                        break;

                    default:
                        System.Console.WriteLine("Exep: More than 6 notes");
                        break;
                    }
                    chord_prts[i] = new SKPoint(-50, -50);                     // open str (0) = off screen
                }
                else
                {
                    chord_prts[i] = new SKPoint(-50, -50);                     // open str (0) = off screen
                }
            }
            canvas.DrawPoints(SKPointMode.Points, chord_prts, paint_blue);
        }
コード例 #21
0
ファイル: MainPage.xaml.cs プロジェクト: jkmsmkj/QGoLF
        private void CanvasView_PaintSurface(object sender, SKPaintSurfaceEventArgs e)
        {
            SKSurface surface = e.Surface;
            SKCanvas  canvas  = surface.Canvas;

            canvas.Clear(SKColors.White);
            //canvas.Save();
            //canvas.Restore();

            int px = 0;
            int py = 0;
            int ind;

            if (iters == 0)
            {
                axLim[0] = 0;
                axLim[1] = (int)Math.Floor(canvas.LocalClipBounds.Right / 50.0) * 50;
                ayLim[0] = 0;
                ayLim[1] = (int)Math.Floor(canvas.LocalClipBounds.Bottom / 50.0) * 50;
                if (!initButton.Text.Equals("Done •") || Ccells.Count == 0)
                {
                    if (Math.IEEERemainder((axLim[1] - axLim[0]) / 2, 50) == 0)
                    {
                        px = (axLim[1] - axLim[0]) / 2;
                    }
                    else
                    {
                        px = 25 + ((axLim[1] - axLim[0]) / 2);
                    }
                    if (Math.IEEERemainder((ayLim[1] - ayLim[0]) / 2, 50) == 0)
                    {
                        py = (ayLim[1] - ayLim[0]) / 2;
                    }
                    else
                    {
                        py = 25 + ((ayLim[1] - ayLim[0]) / 2);
                    }
                    Ccells.Clear();
                    Scells.Clear();
                    Ccells.Add(new int[] { px, py, iters });
                    Fcells.Clear();
                    Fcells.Add(new int[] { px - 25, py + 25, iters });
                    Fcells.Add(new int[] { px + 25, py + 75, iters });
                    Fcells.Add(new int[] { px + 75, py + 25, iters });
                    Fcells.Add(new int[] { px + 25, py - 25, iters });
                }
                scale = Math.Min((float)(canvas.LocalClipBounds.Width / axLim[1]), (float)(canvas.LocalClipBounds.Height / ayLim[1]));
                canvas.Scale(scale, scale, canvas.LocalClipBounds.MidX, canvas.LocalClipBounds.MidY);
                canvas.Translate(canvas.LocalClipBounds.Left - axLim[0], canvas.LocalClipBounds.Top - ayLim[0]);
            }
            else
            {
                canvas.Scale(scale, scale, canvas.LocalClipBounds.MidX, canvas.LocalClipBounds.MidY);
                canvas.Translate(canvas.LocalClipBounds.Left - axLim[0], canvas.LocalClipBounds.Top - ayLim[0]);
                ind = rndNum.Next(0, Fcells.Count);
                px  = Fcells[ind][0] - 25;
                py  = Fcells[ind][1] - 25;
                InitFunc(new SKPoint(px, py));
            }

            if (Fcells.Exists(item => item[0] < axLim[0] || item[0] > axLim[1]))
            {
                axLim[0] -= 250;
                axLim[1] += 250;
                float LocScale = (canvas.LocalClipBounds.Width / (axLim[1] - axLim[0]));
                canvas.Clear(SKColors.White);
                canvas.Scale(LocScale, LocScale, canvas.LocalClipBounds.MidX, canvas.LocalClipBounds.MidY);
                ayLim[0] = (int)Math.Floor(canvas.LocalClipBounds.Top / 50.0) * 50;
                ayLim[1] = (int)Math.Floor(canvas.LocalClipBounds.Bottom / 50.0) * 50;
                canvas.Translate(canvas.LocalClipBounds.Left - axLim[0], canvas.LocalClipBounds.Top - ayLim[0]);
                scale *= LocScale;
            }
            if (Fcells.Exists(item => item[1] < ayLim[0] || item[1] > ayLim[1]))
            {
                ayLim[0] -= 250;
                ayLim[1] += 250;
                float LocScale = (canvas.LocalClipBounds.Height / (ayLim[1] - ayLim[0]));
                canvas.Clear(SKColors.White);
                canvas.Scale(LocScale, LocScale, canvas.LocalClipBounds.MidX, canvas.LocalClipBounds.MidY);
                axLim[0] = (int)Math.Floor(canvas.LocalClipBounds.Left / 50.0) * 50;
                axLim[1] = (int)Math.Floor(canvas.LocalClipBounds.Right / 50.0) * 50;
                canvas.Translate(canvas.LocalClipBounds.Left - axLim[0], canvas.LocalClipBounds.Top - ayLim[0]);
                scale *= LocScale;
            }

            canvas.DrawRect(canvas.LocalClipBounds, blackLines);
            for (int i = axLim[0]; i <= canvas.LocalClipBounds.Right; i += 50)
            {
                canvas.DrawLine(i, canvas.LocalClipBounds.Top, i, canvas.LocalClipBounds.Bottom, blackLines); //ayLim[s]
            }
            for (int i = ayLim[0]; i <= canvas.LocalClipBounds.Bottom; i += 50)
            {
                canvas.DrawLine(canvas.LocalClipBounds.Left, i, canvas.LocalClipBounds.Right, i, blackLines); //axLim[s]
            }

            foreach (int[] pxy in Scells)
            {
                canvas.DrawRect(pxy[0] + 2, pxy[1] + 2, 48, 48, grayFillPaint);
            }
            foreach (int[] pxy in Ccells)
            {
                canvas.DrawRect(pxy[0] + 2, pxy[1] + 2, 48, 48, blueFillPaint);
            }
            foreach (int[] pxy in Fcells)
            {
                canvas.DrawPoints(SKPointMode.Points, new SKPoint[] { new SKPoint(pxy[0], pxy[1]) }, redDots);
            }
            titleLabel.Text = "H = " + Hness.ToString("F4") + " (Step " + iters + ")";
        }
コード例 #22
0
        private void DrawMarker(SKPaintSurfaceEventArgs e)
        {
            SKImageInfo info    = e.Info;
            SKSurface   surface = e.Surface;
            SKCanvas    canvas  = surface.Canvas;
            SKPoint     center  = new SKPoint(info.Width / 2, info.Height / 2);

            // draw live
            FixMaxMin();
            float livePixelsYStart = info.Height + bottomFluidGlassCircleCenterY - bottomFluidGlassHullRadius - startMarkerDistance;
            float livePixelsYEnd   = topFluidGlassCircleCenterY;

            // map real temp to pixels from marker start to end
            float temperatureY = Temperature.Map(MinTemperature, MaxTemperature, livePixelsYStart, livePixelsYEnd);

            int tempRange   = Math.Abs(MinTemperature) + Math.Abs(MaxTemperature);
            int markerCount = tempRange / markerStep;

            float thermometerPixelHeight = livePixelsYStart - livePixelsYEnd;
            float pixelStep = thermometerPixelHeight / markerCount;

            float yMarkerStep = livePixelsYStart;

            SKPaint markerPaint = new SKPaint
            {
                IsAntialias = true,
                Style       = SKPaintStyle.Fill,
                Color       = MarkerColor.ToSKColor(),
                TextSize    = 40,
                TextAlign   = SKTextAlign.Center,
            };

            for (int i = 0; i <= markerCount; i++)
            {
                SKRect marker = new SKRect
                {
                    Left   = center.X + (topFluidGlassWidth / 2) + markerOffsetX,
                    Top    = yMarkerStep + 2,
                    Bottom = yMarkerStep - 2
                };
                marker.Right = marker.Left + 100;

                canvas.DrawRect(marker, markerPaint);
                canvas.DrawText((MinTemperature + (i * markerStep)).ToString(), marker.Right - 30, yMarkerStep - 10, markerPaint);
                yMarkerStep -= pixelStep;
            }

            SKPaint indicatorGeometryPaint = new SKPaint
            {
                IsAntialias = true,
                Style       = SKPaintStyle.StrokeAndFill,
                Color       = IndicatorColor.ToSKColor(),
                StrokeWidth = 6,
            };

            SKPoint indicatorTextPosition = new SKPoint(center.X - indicatorOffset, (livePixelsYStart - (thermometerPixelHeight * indicatorPositionY)));

            SKPoint indicatorUnderlineStart = new SKPoint(indicatorTextPosition.X, indicatorTextPosition.Y);
            SKPoint indicatorUnderlineEnd   = new SKPoint(indicatorTextPosition.X + 120, indicatorTextPosition.Y);

            SKPoint connectionLineStart = new SKPoint(indicatorUnderlineEnd.X, indicatorUnderlineEnd.Y);
            SKPoint connectionLineEnd   = new SKPoint(center.X, temperatureY);

            SKPoint[] points = new SKPoint[]
            {
                indicatorUnderlineStart,
                indicatorUnderlineEnd,
                connectionLineStart,
                connectionLineEnd,
            };

            canvas.DrawPoints(SKPointMode.Lines, points, indicatorGeometryPaint);
            canvas.DrawCircle(center.X, temperatureY, 10, indicatorGeometryPaint);

            SKPaint indicatorTextPaint = new SKPaint
            {
                IsAntialias = true,
                Style       = SKPaintStyle.StrokeAndFill,
                Color       = IndicatorTextColor.ToSKColor(),
                TextSize    = 50,
                TextAlign   = SKTextAlign.Left,
            };

            canvas.DrawText(Temperature.ToString("0.00"), indicatorTextPosition.X, indicatorTextPosition.Y - 10, indicatorTextPaint);
        }
コード例 #23
0
        protected override void Draw(SKCanvas canvas)
        {
            // B값
            if (Optical == OpticalType.oga || Optical == OpticalType.bollen)
            {
                B = A * F / (A - F);
            }
            else if (Optical == OpticalType.bolga || Optical == OpticalType.olen)
            {
                B = A * -F / (A + F);
            }

            // 배율
            M = B / A;
            // 상 크기
            ImageSize = ObjectSize * Math.Abs(M);

            // 원점
            SKPoint originPoint = new SKPoint(Width / 2, Height / 2);

            // 초점, 구심 좌표
            SKPoint[] xPoints = new SKPoint[2];
            // 물체 좌표
            SKPoint objPoint = originPoint + new SKPoint(-A, -ObjectSize);

            // 1번 광선 경로
            SKPoint[] points_1 = new SKPoint[3];
            points_1[0] = objPoint;
            points_1[1] = originPoint + new SKPoint(0, -ObjectSize);

            // 2번 광선 경로
            SKPoint[] points_2 = new SKPoint[3];
            points_2[0] = objPoint;

            // 3번 광선 경로
            SKPoint[] points_3 = new SKPoint[2];

            // 4번 광선 경로
            SKPoint[] points_4 = new SKPoint[3];
            points_4[0] = objPoint;
            points_4[1] = originPoint;

            // 1번 광선 경로 (가상)
            SKPoint[] points_1v = new SKPoint[2];
            // 2번 광선 경로 (가상)
            SKPoint[] points_2v = new SKPoint[2];
            // 3번 광선 경로 (가상)
            SKPoint[] points_3v = new SKPoint[2];
            // 4번 광선 경로 (가상)
            SKPoint[] points_4v = new SKPoint[2];

            // 광학기기 종류별 처리
            switch (Optical)
            {
            case OpticalType.oga:
                points_1[2] = originPoint + new SKPoint(-10 * F, 9 * ObjectSize);
                points_2[1] = originPoint + new SKPoint(0, ObjectSize * F / (A - F));
                points_2[2] = originPoint + new SKPoint(-10 * F, ObjectSize * F / (A - F));
                points_3[0] = objPoint;
                points_3[1] = originPoint + new SKPoint(0, 2 * ObjectSize * F / (A - 2 * F));
                points_4[2] = originPoint + new SKPoint(-10 * F, 10 * ObjectSize * F / A);

                if (A < F)
                {
                    points_1v[0] = points_1[1];
                    points_1v[1] = originPoint + new SKPoint(10 * F, -11 * ObjectSize);
                    points_2v[0] = points_2[1];
                    points_2v[1] = originPoint + new SKPoint(10 * F, ObjectSize * F / (A - F));
                    points_3v[0] = points_3[1];
                    points_3v[1] = originPoint + new SKPoint(10 * F, 12 * ObjectSize * F / (A - 2 * F));
                    points_4v[0] = points_4[1];
                    points_4v[1] = originPoint + new SKPoint(10 * F, -10 * ObjectSize * F / A);
                }
                else if (A < 2 * F)
                {
                    points_3v[0] = points_3[0];
                    points_3v[1] = originPoint + new SKPoint(-10 * F, -8 * ObjectSize * F / (A - 2 * F));
                }

                xPoints[0] = originPoint + new SKPoint(-F, 0);
                xPoints[1] = originPoint + new SKPoint(-2 * F, 0);
                break;

            case OpticalType.bolga:
                points_1[2] = originPoint + new SKPoint(-F, -2 * ObjectSize);
                points_2[1] = originPoint + new SKPoint(0, -ObjectSize * F / (A + F));
                points_2[2] = originPoint + new SKPoint(-2 * F, -ObjectSize * F / (A + F));
                points_3[0] = objPoint;
                points_3[1] = originPoint + new SKPoint(0, -2 * ObjectSize * F / (A + 2 * F));
                points_4[2] = originPoint + new SKPoint(-2 * F, 2 * ObjectSize * F / A);

                points_1v[0] = points_1[1];
                points_1v[1] = originPoint + new SKPoint(F, 0);
                points_2v[0] = points_2[1];
                points_2v[1] = originPoint + new SKPoint(10 * F, -ObjectSize * F / (A + F));
                points_3v[0] = points_3[1];
                points_3v[1] = originPoint + new SKPoint(2 * F, 0);
                points_4v[0] = points_4[1];
                points_4v[1] = originPoint + new SKPoint(10 * F, -10 * ObjectSize * F / A);

                xPoints[0] = originPoint + new SKPoint(F, 0);
                xPoints[1] = originPoint + new SKPoint(2 * F, 0);
                break;

            case OpticalType.bollen:
                points_1[2] = originPoint + new SKPoint(10 * F, 9 * ObjectSize);
                points_2[1] = originPoint + new SKPoint(0, ObjectSize * F / (A - F));
                points_2[2] = originPoint + new SKPoint(10 * F, ObjectSize * F / (A - F));
                points_4[2] = originPoint + new SKPoint(10 * F, 10 * ObjectSize * F / A);

                if (A < F)
                {
                    points_1v[0] = points_1[1];
                    points_1v[1] = originPoint + new SKPoint(-10 * F, -11 * ObjectSize);
                    points_2v[0] = points_2[1];
                    points_2v[1] = originPoint + new SKPoint(-10 * F, ObjectSize * F / (A - F));
                    points_4v[0] = points_4[1];
                    points_4v[1] = originPoint + new SKPoint(-10 * F, -10 * ObjectSize * F / A);
                }

                xPoints[0] = originPoint + new SKPoint(F, 0);
                xPoints[1] = originPoint + new SKPoint(-F, 0);
                break;

            case OpticalType.olen:
                points_1[2] = originPoint + new SKPoint(2 * F, -3 * ObjectSize);
                points_2[1] = originPoint + new SKPoint(0, -ObjectSize * F / (A + F));
                points_2[2] = originPoint + new SKPoint(2 * F, -ObjectSize * F / (A + F));
                points_4[2] = originPoint + new SKPoint(2 * F, 2 * ObjectSize * F / A);

                points_1v[0] = points_1[1];
                points_1v[1] = originPoint + new SKPoint(-F, 0);
                points_2v[0] = points_2[1];
                points_2v[1] = originPoint + new SKPoint(-2 * F, -ObjectSize * F / (A + F));

                xPoints[0] = originPoint + new SKPoint(-F, 0);
                xPoints[1] = originPoint + new SKPoint(F, 0);
                break;
            }

            // 광축 표시
            canvas.DrawLine(0, Height / 2, Width, Height / 2, linePaint);
            // 초점 표시
            canvas.DrawPoints(SKPointMode.Points, xPoints, pointPaint);

            // 1번 광선 표시
            canvas.DrawPoints(SKPointMode.Polygon, points_1, new SKPaint()
            {
                StrokeWidth = 2, Color = SKColors.Orange
            });
            // 2번 광선 표시
            canvas.DrawPoints(SKPointMode.Polygon, points_2, new SKPaint()
            {
                StrokeWidth = 2, Color = SKColors.Green
            });
            // 3번 광선 표시
            canvas.DrawPoints(SKPointMode.Lines, points_3, new SKPaint()
            {
                StrokeWidth = 2, Color = SKColors.Blue
            });
            // 4번 광선 표시
            canvas.DrawPoints(SKPointMode.Polygon, points_4, new SKPaint()
            {
                StrokeWidth = 2, Color = SKColors.DeepPink
            });

            // 1번 광선 표시 (가상)
            canvas.DrawPoints(SKPointMode.Lines, points_1v, new SKPaint()
            {
                StrokeWidth = 2, Color = SKColors.Orange, PathEffect = SKPathEffect.CreateDash(new float[] { 5f, 5f }, 20f)
            });
            // 2번 광선 표시 (가상)
            canvas.DrawPoints(SKPointMode.Lines, points_2v, new SKPaint()
            {
                StrokeWidth = 2, Color = SKColors.Green, PathEffect = SKPathEffect.CreateDash(new float[] { 5f, 5f }, 20f)
            });
            // 3번 광선 표시 (가상)
            canvas.DrawPoints(SKPointMode.Lines, points_3v, new SKPaint()
            {
                StrokeWidth = 2, Color = SKColors.Blue, PathEffect = SKPathEffect.CreateDash(new float[] { 5f, 5f }, 20f)
            });
            // 4번 광선 표시 (가상)
            canvas.DrawPoints(SKPointMode.Lines, points_4v, new SKPaint()
            {
                StrokeWidth = 2, Color = SKColors.DeepPink, PathEffect = SKPathEffect.CreateDash(new float[] { 5f, 5f }, 20f)
            });

            // 광학 기기 표시
            canvas.DrawBitmap(opticalBitmap, originPoint + new SKPoint(-opticalBitmap.Width / 2, -opticalBitmap.Height / 2));

            if (objectBitmap != null)
            {
                // 물체 표시
                canvas.DrawBitmap(objectBitmap, SKRect.Create(originPoint + new SKPoint(-A - ObjectSize / objectBitmap.Height * objectBitmap.Width / 2, -ObjectSize), new SKSize(ObjectSize / objectBitmap.Height * objectBitmap.Width, ObjectSize)));

                // 상 표시
                if (Optical == OpticalType.oga || Optical == OpticalType.bolga)
                {
                    if (M > 0)
                    {
                        canvas.DrawBitmap(reverseBitmap, SKRect.Create(originPoint + new SKPoint(-B - ImageSize / reverseBitmap.Height * reverseBitmap.Width / 2, 0), new SKSize(ImageSize / reverseBitmap.Height * reverseBitmap.Width, ImageSize)), imagePaint);
                    }
                    else if (M < 0)
                    {
                        canvas.DrawBitmap(horizontalBitmap, SKRect.Create(originPoint + new SKPoint(-B - ImageSize / horizontalBitmap.Height * horizontalBitmap.Width / 2, -ImageSize), new SKSize(ImageSize / horizontalBitmap.Height * horizontalBitmap.Width, ImageSize)), imagePaint);
                    }
                }
                else if (Optical == OpticalType.bollen || Optical == OpticalType.olen)
                {
                    if (M > 0)
                    {
                        canvas.DrawBitmap(verticalBitmap, SKRect.Create(originPoint + new SKPoint(B - ImageSize / verticalBitmap.Height * verticalBitmap.Width / 2, 0), new SKSize(ImageSize / verticalBitmap.Height * verticalBitmap.Width, ImageSize)), imagePaint);
                    }
                    else if (M < 0)
                    {
                        canvas.DrawBitmap(objectBitmap, SKRect.Create(originPoint + new SKPoint(B - ImageSize / objectBitmap.Height * objectBitmap.Width / 2, -ImageSize), new SKSize(ImageSize / objectBitmap.Height * objectBitmap.Width, ImageSize)), imagePaint);
                    }
                }
            }
        }
コード例 #24
0
        protected override void OnDrawSample(SKCanvas canvas, int width, int height)
        {
            canvas.Clear(SKColors.White);
            canvas.Scale(2);

            var points = new[]
            {
                new SKPoint(10, 10),
                new SKPoint(50, 20),
                new SKPoint(100, 150)
            };

            using (SKPaint paint = new SKPaint())
                using (SKPaint textPaint = new SKPaint())
                {
                    paint.Style       = SKPaintStyle.Stroke;
                    paint.StrokeWidth = 5;
                    paint.IsAntialias = true;
                    paint.StrokeCap   = SKStrokeCap.Round;

                    textPaint.IsAntialias = true;

                    using (SKPath path = new SKPath())
                    {
                        // create a conic path
                        path.MoveTo(points[0]);
                        path.ConicTo(points[1], points[2], 10);

                        // draw the conic-based path
                        paint.Color = SampleMedia.Colors.XamarinDarkBlue;
                        canvas.DrawPath(path, paint);

                        // get the quads from the conic points
                        SKPoint[] pts;
                        var       quads = SKPath.ConvertConicToQuads(points[0], points[1], points[2], 10, out pts, 2);

                        // move the points on a bit
                        for (int i = 0; i < pts.Length; i++)
                        {
                            pts[i].Offset(120, 0);
                        }
                        // draw the quad-based path
                        using (var quadsPath = new SKPath())
                        {
                            quadsPath.MoveTo(pts[0].X, pts[0].Y);
                            for (int i = 0; i < quads; i++)
                            {
                                var idx = i * 2;
                                quadsPath.CubicTo(
                                    pts[idx].X, pts[idx].Y,
                                    pts[idx + 1].X, pts[idx + 1].Y,
                                    pts[idx + 2].X, pts[idx + 2].Y);
                            }

                            paint.Color = SampleMedia.Colors.XamarinPurple;
                            canvas.DrawPath(quadsPath, paint);
                        }

                        // move the points on a bit
                        for (int i = 0; i < pts.Length; i++)
                        {
                            pts[i].Offset(120, 0);
                        }
                        // draw the dots
                        paint.Color = SampleMedia.Colors.XamarinGreen;
                        canvas.DrawPoints(SKPointMode.Points, pts, paint);
                    }
                }
        }
コード例 #25
0
        void OnCanvasViewPaintSurface(object sender, SKPaintSurfaceEventArgs args)
        {
            SKImageInfo info    = args.Info;
            SKSurface   surface = args.Surface;
            SKCanvas    canvas  = surface.Canvas;

            canvas.Clear();


            if (info.Width > info.Height)
            {
                this.graphMinHeightPercentage = Graph.graphTopPaddingPercentage;
            }
            else
            {
                this.graphMinHeightPercentage = Graph.defaultGraphMinHeightPercentage;
            }

            DateTime startDate = new DateTime(2018, 11, 1);
            DateTime endDate   = new DateTime(2018, 12, 8);

            bool success = this.graph.CalculatePoints(Graph.defaultGraphWidthPercentage, this.graphMinHeightPercentage * 100, info.Width, info.Height, startDate, endDate);


            List <List <SKPoint> > graphLines       = this.graph.GetGraphLines();
            List <List <SKPoint> > graphLinesFill   = this.graph.GetGraphLinesFill();
            List <List <SKPoint> > graphHelperLines = this.graph.GetGraphHelperLines();

            SKPaint paint = new SKPaint {
                Color       = SKColors.LightGray.WithAlpha(0xAA),
                StrokeWidth = 1,
                StrokeCap   = SKStrokeCap.Square,
                Style       = SKPaintStyle.Stroke,
                IsAntialias = true
            };

            foreach (List <SKPoint> graphHelperLine in graphHelperLines)
            {
                canvas.DrawPoints(SKPointMode.Lines, graphHelperLine.ToArray(), paint);
            }

            paint.StrokeCap = SKStrokeCap.Round;

            for (int i = 0; i < graphLines.Count; ++i)
            {
                paint.Color       = graph.colorList[i];
                paint.Style       = SKPaintStyle.Stroke;
                paint.StrokeWidth = 2;
                canvas.DrawPoints(SKPointMode.Polygon, graphLines[i].ToArray(), paint);
                paint.StrokeWidth = 6;
                canvas.DrawPoints(SKPointMode.Points, graphLines[i].ToArray(), paint);
                paint.Color = paint.Color.WithAlpha(0x50);
                paint.Style = SKPaintStyle.Fill;
                SKPath path = new SKPath();
                path.AddPoly(graphLinesFill[i].ToArray());
                canvas.DrawPath(path, paint);
            }

            paint.StrokeWidth = 4;
            paint.Color       = SKColors.Black;


            float bottomY = (1 - this.graphMinHeightPercentage) * info.Height;
            float topY    = (Graph.graphTopPaddingPercentage - axisExtensionPercentage) * info.Height;
            float leftX   = Graph.graphLeftPaddingPercentage * info.Width;
            float rightX  = (Graph.graphLeftPaddingPercentage + this.graphWidthPercentage + axisExtensionPercentage) * info.Width;

            List <SKPoint> horizontalAxis = new List <SKPoint> {
                //Axis
                new SKPoint(leftX, bottomY),
                new SKPoint(rightX, bottomY),


                //Arrow
                new SKPoint(rightX, bottomY),
                new SKPoint(rightX - arrowOffset, bottomY - arrowOffset),

                new SKPoint(rightX, bottomY),
                new SKPoint(rightX - arrowOffset, bottomY + arrowOffset),
            };
            List <SKPoint> verticalAxis = new List <SKPoint> {
                //Axis
                new SKPoint(leftX, bottomY),
                new SKPoint(leftX, topY),

                //Arrow

                new SKPoint(leftX, topY),
                new SKPoint(leftX - arrowOffset, topY + arrowOffset),

                new SKPoint(leftX, topY),
                new SKPoint(leftX + arrowOffset, topY + arrowOffset),
            };

            canvas.DrawPoints(SKPointMode.Lines, horizontalAxis.ToArray(), paint);
            canvas.DrawPoints(SKPointMode.Lines, verticalAxis.ToArray(), paint);
            if (success)
            {
                List <Graph.GraphValue> graphValues = this.graph.GetGraphValues();
                List <Graph.GraphValue> xValues     = this.graph.GetXValues();

                SKPaint textPaint = new SKPaint {
                    Color       = SKColors.Blue,
                    IsAntialias = true,
                };

                float textWidth = textPaint.MeasureText("22.22");
                textPaint.TextSize = Graph.graphLeftPaddingPercentage * info.Width * textScalePercentage * textPaint.TextSize / textWidth;
                SKRect textBounds = new SKRect();

                foreach (Graph.GraphValue graphValue in graphValues)
                {
                    textPaint.MeasureText(graphValue.Value, ref textBounds);

                    float xText = info.Width * (Graph.graphLeftPaddingPercentage + Graph.graphLeftPaddingPercentage * textPaddingPercentage) / 2 - textBounds.MidX;

                    canvas.DrawText(graphValue.Value, xText, (float)graphValue.anchor.Y - textBounds.MidY, textPaint);
                }

                foreach (Graph.GraphValue xValue in xValues)
                {
                    textPaint.MeasureText(xValue.Value, ref textBounds);
                    float yText = bottomY + textBounds.Height + 10;
                    canvas.DrawText(xValue.Value, (float)xValue.anchor.X - textBounds.MidX, yText, textPaint);
                }
            }
        }
コード例 #26
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="args"></param>
        void CanvasView_ReDraw(object sender, SKPaintSurfaceEventArgs args)
        {
            SKImageInfo info    = args.Info;
            SKSurface   surface = args.Surface;
            SKCanvas    canvas  = surface.Canvas;

            float hourlyWidth = Convert.ToSingle(info.Width) / 24f;

            float min, max, minInHours, maxInHours;

            canvas.Clear(SKColors.White);

            SKPaint sleepPaint = new SKPaint
            {
                Style       = SKPaintStyle.Fill,
                Color       = ViewTools.DarkGray.ToSKColor(),
                StrokeWidth = 3,
                IsAntialias = true
            };

            SKPaint skPaint = new SKPaint()
            {
                Style       = SKPaintStyle.StrokeAndFill,
                Color       = SKColors.DarkBlue,
                StrokeWidth = 3,
                IsAntialias = true,
            };

            SKPaint gridPaint = new SKPaint
            {
                Style       = SKPaintStyle.Stroke,
                Color       = Color.Black.ToSKColor(),
                StrokeWidth = 3,
                IsAntialias = true,
            };

            foreach (var sleepingSpan in SleepingSpans)
            {
                min = Convert.ToSingle(sleepingSpan.RangeSliderView.RangeSlider.LowerValue);
                max = Convert.ToSingle(sleepingSpan.RangeSliderView.RangeSlider.UpperValue);

                minInHours = min / 60f;
                maxInHours = max / 60f;

                canvas.DrawRect(new SKRect(minInHours * hourlyWidth,
                                           info.Height,
                                           maxInHours * hourlyWidth,
                                           0), sleepPaint);
            }

            foreach (var downSpan in DownSpans)
            {
                min = Convert.ToSingle(downSpan.RangeSliderView.RangeSlider.LowerValue);
                max = Convert.ToSingle(downSpan.RangeSliderView.RangeSlider.UpperValue);

                minInHours = min / 60f;
                maxInHours = max / 60f;

                SKPoint[] skPointsList = new SKPoint[]
                {
                    //Point Bottom
                    new SKPoint(minInHours * hourlyWidth, info.Height),
                    //Point Right
                    new SKPoint(minInHours * hourlyWidth + (hourlyWidth / 2), info.Height / 2),
                    new SKPoint(minInHours * hourlyWidth + (hourlyWidth / 2), info.Height / 2),

                    //Point Center
                    new SKPoint(minInHours * hourlyWidth, info.Height / 2),

                    //Point Top
                    new SKPoint(minInHours * hourlyWidth, 0),
                    new SKPoint(minInHours * hourlyWidth, 0),

                    //Point Center
                    new SKPoint(minInHours * hourlyWidth, info.Height / 2),

                    //Point Left
                    new SKPoint(minInHours * hourlyWidth - (hourlyWidth / 2), info.Height / 2),
                    new SKPoint(minInHours * hourlyWidth - (hourlyWidth / 2), info.Height / 2),

                    //Point Bottom
                    new SKPoint(minInHours * hourlyWidth, info.Height),
                };

                canvas.DrawPoints(SKPointMode.Lines, skPointsList, skPaint);

                skPointsList = new SKPoint[]
                {
                    //Point Bottom
                    new SKPoint(maxInHours * hourlyWidth, 0),
                    //Point Right
                    new SKPoint(maxInHours * hourlyWidth + (hourlyWidth / 2), info.Height / 2),
                    new SKPoint(maxInHours * hourlyWidth + (hourlyWidth / 2), info.Height / 2),

                    //Point Center
                    new SKPoint(maxInHours * hourlyWidth, info.Height / 2),

                    //Point Top
                    new SKPoint(maxInHours * hourlyWidth, info.Height),
                    new SKPoint(maxInHours * hourlyWidth, info.Height),

                    //Point Center
                    new SKPoint(maxInHours * hourlyWidth, info.Height / 2),

                    //Point Left
                    new SKPoint(maxInHours * hourlyWidth - (hourlyWidth / 2), info.Height / 2),
                    new SKPoint(maxInHours * hourlyWidth - (hourlyWidth / 2), info.Height / 2),

                    //Point Bottom
                    new SKPoint(maxInHours * hourlyWidth, 0),
                };

                canvas.DrawPoints(SKPointMode.Lines, skPointsList, skPaint);
            }

            for (int i = 1; i <= 24; i++)
            {
                canvas.DrawRect(new SKRect(0, info.Height, hourlyWidth * i, 0), gridPaint);
            }
        }
コード例 #27
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="sleepingSpans"></param>
        /// <param name="downSpans"></param>
        /// <param name="holder"></param>
        public SleepDiagramView(List <Tuple <double, double> > sleepingSpans, List <Tuple <double, double> > downSpans, string holder)
        {
            sleepingSpansTuple = sleepingSpans;
            downSpansTuple     = downSpans;

            int docHeight = 100;
            int docWidth  = 1600;

            var surface = SKSurface.Create(docWidth, docHeight, SKImageInfo.PlatformColorType, SKAlphaType.Premul);

            var surfWidth  = surface.Snapshot().Width;
            var surfHeight = surface.Snapshot().Height;

            var barHeight = 75;

            SKCanvas canvas = surface.Canvas;

            float hourlyWidth = Convert.ToSingle(surfWidth - 300) / 24f;

            float min, max, minInHours, maxInHours;

            canvas.Clear(SKColors.White);

            SKPaint sleepPaint = new SKPaint
            {
                Style       = SKPaintStyle.Fill,
                Color       = ViewTools.DarkGray.ToSKColor(),
                StrokeWidth = 3,
                IsAntialias = true
            };

            SKPaint skPaint = new SKPaint()
            {
                Style       = SKPaintStyle.StrokeAndFill,
                Color       = SKColors.DarkBlue,
                StrokeWidth = 3,
                IsAntialias = true,
            };

            SKPaint gridPaint = new SKPaint
            {
                Style       = SKPaintStyle.Stroke,
                Color       = Color.Black.ToSKColor(),
                StrokeWidth = 3,
                IsAntialias = true,
            };

            SKPaint writer = new SKPaint
            {
                TextSize    = 16.0f,
                IsAntialias = true,
                Color       = SKColors.Black,
                TextAlign   = SKTextAlign.Center
            };

            foreach (var sleepingSpan in sleepingSpansTuple)
            {
                min = Convert.ToSingle(sleepingSpan.Item1);
                max = Convert.ToSingle(sleepingSpan.Item2);

                minInHours = min / 60f;
                maxInHours = max / 60f;

                canvas.DrawRect(new SKRect(minInHours * hourlyWidth,
                                           barHeight,
                                           maxInHours * hourlyWidth,
                                           0), sleepPaint);
            }

            foreach (var downSpan in downSpansTuple)
            {
                min = Convert.ToSingle(downSpan.Item1);
                max = Convert.ToSingle(downSpan.Item2);

                minInHours = min / 60f;
                maxInHours = max / 60f;

                SKPoint[] skPointsList = new SKPoint[]
                {
                    //Point Bottom
                    new SKPoint(minInHours * hourlyWidth, barHeight),
                    //Point Right
                    new SKPoint(minInHours * hourlyWidth + (hourlyWidth / 2), barHeight / 2),
                    new SKPoint(minInHours * hourlyWidth + (hourlyWidth / 2), barHeight / 2),

                    //Point Center
                    new SKPoint(minInHours * hourlyWidth, barHeight / 2),

                    //Point Top
                    new SKPoint(minInHours * hourlyWidth, 0),
                    new SKPoint(minInHours * hourlyWidth, 0),

                    //Point Center
                    new SKPoint(minInHours * hourlyWidth, barHeight / 2),

                    //Point Left
                    new SKPoint(minInHours * hourlyWidth - (hourlyWidth / 2), barHeight / 2),
                    new SKPoint(minInHours * hourlyWidth - (hourlyWidth / 2), barHeight / 2),

                    //Point Bottom
                    new SKPoint(minInHours * hourlyWidth, barHeight),
                };

                canvas.DrawPoints(SKPointMode.Lines, skPointsList, skPaint);

                skPointsList = new SKPoint[]
                {
                    //Point Bottom
                    new SKPoint(maxInHours * hourlyWidth, 0),
                    //Point Right
                    new SKPoint(maxInHours * hourlyWidth + (hourlyWidth / 2), barHeight / 2),
                    new SKPoint(maxInHours * hourlyWidth + (hourlyWidth / 2), barHeight / 2),

                    //Point Center
                    new SKPoint(maxInHours * hourlyWidth, barHeight / 2),

                    //Point Top
                    new SKPoint(maxInHours * hourlyWidth, barHeight),
                    new SKPoint(maxInHours * hourlyWidth, barHeight),

                    //Point Center
                    new SKPoint(maxInHours * hourlyWidth, barHeight / 2),

                    //Point Left
                    new SKPoint(maxInHours * hourlyWidth - (hourlyWidth / 2), barHeight / 2),
                    new SKPoint(maxInHours * hourlyWidth - (hourlyWidth / 2), barHeight / 2),

                    //Point Bottom
                    new SKPoint(maxInHours * hourlyWidth, 0),
                };

                canvas.DrawPoints(SKPointMode.Lines, skPointsList, skPaint);
            }

            for (int i = 1; i <= 24; i++)
            {
                canvas.DrawRect(new SKRect(0, barHeight, hourlyWidth * i, 0), gridPaint);

                canvas.DrawText(GetTranslatedTime(i - 1), (hourlyWidth * i) - hourlyWidth / 2f, 100, writer);
            }

            ImgData = surface.Snapshot();

            OnDrawCompleted(new EventArgs());
        }