Esempio n. 1
0
        public void drawGrid(double s, CanvasDrawingSession ds)
        {
            CanvasPathBuilder pathBuilder = new CanvasPathBuilder(ds);

            for (float x0 = 0.5f; x0 < 8.5f; x0 += 1)
            {
                pathBuilder.BeginFigure(0, x0);
                for (float y0 = 0.5f; y0 < 8.5; y0 += 0.5f)
                {
                    var a = Math.Atan2(y0, x0) * 2 / 3;
                    var r = Math.Sqrt(x0 * x0 + y0 * y0);
                    var x = r * Math.Sin(a);
                    var y = r * Math.Cos(a);
                    pathBuilder.AddLine((float)x, (float)y);
                }
                pathBuilder.EndFigure(CanvasFigureLoop.Open);
            }
            //  rotate and reflect the result
            var onep = CanvasGeometry.CreatePath(pathBuilder);

            for (int a = 0; a < 6; a++)
            {
                var m = Matrix3x2.Identity * Matrix.CreateRotation(Math.PI / 6 + a * Math.PI / 3);
                ds.DrawGeometry(onep.Transform(m), Colors.DarkGray, 1 / (float)s);
                m = m * Matrix.CreateScale(1, -1);
                ds.DrawGeometry(onep.Transform(m), Colors.DarkGray, 1 / (float)s);
            }
        }
Esempio n. 2
0
        public bool DrawString(
            CanvasDrawingSession graphics,
            CanvasTextLayout textLayout,
            float x, float y)
        {
            using (CanvasGeometry geometry = CanvasGeometry.CreateText(textLayout))
            {
                CanvasStrokeStyle stroke = new CanvasStrokeStyle();
                stroke.DashStyle = CanvasDashStyle.Solid;
                stroke.DashCap   = CanvasCapStyle.Round;
                stroke.StartCap  = CanvasCapStyle.Round;
                stroke.EndCap    = CanvasCapStyle.Round;
                stroke.LineJoin  = CanvasLineJoin.Round;

                for (int i = m_nThickness1; i <= m_nThickness1 + m_nThickness2; ++i)
                {
                    graphics.DrawGeometry(geometry, x, y, m_clrOutline2, i, stroke);
                }
                graphics.DrawGeometry(geometry, x, y, m_clrOutline1, m_nThickness1, stroke);
                if (m_bClrText)
                {
                    graphics.FillGeometry(geometry, x, y, m_clrText);
                }
                else
                {
                    graphics.FillGeometry(geometry, x, y, m_brushText);
                }
            }
            return(true);
        }
Esempio n. 3
0
 public void Draw(CanvasDrawingSession cds)
 {
     if (this.Selected == true)
     {
         cds.DrawGeometry(this.Line, this.SelectedLineColor, this.LineWidth);
     }
     else
     {
         cds.DrawGeometry(this.Line, this.LineColor, this.LineWidth);
     }
 }
Esempio n. 4
0
 public void Draw(CanvasDrawingSession cds)
 {
     Debug.WriteLine("Drawing Vertex");
     if (this.Selected == true)
     {
         cds.DrawGeometry(this.Circle, this.SelectedLineColor, this.LineWidth);
     }
     else
     {
         cds.DrawGeometry(this.Circle, this.LineColor, this.LineWidth);
     }
     this.Redraw = false;
 }
Esempio n. 5
0
        private void RenderData(CanvasDrawingSession ds, double width, double height)
        {
            if (data.Count == 0)
            {
                return;
            }
            float thickness = 1;
            float w         = (float)width * data.Count / 300;
            float xs        = w / data.Count;
            float x0        = (float)width - w;

            using (var cpb = new CanvasPathBuilder(ds))
            {
                cpb.BeginFigure(new Vector2((float)(axis[0] * width), (float)(height * (1 - data[0]))));

                for (int i = 1; i < data.Count; i++)
                {
                    //cpb.AddLine(new Vector2(i*xs + x0, (float)(height * (1 - data[i]))));
                    cpb.AddLine(new Vector2((float)(axis[i] * width), (float)(height * (1 - data[i]))));
                }

                if (renderArea)
                {
                    cpb.AddLine(new Vector2(data.Count * xs + x0, (float)height));
                    cpb.AddLine(new Vector2(x0, (float)height));
                    cpb.EndFigure(CanvasFigureLoop.Closed);
                    ds.FillGeometry(CanvasGeometry.CreatePath(cpb), color);
                }
                else
                {
                    cpb.EndFigure(CanvasFigureLoop.Open);
                    ds.DrawGeometry(CanvasGeometry.CreatePath(cpb), color, thickness);
                }
            }
        }
Esempio n. 6
0
        internal override void Draw(CanvasControl cc, CanvasDrawingSession ds, float scale, Vector2 center, FlipState flip)
        {
            var color  = GetColor(Coloring.Normal);
            var points = GetDrawingPoints(flip, scale, center);

            if (points.Length == 2)
            {
                ds.DrawLine(points[0], points[1], color, StrokeWidth, StrokeStyle());
            }
            else if (points.Length > 2)
            {
                using (var pb = new CanvasPathBuilder(cc))
                {
                    pb.BeginFigure(points[0]);
                    for (int i = 1; i < points.Length; i++)
                    {
                        pb.AddLine(points[i]);
                    }
                    pb.EndFigure(CanvasFigureLoop.Open);

                    using (var geo = CanvasGeometry.CreatePath(pb))
                    {
                        if (FillStroke == Fill_Stroke.Filled)
                        {
                            ds.FillGeometry(geo, color);
                        }
                        else
                        {
                            ds.DrawGeometry(geo, color, StrokeWidth, StrokeStyle());
                        }
                    }
                }
            }
        }
Esempio n. 7
0
        internal override void Draw(CanvasControl cc, CanvasDrawingSession ds, float scale, Vector2 center, FlipState flip)
        {
            var color  = GetColor(Coloring.Normal);
            var points = GetDrawingPoints(flip, scale, center);

            using (var pb = new CanvasPathBuilder(cc))
            {
                pb.BeginFigure(points[0]);
                var N = DXY.Count;
                for (var i = 0; i < N - 2;)
                {
                    pb.AddCubicBezier(points[i], points[++i], points[++i]);
                }
                pb.EndFigure(CanvasFigureLoop.Open);

                using (var geo = CanvasGeometry.CreatePath(pb))
                {
                    if (FillStroke == Fill_Stroke.Filled)
                    {
                        ds.FillGeometry(geo, color);
                    }
                    else
                    {
                        ds.DrawGeometry(geo, color, StrokeWidth, StrokeStyle());
                    }
                }
            }
        }
Esempio n. 8
0
        public static void DrawComponents(Data.Layer layer, CanvasDrawingSession ds, float rescale, Color componentColor,
                                          bool drawSelection = false)
        {
            var margin                 = 4 * rescale;
            var originColor            = Color.FromArgb(135, 34, 34, 34);
            var selectedComponentColor = Color.FromArgb(
                135,
                (byte)Math.Max(componentColor.R - 90, 0),
                (byte)Math.Max(componentColor.G - 90, 0),
                (byte)Math.Max(componentColor.B - 90, 0)
                );

            foreach (var component in layer.Components)
            {
                ds.FillGeometry(component.ClosedCanvasPath, drawSelection && component.IsSelected ? selectedComponentColor : componentColor);
                ds.DrawGeometry(component.OpenCanvasPath, componentColor, strokeWidth: rescale);

                if (drawSelection && component.IsSelected)
                {
                    var origin = component.Origin;
                    ds.DrawLine(origin.X, origin.Y + margin, origin.X, origin.Y - margin, originColor, strokeWidth: rescale);
                    ds.DrawLine(origin.X - margin, origin.Y, origin.X + margin, origin.Y, originColor, strokeWidth: rescale);
                }
            }
        }
        private void DrawDryInk_GeometryMethod(CanvasDrawingSession ds, IReadOnlyList <InkStroke> strokes)
        {
            //
            // This converts the ink strokes to geometry, then draws the geometry outline
            // with a dotted stroke style.
            //
            var strokeStyle = new CanvasStrokeStyle {
                DashStyle = CanvasDashStyle.Dot
            };

            var strokesGroupedByColor = from stroke in strokes
                                        where !IsPencilStroke(stroke)
                                        group stroke by stroke.DrawingAttributes.Color into strokesOfColor
                                        select strokesOfColor;

            foreach (var strokesOfColor in strokesGroupedByColor)
            {
                var geometry = CanvasGeometry.CreateInk(ds, strokesOfColor.ToList()).Outline();

                ds.DrawGeometry(geometry, strokesOfColor.Key, 1, strokeStyle);
            }

            // Display text labels in place of any pencil strokes, because we cannot create geometry for those.
            foreach (var pencilStroke in strokes.Where(IsPencilStroke))
            {
                ds.DrawText("CanvasGeometry.CreateInk does not support pencil strokes",
                            pencilStroke.BoundingRect,
                            pencilStroke.DrawingAttributes.Color,
                            centerTextFormat);
            }
        }
Esempio n. 10
0
        private void DrawDryInk_CustomGeometryMethod(CanvasDrawingSession ds, IReadOnlyList <InkStroke> strokes)
        {
            //
            // This shows off the fact that apps can use the custom drying path
            // to render dry ink using Win2D, and not necessarily
            // rely on the built-in rendering in CanvasDrawingSession.DrawInk.
            //
            foreach (var stroke in strokes)
            {
                var color = stroke.DrawingAttributes.Color;

                var inkPoints = stroke.GetInkPoints();
                if (inkPoints.Count > 0)
                {
                    CanvasPathBuilder pathBuilder = new CanvasPathBuilder(canvasControl);
                    pathBuilder.BeginFigure(inkPoints[0].Position.ToVector2());
                    for (int i = 1; i < inkPoints.Count; i++)
                    {
                        pathBuilder.AddLine(inkPoints[i].Position.ToVector2());
                        ds.DrawCircle(inkPoints[i].Position.ToVector2(), 3, color);
                    }
                    pathBuilder.EndFigure(CanvasFigureLoop.Open);
                    CanvasGeometry geometry = CanvasGeometry.CreatePath(pathBuilder);
                    ds.DrawGeometry(geometry, color);
                }
            }
        }
Esempio n. 11
0
        public void DrawPath(Path path, Paint paint)
        {
            UpdateDrawingSessionWithFlags(paint.Flags);

            _drawingSession.Transform = GetCurrentTransform();

            var gradient = paint.Shader as Gradient;
            var brush    = gradient != null?gradient.GetBrush(_device, paint.Alpha) : new CanvasSolidColorBrush(_device, paint.Color);

            brush = paint.ColorFilter?.Apply(this, brush) ?? brush;

            using (var geometry = path.GetGeometry(_device))
            {
                if (paint.Style == Paint.PaintStyle.Stroke)
                {
                    _drawingSession.DrawGeometry(geometry, brush, paint.StrokeWidth, GetCanvasStrokeStyle(paint));
                }
                else
                {
                    _drawingSession.FillGeometry(geometry, brush);
                }
            }

            if (gradient == null)
            {
                brush.Dispose();
            }
        }
Esempio n. 12
0
        public void DisplayRegionEditInProgress(CanvasDrawingSession drawingSession, List <Vector2> points, float zoomFactor)
        {
            if (RegionSelectionMode == SelectionMode.MagicWand)
            {
                // Display a magic wand selection.
                var mask   = GetMagicWandMask(points, zoomFactor);
                var border = GetSelectionBorder(mask, zoomFactor);

                drawingSession.Blend = CanvasBlend.Add;
                drawingSession.DrawImage(mask, Vector2.Zero, SourceBitmap.Bounds, 0.25f);

                drawingSession.Blend = CanvasBlend.SourceOver;
                drawingSession.DrawImage(border);
            }
            else
            {
                // Display a geometric shape selection.
                var geometry = GetSelectionGeometry(drawingSession, points);

                drawingSession.Blend = CanvasBlend.Add;
                drawingSession.FillGeometry(geometry, Color.FromArgb(0x20, 0xFF, 0xFF, 0xFF));

                drawingSession.Blend = CanvasBlend.SourceOver;
                drawingSession.DrawGeometry(geometry, Colors.Magenta, 1f / zoomFactor);
            }
        }
Esempio n. 13
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="cds"></param>
 /// <param name="dn"></param>
 public static void DrawNode(
     CanvasDrawingSession cds,
     DrawableVertex dn)
 {
     //cds.DrawCircle(dn.Position, Defines.VERTEX_SIZE, Defines.DEFAULT_NODE_COLOR, Defines.NODE_LINE_WIDTH);
     cds.DrawGeometry(dn.Circle, Defines.DEFAULT_NODE_COLOR, Defines.NODE_LINE_WIDTH);
 }
Esempio n. 14
0
        public void DrawCommon(CanvasDrawingSession g)
        {
            //save tansform
            var save = g.Transform;

            g.FillRectangle(new Rect(P11.X - 2, P11.Y - 2, 4, 4), Pen.Color);

            using (var pathBuilder = new CanvasPathBuilder(g))
            {
                pathBuilder.BeginFigure(P11);
                pathBuilder.AddLine(P12);
                pathBuilder.AddLine(P22);
                pathBuilder.AddLine(P21);
                pathBuilder.EndFigure(CanvasFigureLoop.Closed);
                g.DrawGeometry(CanvasGeometry.CreatePath(pathBuilder), Pen.Color, Pen.Width);
            }

            if (IsGlyphVisible)
            {
                drawOrthogonalGlyph(g, P11, P12, P21);
                drawOrthogonalGlyph(g, P12, P11, P22);
                drawOrthogonalGlyph(g, P21, P11, P22);
                drawOrthogonalGlyph(g, P22, P21, P12);
            }

            drawMeasure(g, P11, P12);
            drawMeasure(g, P12, P22);
            drawMeasure(g, P22, P21);
            drawMeasure(g, P21, P11);

            //recover transform
            g.Transform = save;
        }
Esempio n. 15
0
        private void DrawFileViewLasso(
            CanvasDrawingSession ds, float leftTop, float leftHeight, float rightTop, float rightHeight)
        {
            var pathBuilder = new CanvasPathBuilder(ds);

            float num1 = Math.Min(4.0f, leftHeight * 0.5f);  // bezier curve control point
            float num2 = Math.Min(4.0f, rightHeight * 0.5f); // bezier curve control point
            float y1   = leftTop + leftHeight;
            float y2   = rightTop + rightHeight;

            pathBuilder.BeginFigure(new Vector2(32.0f, leftTop));
            pathBuilder.AddLine(new Vector2(36.0f, rightTop));
            pathBuilder.AddLine(new Vector2(56.0f, rightTop));
            pathBuilder.AddQuadraticBezier(new Vector2(60.0f, rightTop), new Vector2(60.0f, rightTop + num2));
            pathBuilder.AddLine(new Vector2(60.0f, y2 - num2));
            pathBuilder.AddQuadraticBezier(new Vector2(60.0f, y2), new Vector2(56.0f, y2));
            pathBuilder.AddLine(new Vector2(36.0f, y2));
            pathBuilder.AddLine(new Vector2(32.0f, y1));
            pathBuilder.AddLine(new Vector2(12.0f, y1));
            pathBuilder.AddQuadraticBezier(new Vector2(8.0f, y1), new Vector2(8.0f, y1 - num1));
            pathBuilder.AddLine(new Vector2(8.0f, leftTop + num1));
            pathBuilder.AddQuadraticBezier(new Vector2(8.0f, leftTop), new Vector2(12.0f, leftTop));
            pathBuilder.EndFigure(CanvasFigureLoop.Closed);

            var finalGeo = CanvasGeometry.CreatePath(pathBuilder);

            ds.DrawGeometry(finalGeo, _lassoColor);
        }
Esempio n. 16
0
        public void Draw(CanvasRenderTarget crt, Color lineColor, float lineWidth, Color fillColor, Matrix3x2 m)
        {
            //CanvasDevice device = CanvasDevice.GetSharedDevice();
            //CanvasRenderTarget offscreen = new CanvasRenderTarget(device, width, height, 96);
            using (CanvasDrawingSession ds = crt.CreateDrawingSession())
            {
                //ds.Clear(Colors.Transparent);
                //ds.DrawRectangle(100, 200, 5, 6, Colors.Red);
                // Debug.WriteLine(_cg.ComputeBounds().ToString());
                if (m.IsIdentity == false)
                {
                    _cg = _cg.Transform(m);
                    //Debug.WriteLine(_cg.ComputeBounds().ToString());
                }
                if (!(lineColor == Colors.Transparent))
                {
                    ds.DrawGeometry(_cg, lineColor, lineWidth);
                }

                if (fillColor != null)
                {
                    ds.FillGeometry(_cg, fillColor);
                }
            }
        }
Esempio n. 17
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="cds"></param>
 /// <param name="de"></param>
 public static void DrawEdge(
     CanvasDrawingSession cds,
     DrawableEdge de)
 {
     //cds.DrawLine(de.HeadPosition, de.TailPosition, Defines.DEF_EDGE_COLOR, Defines.DEF_EDGE_LINE_WIDTH);
     cds.DrawGeometry(de.Line, Defines.DEFAULT_NODE_COLOR, Defines.NODE_LINE_WIDTH);
 }
Esempio n. 18
0
        private void DrawSelectionLasso(CanvasControl sender, CanvasDrawingSession ds)
        {
            if (selectionPolylinePoints == null)
            {
                return;
            }

            if (selectionPolylinePoints.Count == 0)
            {
                return;
            }

            CanvasPathBuilder selectionLasso = new CanvasPathBuilder(canvasControl);

            selectionLasso.BeginFigure(selectionPolylinePoints[0].ToVector2());
            for (int i = 1; i < selectionPolylinePoints.Count; ++i)
            {
                selectionLasso.AddLine(selectionPolylinePoints[i].ToVector2());
            }
            selectionLasso.EndFigure(CanvasFigureLoop.Open);

            CanvasGeometry pathGeometry = CanvasGeometry.CreatePath(selectionLasso);

            ds.DrawGeometry(pathGeometry, Colors.Magenta, 5.0f);
        }
 /// <summary>
 /// Draws a Squircle of the specified dimensions, using a CanvasStroke to define the stroke
 /// width, the stroke color and stroke style.
 /// </summary>
 /// <param name="session">CanvasDrawingSession</param>
 /// <param name="x">Offset of the top left corner of the  Squircle on the x-axis</param>
 /// <param name="y">Offset of the top left corner of the  Squircle on the y-axis</param>
 /// <param name="w">Width of the  Squircle</param>
 /// <param name="h">Height of the  Squircle</param>
 /// <param name="radiusX">Corner Radius on the x axis</param>
 /// <param name="radiusY">Corner Radius on the y axis</param>
 /// <param name="offset">Offset of the Squircle from the origin.</param>
 /// <param name="stroke">CanvasStroke defining the stroke width, the stroke
 /// color and stroke style.</param>
 public static void DrawSquircle(this CanvasDrawingSession session, float x, float y, float w, float h,
                                 float radiusX, float radiusY, Vector2 offset, ICanvasStroke stroke)
 {
     using (var geometry = CanvasObject.CreateSquircle(session.Device, x, y, w, h, radiusX, radiusY))
     {
         session.DrawGeometry(geometry, offset, stroke);
     }
 }
 /// <summary>
 /// Draw lines on bound.
 /// </summary>
 /// <param name="drawingSession"> The drawing-session. </param>
 /// <param name="matrix"> The matrix. </param>
 /// <param name="accentColor"> The accent color. </param>
 public override void DrawBound(CanvasDrawingSession drawingSession, Matrix3x2 matrix, Windows.UI.Color accentColor)
 {
     if (this.Geometry2 == null)
     {
         return;
     }
     drawingSession.DrawGeometry(this.Geometry2.Transform(matrix), accentColor);
 }
Esempio n. 21
0
        private void RenderCheck(CanvasDrawingSession session)
        {
            if (checkGeometry == null)
            {
                checkGeometry = CreateGeometry(session);
            }

            session.DrawGeometry(checkGeometry, Colors.Black, 2);
        }
Esempio n. 22
0
        static void DrawContactGeometry(CanvasDrawingSession ds, CanvasGeometry geom)
        {
            if (geom == null)
            {
                return;
            }

            ds.FillGeometry(geom, Colors.Green);
            ds.DrawGeometry(geom, Colors.Blue, 5);
        }
Esempio n. 23
0
        internal virtual void drawArc(int x, int y, int w, int h, int startAngle, int arcAngle)
        {
            Vector2 center = new Vector2();

            center.X = x + w / 2;
            center.Y = y + h / 2;
            if (arcAngle == 360)
            {
                graphics.DrawEllipse(center, w / 2, h / 2, c);
            }
            else
            {
                CanvasPathBuilder builder = new CanvasPathBuilder(graphics);
                builder.BeginFigure(center);
                builder.AddArc(center, w / 2, h / 2, -(float)(2 * Math.PI * startAngle / 360), -(float)(2 * Math.PI * arcAngle / 360));
                builder.EndFigure(CanvasFigureLoop.Closed);
                graphics.DrawGeometry(CanvasGeometry.CreatePath(builder), c);
            }
        }
Esempio n. 24
0
        public void Render(Win2DRenderable renderable, CanvasDrawingSession session, Win2DColor color, bool renderControls)
        {
            if (hullGeometry == null)
            {
                return;
            }

            session.DrawGeometry(hullGeometry, renderable.Resources.Brush(color.Normal, 1.0f), 1f);
            session.FillGeometry(hullGeometry, renderable.Resources.Brush(color.Lighter, 0.5f));
        }
        public void Draw(double targetElapsedTimeInMs, long updateCount, CanvasDrawingSession ds)
        {
            ds.FillGeometry(clockFaceGeometry, backgroundBrush);

            double updatesPerSecond = 1000.0 / targetElapsedTimeInMs;
            int    seconds          = (int)((updateCount / updatesPerSecond) % 10);

            hueRotationEffect.Angle = (float)Math.PI * (seconds / 10.0f) * 2.0f;

            using (var timeSegmentGeometry = CreateTimeSegmentGeometry(ds, updateCount, updatesPerSecond))
            {
                ds.FillGeometry(timeSegmentGeometry, foregroundBrush);

                DrawSecondsText(ds, new Vector2(center), seconds);

                ds.DrawGeometry(timeSegmentGeometry, Colors.White, 1, hairlineStrokeStyle);
            }

            ds.DrawGeometry(clockFaceGeometry, Colors.White, 18, timeCircleStrokeStyle);
            ds.DrawGeometry(clockFaceGeometry, Colors.Black, 16, timeCircleStrokeStyle);
        }
        public async Task <Size> DrawOutlineText(int dim, string font, string text, string saved_file)
        {
            Size         size   = new Size();
            CanvasDevice device = CanvasDevice.GetSharedDevice();

            using (CanvasRenderTarget offscreen = new CanvasRenderTarget(device, dim, dim, 96, Windows.Graphics.DirectX.DirectXPixelFormat.B8G8R8A8UIntNormalized,
                                                                         CanvasAlphaMode.Premultiplied))
            {
                using (CanvasDrawingSession ds = offscreen.CreateDrawingSession())
                {
                    ds.Clear(ColorHelper.FromArgb(255, 255, 255, 255));

                    Color text_color = Colors.White;

                    CanvasSolidColorBrush brush  = new CanvasSolidColorBrush(device, text_color);
                    CanvasTextFormat      format = new CanvasTextFormat();
                    format.FontFamily = font;
                    format.FontStyle  = Windows.UI.Text.FontStyle.Normal;
                    format.FontSize   = 60;
                    format.FontWeight = Windows.UI.Text.FontWeights.Bold;

                    float            layoutWidth  = dim;
                    float            layoutHeight = dim;
                    CanvasTextLayout textLayout   = new CanvasTextLayout(device, text, format, layoutWidth, layoutHeight);
                    CanvasGeometry   geometry     = CanvasGeometry.CreateText(textLayout);

                    CanvasStrokeStyle stroke = new CanvasStrokeStyle();
                    stroke.DashStyle = CanvasDashStyle.Solid;
                    stroke.DashCap   = CanvasCapStyle.Round;
                    stroke.StartCap  = CanvasCapStyle.Round;
                    stroke.EndCap    = CanvasCapStyle.Round;
                    stroke.LineJoin  = CanvasLineJoin.Round;

                    ds.DrawGeometry(geometry, 10.0f, 10.0f, Colors.Black, 10.0f, stroke);

                    ds.FillGeometry(geometry, 10.0f, 10.0f, brush);
                }
                Windows.Storage.StorageFolder storageFolder =
                    Windows.Storage.ApplicationData.Current.TemporaryFolder;
                string saved_file2 = "\\";
                saved_file2 += saved_file;
                await offscreen.SaveAsync(storageFolder.Path + saved_file2);

                imgOutlineText.Source = new BitmapImage(new Uri(storageFolder.Path + saved_file2));

                using (CanvasDrawingSession ds = offscreen.CreateDrawingSession())
                {
                    ds.Clear(Colors.White);
                }

                return(size);
            }
        }
Esempio n. 27
0
 public void RenderObstacles(IObstacle[] obstacles)
 {
     foreach (var obs in obstacles)
     {
         var geom  = CanvasGeometry.CreatePolygon(canvas, obs.Points);
         var color = HexToColor("#ff032939");
         session.DrawGeometry(geom, color, 3, new CanvasStrokeStyle {
             LineJoin = CanvasLineJoin.Round
         });
         //session.FillGeometry(geom, color);
     }
 }
Esempio n. 28
0
        void DrawBezier(CanvasDrawingSession drawingSession, Vector2 start, Vector2 ctrl0, Vector2 ctrl1, Vector2 end)
        {
            CanvasPathBuilder pathBuilder = new CanvasPathBuilder(canvasControl);

            pathBuilder.BeginFigure(start);
            pathBuilder.AddCubicBezier(ctrl0, ctrl1, end);
            pathBuilder.EndFigure(CanvasFigureLoop.Open);

            CanvasGeometry geometry = CanvasGeometry.CreatePath(pathBuilder);

            drawingSession.DrawGeometry(geometry, Colors.White, 5.0f);
        }
Esempio n. 29
0
        public virtual void Draw(CanvasDrawingSession g, bool drawSelected = true)
        {
            if (drawSelected && IsSelected)
            {
                var groups = new CanvasGeometry[Geometries.Count];
                for (int i = 0; i < groups.Length; i++)
                {
                    groups[i] = Geometries[i].Geometry;
                }
                using (var group = CanvasGeometry.CreateGroup(g, groups))
                {
                    var bounds = group.ComputeBounds();
                    g.FillRectangle(bounds, Color.FromArgb(0x22, 0, 0, 0));
                    g.DrawRectangle(bounds, Context.SelectedBorderColor, Context.SelectedBorderWidth);
                }
            }

            foreach (var item in Geometries)
            {
                if (!item.IsDrawUnit)
                {
                    continue;
                }
                switch (item.Style)
                {
                case GeometryStyle.Stroke:
                    g.DrawGeometry(item.Geometry, item.StrokeColor, item.StrokeWidth);
                    break;

                case GeometryStyle.Fill:
                    g.FillGeometry(item.Geometry, item.FillColor);
                    break;

                case GeometryStyle.Both:
                    g.DrawGeometry(item.Geometry, item.StrokeColor, item.StrokeWidth);
                    g.FillGeometry(item.Geometry, item.FillColor);
                    break;
                }
            }
        }
        private void DrawStar(CanvasControl sender, CanvasDrawingSession ds)
        {
            var width  = (float)sender.ActualWidth;
            var height = (float)sender.ActualHeight;
            var stroke = this.defaultStroke;
            var scale  = (width / 2) - (stroke * 2);
            var center = new Vector2(width / 2, height / 2);

            var starGeometry = CreateStarGeometry(sender, scale, center);

            ds.FillGeometry(starGeometry, ForegroundColor);
            ds.DrawGeometry(starGeometry, GlowColor, stroke);
        }