Esempio n. 1
0
        public override void GetPatternRender(ICanvasResourceCreator resourceCreator, CanvasDrawingSession drawingSession, CanvasGeometry geometry)
        {
            ICanvasBrush      canvasBrush = this.Style.Stroke.GetICanvasBrush(resourceCreator);
            float             strokeWidth = this.Style.StrokeWidth;
            CanvasStrokeStyle strokeStyle = this.Style.StrokeStyle;

            Transformer       transformer = base.Transform.GetActualTransformer();
            TransformerBorder border      = new TransformerBorder(transformer);

            if (this.GridType != PatternGridType.Vertical)
            {
                for (float i = border.Left; i < border.Right; i += this.HorizontalStep)
                {
                    drawingSession.DrawLine(i, border.Top, i, border.Bottom, canvasBrush, strokeWidth, strokeStyle);
                }
            }

            if (this.GridType != PatternGridType.Horizontal)
            {
                for (float i = border.Top; i < border.Bottom; i += this.VerticalStep)
                {
                    drawingSession.DrawLine(border.Left, i, border.Right, i, canvasBrush, strokeWidth, strokeStyle);
                }
            }
        }
Esempio n. 2
0
        public static void Render()
        {
            using (CanvasDrawingSession ds = App.Model.SecondSourceRenderTarget.CreateDrawingSession())
            {
                ds.Clear(Colors.Transparent);

                //左上右下的位置
                float LineL = 0;
                float LineT = 0;
                float LineR = App.Model.Width;
                float LineB = App.Model.Height;


                //线循环
                for (float X = LineL; X < LineR; X += App.Setting.GridsSpace)
                {
                    float xx = LineL + X;
                    ds.DrawLine(xx, LineT, xx, LineB, App.Model.GridsColor);
                }
                for (float Y = LineT; Y < LineB; Y += App.Setting.GridsSpace)
                {
                    float yy = LineT + Y;
                    ds.DrawLine(LineL, yy, LineR, yy, App.Model.GridsColor);
                }
            }

            App.Model.isReRender = true; //重新渲染
            App.Model.Refresh++;         //画布刷新
        }
        private static void DrawFunctionDeclaration(
            CanvasDrawingSession session,
            float offset,
            IndentationType indentationType)
        {
            session.FillRoundedRectangle(IndentationIndicatorsLeftMargin, offset, IndentationIndicatorBlockSize, IndentationIndicatorBlockSize, 9999, 9999, FunctionBackgroundColor);
            session.DrawRoundedRectangle(IndentationIndicatorsLeftMargin, offset, IndentationIndicatorBlockSize, IndentationIndicatorBlockSize, 9999, 9999, OutlineColor);
            session.DrawText("f", IndentationIndicatorsLeftMargin + 4f, offset, TextColor, TextFormat);

            // Vertical guide
            if ((indentationType & IndentationType.FullSize) != 0)
            {
                session.DrawLine(IndentationIndicatorsMiddleMargin, offset + IndentationIndicatorBlockSize, IndentationIndicatorsMiddleMargin, offset + IndentationIndicatorsElementHeight, OutlineColor);
            }
            else
            {
                float middleOffset = offset + (IndentationIndicatorsElementHeight + IndentationIndicatorBlockSize) / 2f;
                session.DrawLine(IndentationIndicatorsMiddleMargin, offset + IndentationIndicatorBlockSize, IndentationIndicatorsMiddleMargin, middleOffset, OutlineColor);
            }

            // Horizontal marker
            if ((indentationType & IndentationType.IsClosing) != 0)
            {
                float
                    horizontalOffset = IndentationIndicatorsMiddleMargin - 0.5f,
                    middleOffset     = offset + (IndentationIndicatorsElementHeight + IndentationIndicatorBlockSize) / 2f + 0.5f;
                session.DrawLine(horizontalOffset, middleOffset, IndentationIndicatorsRightMargin, middleOffset, OutlineColor);
            }
        }
        private static void DrawLine(
            CanvasDrawingSession session,
            float offset,
            IndentationType indentationType)
        {
            // Vertical guide
            if ((indentationType & IndentationType.FullSize) != 0)
            {
                session.DrawLine(IndentationIndicatorsMiddleMargin, offset, IndentationIndicatorsMiddleMargin, offset + IndentationIndicatorsElementHeight, OutlineColor);
            }
            else
            {
                float middleOffset = offset + (IndentationIndicatorsElementHeight + IndentationIndicatorBlockSize) / 2f;
                session.DrawLine(IndentationIndicatorsMiddleMargin, offset, IndentationIndicatorsMiddleMargin, middleOffset, OutlineColor);
            }

            // Horizontal marker
            if ((indentationType & IndentationType.IsClosing) != 0)
            {
                float
                    horizontalOffset = IndentationIndicatorsMiddleMargin - 0.5f,
                    middleOffset     = offset + (IndentationIndicatorsElementHeight + IndentationIndicatorBlockSize) / 2f + 0.5f;
                session.DrawLine(horizontalOffset, middleOffset, IndentationIndicatorsRightMargin, middleOffset, OutlineColor);
            }
        }
Esempio n. 5
0
        public void Draw(CanvasDrawingSession graphics)
        {
            if (_points == null || _points.Count == 0)
            {
                return;
            }

            var brush = new CanvasSolidColorBrush(graphics, drawingColor);

            if (_points.Count == 1)
            {
                graphics.DrawLine((float)_points[0].X, (float)_points[0].Y, (float)_points[0].X, (float)_points[0].Y, brush, drawingSize);
                return;
            }
            var style = new CanvasStrokeStyle()
            {
                DashCap  = CanvasCapStyle.Round,
                StartCap = CanvasCapStyle.Round,
                EndCap   = CanvasCapStyle.Round
            };

            for (int i = 0; i < _points.Count - 1; ++i)
            {
                graphics.DrawLine((float)_points[i].X, (float)_points[i].Y,
                                  (float)_points[i + 1].X, (float)_points[i + 1].Y,
                                  brush, drawingSize, style);
            }
        }
Esempio n. 6
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);
                }
            }
        }
Esempio n. 7
0
        public override void Draw(CanvasDrawingSession session)
        {
            Vector2 leftArrow  = new Vector2(4, 8);
            Vector2 rightArrow = new Vector2(-4, 8);
            double  rad;

            foreach (var node in Nodes)
            {
                foreach (var neighbour in node.Neighbours)
                {
                    var color = (node.Waypoint.IsSelected() && neighbour.Waypoint.IsSelected()) ? Colors.Red : Colors.Yellow;
                    session.DrawLine(node.Waypoint.Position, neighbour.Waypoint.Position, color);
                    Vector2 delta = neighbour.Waypoint.Position - node.Waypoint.Position;

                    rad = Math.Atan(delta.Y / delta.X);
                    double sin = -(delta.Y * 1d) / delta.Length();
                    double cos = -(delta.X * 1d) / delta.Length();

                    Vector2 left  = new Vector2((float)(-leftArrow.X * sin + leftArrow.Y * cos), (float)(leftArrow.X * cos + leftArrow.Y * sin));
                    Vector2 right = new Vector2((float)(-rightArrow.X * sin + rightArrow.Y * cos), (float)(rightArrow.X * cos + rightArrow.Y * sin));

                    session.DrawLine(neighbour.Waypoint.Position, neighbour.Waypoint.Position + left, color);
                    session.DrawLine(neighbour.Waypoint.Position, neighbour.Waypoint.Position + right, color);
                }
                node.Waypoint.Draw(session);
            }
        }
 private static void DrawBoundCore(CanvasDrawingSession drawingSession, Vector2 leftTop, Vector2 rightTop, Vector2 rightBottom, Vector2 leftBottom, Windows.UI.Color accentColor)
 {
     drawingSession.DrawLine(leftTop, rightTop, accentColor);
     drawingSession.DrawLine(rightTop, rightBottom, accentColor);
     drawingSession.DrawLine(rightBottom, leftBottom, accentColor);
     drawingSession.DrawLine(leftBottom, leftTop, accentColor);
 }
Esempio n. 9
0
            private void DrawBackground(CanvasDrawingSession ds, Matrix3x2 transform)
            {
                const int levelUpTime = 60;

                // After levelling up we flash the screen white for a bit
                Color normalColor       = Colors.Blue;
                Color levelUpFlashColor = Colors.White;

                var flashAmount = Math.Min(1, (leveledUpTimer / (float)levelUpTime));

                ds.Clear(InterpolateColors(normalColor, levelUpFlashColor, flashAmount));

                var topLeft     = Vector2.Transform(new Vector2(0, 0), transform);
                var bottomRight = Vector2.Transform(new Vector2(1, 1), transform);

                var middle = (bottomRight.X - topLeft.X) / 2 + topLeft.X;

                // and display some text to let the player know what happened
                if (leveledUpTimer < levelUpTime * 2)
                {
                    ds.DrawText("Level Up!", middle, 0, Colors.White, levelUpFormat);
                }

                // Draw some lines to show where the top / bottom of the play area is.
                var topLine    = topLeft.Y - Letter.TextFormat.FontSize;
                var bottomLine = bottomRight.Y + Letter.TextFormat.FontSize;

                Color lineColor = levelUpFlashColor;

                lineColor.A = 128;

                ds.DrawLine(0, topLine, bottomRight.X, topLine, lineColor, 3);
                ds.DrawLine(0, bottomLine, bottomRight.X, bottomLine, lineColor, 3);
            }
Esempio n. 10
0
        public static void Apply()
        {
            //Undo:撤销
            Undo undo = new Undo();

            undo.TargeInstantiation(App.Model.Index, App.Model.CurrentRenderTarget);
            App.UndoAdd(undo);

            using (CanvasDrawingSession ds = App.Model.CurrentRenderTarget.CreateDrawingSession())
            {
                //左上右下的位置
                float LineL = 0;
                float LineT = 0;
                float LineR = App.Model.Width;
                float LineB = App.Model.Height;


                //线循环
                for (float X = LineL; X < LineR; X += App.Setting.GridsSpace)
                {
                    float xx = LineL + X;
                    ds.DrawLine(xx, LineT, xx, LineB, App.Model.GridsColor);
                }
                for (float Y = LineT; Y < LineB; Y += App.Setting.GridsSpace)
                {
                    float yy = LineT + Y;
                    ds.DrawLine(LineL, yy, LineR, yy, App.Model.GridsColor);
                }
            }
        }
Esempio n. 11
0
        private void DrawTriangleMark(CanvasDrawingSession session, int x, int y, Color color, Color background)
        {
            y = (this.SharedBoardControlState.BoardHeight - 1) - y;

            session.FillRectangle(
                _cellSize * x,
                _cellSize * y,
                _cellSize,
                _cellSize,
                background);

            session.DrawLine(
                new Vector2(_cellSize * (x + 0.2f), _cellSize * (y + 0.8f)),
                new Vector2(_cellSize * (x + 0.5f), _cellSize * (y + 0.2f)),
                color, 3);

            session.DrawLine(
                new Vector2(_cellSize * (x + 0.5f), _cellSize * (y + 0.2f)),
                new Vector2(_cellSize * (x + 0.8f), _cellSize * (y + 0.8f)),
                color, 3);

            session.DrawLine(
                new Vector2(_cellSize * (x + 0.8f), _cellSize * (y + 0.8f)),
                new Vector2(_cellSize * (x + 0.2f), _cellSize * (y + 0.8f)),
                color, 3);
        }
Esempio n. 12
0
        private void DrawLine(CanvasControl sender, CanvasDrawingSession ds)
        {
            var width  = (float)sender.ActualWidth;
            var height = (float)sender.ActualHeight;

            var middle = height / 2;

            int steps = Math.Min((int)(width / 10), 30);

            for (int i = 0; i < steps; ++i)
            {
                var mu = (float)i / steps;
                var a  = (float)(mu * Math.PI * 2);

                var color = GradientColor(mu);

                var x = width * mu;
                var y = (float)(middle + Math.Sin(a) * (middle * 0.3));

                var strokeWidth = (float)(Math.Cos(a) + 1) * 5;

                ds.DrawLine(x, 0, x, y, color, strokeWidth);
                ds.DrawLine(x, height, x, y, color, 10 - strokeWidth);
            }
        }
Esempio n. 13
0
            public void Draw(CanvasDrawingSession ds, float alpha = 1)
            {
                // Create a drop shadow by drawing a black circle with an offset position.
                const float dropShadowOffset = 4;

                ds.FillCircle(Position + new Vector2(dropShadowOffset), Radius, AdjustAlpha(Colors.Black, alpha));

                // Draw a white X.
                const float crossWidth = 3;
                float       crossSize  = Radius * 0.8f;

                Vector2 cross1 = new Vector2(crossSize, crossSize);
                Vector2 cross2 = new Vector2(crossSize, -crossSize);

                ds.DrawLine(Position - cross1, Position + cross1, AdjustAlpha(Colors.White, alpha), crossWidth);
                ds.DrawLine(Position - cross2, Position + cross2, AdjustAlpha(Colors.White, alpha), crossWidth);

                // Fill the circle with its unique color.
                ds.FillCircle(Position, Radius, AdjustAlpha(color, alpha));

                // White border around it.
                ds.DrawCircle(Position, Radius, AdjustAlpha(Colors.White, alpha));

                // Text label.
                ds.DrawText(label, Position, AdjustAlpha(Colors.White, alpha), textFormat);
            }
Esempio n. 14
0
        internal void DrawHandle(CanvasDrawingSession win2d, DrawingPoint befor, bool atlast)
        {
            if (atlast && befor != null)
            {
                if (befor.IsHaveControlPoint)
                {
                    var cp = befor.getControlPoint(false);
                    var pt = befor.getPoint();
                    win2d.DrawLine(pt, cp, Colors.Green);
                    DrawHandle_sub(win2d, cp.X, cp.Y, true, Colors.Green);
                }
            }
            if (_haveControlPoint)
            {
                DrawHandle_sub(win2d, _point.X, _point.Y, true, Colors.Blue);
                if (atlast)
                {
                    var x = _point.X - (_controlPoint0.X - _point.X);
                    var y = _point.Y - (_controlPoint0.Y - _point.Y);

                    win2d.DrawLine(new Vector2(x, y), _controlPoint0, Colors.Green);

                    DrawHandle_sub(win2d, x, y, true, Colors.Green);
                }
                DrawHandle_sub(win2d, _controlPoint0.X, _controlPoint0.Y, true, Colors.Green);
            }
            else
            {
                DrawHandle_sub(win2d, _point.X, _point.Y, false, Colors.Blue);
            }
        }
Esempio n. 15
0
        //CanvasBitmap _brush_image;
        //public async void InitImageBrush()
        //{
        //    if (DrawingColor == Colors.Transparent)
        //    {
        //        if (_brush_image == null)
        //        {
        //            CanvasDevice cd = CanvasDevice.GetSharedDevice();
        //            _brush_image = await CanvasBitmap.LoadAsync(cd, new Uri("ms-appx:///Images/default_back.png"));
        //        }
        //    }
        //}
        public void Draw(CanvasDrawingSession graphics, float scale)
        {
            if (_points != null && _points.Count > 0)
            {
                ICanvasBrush brush;
                //if (DrawingColor == Colors.Transparent)
                //{
                //    if (_brush_image == null)
                //        return;
                //    //brush = new CanvasImageBrush(graphics, _brush_image);
                //}
                //else
                //{
                //    brush = new CanvasSolidColorBrush(graphics, DrawingColor);
                //}
                brush = new CanvasSolidColorBrush(graphics, DrawingColor);

                if (_points.Count == 1)
                {
                    graphics.DrawLine((float)_points[0].X * scale, (float)_points[0].Y * scale, (float)_points[0].X * scale, (float)_points[0].Y * scale, brush, DrawingSize * scale);
                }
                else
                {
                    var style = new CanvasStrokeStyle();
                    style.DashCap  = CanvasCapStyle.Round;
                    style.StartCap = CanvasCapStyle.Round;
                    style.EndCap   = CanvasCapStyle.Round;
                    for (int i = 0; i < _points.Count - 1; ++i)
                    {
                        graphics.DrawLine((float)_points[i].X * scale, (float)_points[i].Y * scale, (float)_points[i + 1].X * scale, (float)_points[i + 1].Y * scale, brush, DrawingSize * scale, style);
                    }
                }
            }
        }
Esempio n. 16
0
        private void AddDraw(CanvasDrawingSession drawingSession)
        {
            ILayer layer = this.CurveLayer;

            Matrix3x2 matrix    = this.ViewModel.CanvasTransformer.GetMatrix();
            Vector2   lastPoint = Vector2.Transform(this._addLastNode.Point, matrix);
            Vector2   endPoint  = Vector2.Transform(this._addEndNode.Point, matrix);


            // Geometry
            ICanvasBrush      canvasBrush = layer.Style.Stroke.GetICanvasBrush(LayerManager.CanvasDevice);
            float             strokeWidth = layer.Style.StrokeWidth;
            CanvasStrokeStyle strokeStyle = layer.Style.StrokeStyle;

            drawingSession.DrawLine(lastPoint, endPoint, canvasBrush, strokeWidth, strokeStyle);


            // Draw
            drawingSession.DrawLine(lastPoint, endPoint, this.ViewModel.AccentColor);
            drawingSession.DrawWireframe(layer, matrix, this.ViewModel.AccentColor);

            drawingSession.DrawNode3(endPoint);
            drawingSession.DrawNodeCollection(layer.Nodes, matrix, this.ViewModel.AccentColor);


            // Snapping
            if (this.IsSnap)
            {
                this.Snap.Draw(drawingSession, matrix);
                this.Snap.DrawNode2(drawingSession, matrix);
            }
        }
Esempio n. 17
0
 public void RenderRays(Vector2 origin, Vector2[] rays)
 {
     foreach (var ray in rays)
     {
         session.DrawLine(origin, ray + origin, Colors.Yellow, 1);
     }
 }
Esempio n. 18
0
 public static void DrawPath(CanvasDrawingSession args, Vector2[] vectors, int[] order, Color color, float stroke)
 {
     for (int i = 0; i < order.Length - 1; i++)
     {
         args.DrawLine(vectors[order[i]], vectors[order[i + 1]], color, stroke);
     }
     args.DrawLine(vectors[order[0]], vectors[order[order.Length - 1]], color, stroke);
 }
Esempio n. 19
0
 public static void DrawPolygon(this CanvasDrawingSession graphics, Vector2[] points, Color color)
 {
     for (int i = 0; i < points.Length - 1; i++)
     {
         graphics.DrawLine(points[i + 0], points[i + 1], color);
     }
     graphics.DrawLine(points[points.Length - 1], points[0], color);
 }
Esempio n. 20
0
        public void DrawCommon(CanvasDrawingSession g)
        {
            if (X1 == -1 || Y1 == -1)
            {
                return;
            }
            if (X1 == X2 && Y1 == Y2)
            {
                return;
            }

            g.DrawLine(X1, Y1, X2, Y2, Pen.Color, Pen.Width);

            //save tansform
            var save = g.Transform;

            var radians = -(float)Radians;//反方向旋转绘图

            if (IsGlyphVisible)
            {
                g.Transform = Matrix3x2.CreateRotation(radians, new Vector2(X1, Y1));
                g.DrawLine(X1, Y1 - Pen.GlyphSize / 2, X1, Y1 + Pen.GlyphSize / 2,
                           Pen.Color, Pen.Width);

                g.Transform = Matrix3x2.CreateRotation(radians, new Vector2(X2, Y2));
                g.DrawLine(X2, Y2 - Pen.GlyphSize / 2, X2, Y2 + Pen.GlyphSize / 2,
                           Pen.Color, Pen.Width);
            }

            var textLayout = CreateTextLayout(Distance.Round3().ToString(), g);

            var bounds = textLayout.LayoutBounds;
            var size   = new Size(bounds.Width + 10, bounds.Height);

            var centerX  = X1 + (X2 - X1 - size.Width) / 2;
            var centerY  = Y1 + (Y2 - Y1 - size.Height) / 2;
            var ySegment = size.Height / 2 + Pen.Width / 2 + 5;
            var offsetX  = Math.Sin(radians) * ySegment;
            var offsetY  = Math.Cos(radians) * ySegment;

            offsetX = Math.Abs(offsetX);
            offsetX = radians < 0 ? offsetX : -offsetX;

            var left = centerX - offsetX;
            var top  = centerY - offsetY;

            centerX = left + size.Width / 2;
            centerY = top + size.Height / 2;

            g.Transform = Matrix3x2.CreateRotation(radians, new Vector2((float)centerX, (float)centerY));
            var rect = new Rect(left, top, size.Width, size.Height);

            g.FillRectangle(rect, Pen.TextBackground);
            g.DrawTextLayout(textLayout, (float)left + 5, (float)top, Pen.TextColor);

            //recover transform
            g.Transform = save;
        }
 private static void DrawDiffMarker(
     CanvasDrawingSession session,
     float offset,
     Color strokeColor,
     Color outlineColor)
 {
     session.DrawLine(GitDiffMarkersMiddleMargin, offset, GitDiffMarkersMiddleMargin, offset + IndentationIndicatorsElementHeight, outlineColor, GitDiffMarkerOutlineWidth);
     session.DrawLine(GitDiffMarkersMiddleMargin, offset, GitDiffMarkersMiddleMargin, offset + IndentationIndicatorsElementHeight, strokeColor, GitDiffMarkerStrokeWidth);
 }
Esempio n. 22
0
 public void drawGrid(double s, CanvasDrawingSession ds)
 {
     for (float x = -7.5f; x <= 7.5f; x += 1)
     {
         var m11 = ds.Transform.M11;
         ds.DrawLine(x, -7.5f, x, 7.5f, Colors.DarkGray, 1 / (float)s);
         ds.DrawLine(-7.5f, x, 7.5f, x, Colors.DarkGray, 1 / (float)s);
     }
 }
Esempio n. 23
0
 void DrawLine(Vector2 p1, Vector2 p2, Color color, float strokeWidth)
 {
     if (!isWireframe)
     {
         currentDrawingSession.DrawLine(p1, p2, color, strokeWidth);
     }
     else
     {
         currentDrawingSession.DrawLine(p1, p2, Colors.Black);
     }
 }
Esempio n. 24
0
        public void Draw(CanvasDrawingSession graphics)
        {
            if (Lines == null)
            {
                return;
            }

            UpdateLines();
            graphics.DrawLine(Lines[0].StartPoint, Lines[0].EndPoint, Colors.White);
            graphics.DrawLine(Lines[1].StartPoint, Lines[1].EndPoint, Colors.White);
            graphics.DrawLine(Lines[2].StartPoint, Lines[2].EndPoint, Colors.White);
        }
Esempio n. 25
0
            void DrawLabel(CanvasDrawingSession ds, string text, float h1InEmSpace, float h2InEmSpace, Side whichSide, int tab)
            {
                //
                // The heights are offset from the baseline.
                //
                float h1        = baselineInWorldSpace + EmSpaceToWorldSpace(h1InEmSpace);
                float h2        = baselineInWorldSpace + EmSpaceToWorldSpace(h2InEmSpace);
                float midHeight = (h1 + h2) / 2;

                float amountPerTab = sizeDim / 7.0f;

                if (whichSide == Side.Left)
                {
                    float margin = tab * amountPerTab;

                    ds.DrawLine(margin, h1, margin, h2, color, strokeWidth);
                    ds.DrawLine(margin, h1, horizontalMidpoint, h1, color, strokeWidth);
                    ds.DrawLine(margin, h2, horizontalMidpoint, h2, color, strokeWidth);

                    ds.DrawLine(margin - amountPerTab, midHeight, margin, midHeight, color, strokeWidth);
                    ds.DrawText(text, margin, midHeight, color, rightJustifiedTextFormat);
                }
                else
                {
                    float rMargin = layoutSize.X - (tab * amountPerTab);
                    ds.DrawLine(rMargin, h1, rMargin, h2, color, strokeWidth);
                    ds.DrawLine(rMargin, h1, horizontalMidpoint, h1, color, strokeWidth);
                    ds.DrawLine(rMargin, h2, horizontalMidpoint, h2, color, strokeWidth);

                    ds.DrawLine(rMargin + amountPerTab, midHeight, rMargin, midHeight, color, strokeWidth);
                    ds.DrawText(text, rMargin, midHeight, color, leftJustifiedTextFormat);
                }

                NextLabel();
            }
Esempio n. 26
0
 public void DrawBoard(CanvasDrawingSession drawingSession)//рисуем доску из клеток
 {
     for (float i = 0; i < iBoardWidth; i++)
     {
         Color drB = i == 0 ? Colors.MediumSeaGreen : colorDrawBrush;
         drawingSession.DrawLine(i + startX + 0.5f, startY + 0.5f, i + startX + 0.5f, iBoardHeight + startY - 0.5f, colorBoard, 0.08f);
     }
     for (float i = 0; i < iBoardHeight; i++)
     {
         Color drB = i == 0 ? Colors.MediumSeaGreen : colorDrawBrush;
         drawingSession.DrawLine(startX + 0.5f, i + startY + 0.5f, iBoardWidth + startX - 0.5f, i + startY + 0.5f, colorBoard, 0.08f);
     }
     //drawingSession.DrawText("Points!", 1, iBoardHeight-2, Colors.DarkGreen);
 }
        private void DrawLine(CanvasControl sender, CanvasDrawingSession ds)
        {
            var width  = (float)sender.ActualWidth;
            var height = (float)sender.ActualHeight;
            var rnd    = Utils.GetRandomBoolean();
            var stroke = this.defaultStroke;

            if (rnd)
            {
                ds.DrawLine(0, 0, width - stroke, height - stroke, ForegroundColor, stroke);
            }
            else
            {
                ds.DrawLine(0, height - stroke, width - stroke, 0, ForegroundColor, stroke);
            }
        }
Esempio n. 28
0
        //public static void FillRectangle(this CanvasDrawingSession session, Rect rect, Paint paint)
        //{

        //}
        public static void DrawLines(this CanvasDrawingSession session, float[] points, int start, int length, Paint paint)
        {
            for (int i = start; i < length - 3; i += 4)
            {
                session.DrawLine(points[i], points[i + 1], points[i + 2], points[i + 3], paint.Color, paint.StrokeWidth);
            }
        }
Esempio n. 29
0
 internal virtual void drawLine(int x1, int y1, int x2, int y2)
 {
     //using (createAlphaLayer())
     //{
     graphics.DrawLine(x1, y1, x2, y2, Color.FromArgb((byte)alpha, c.R, c.G, c.B));
     //}
 }
Esempio n. 30
0
 /// <summary>Draw Line to canvas according coordinates</summary>
 public void DrawLine(float x1, float y1, float x2, float y2)
 {
     if (_strokeColor.A > 0)
     {
         _session.DrawLine(x1, y1, x2, y2, _strokeColor, _strokeWidth, _strokeStyle);
     }
 }
            private void DrawBackground(CanvasDrawingSession ds, Matrix3x2 transform)
            {
                const int levelUpTime = 60;

                // After levelling up we flash the screen white for a bit
                Color normalColor = Colors.Blue;
                Color levelUpFlashColor = Colors.White;

                var flashAmount = Math.Min(1, (leveledUpTimer / (float)levelUpTime));

                ds.Clear(InterpolateColors(normalColor, levelUpFlashColor, flashAmount));

                var topLeft = Vector2.Transform(new Vector2(0, 0), transform);
                var bottomRight = Vector2.Transform(new Vector2(1, 1), transform);

                var middle = (bottomRight.X - topLeft.X) / 2 + topLeft.X;

                // and display some text to let the player know what happened
                if (leveledUpTimer < levelUpTime * 2)
                {
                    ds.DrawText("Level Up!", middle, 0, Colors.White, levelUpFormat);
                }

                // Draw some lines to show where the top / bottom of the play area is.
                var topLine = topLeft.Y - Letter.TextFormat.FontSize;
                var bottomLine = bottomRight.Y + Letter.TextFormat.FontSize;

                Color lineColor = levelUpFlashColor;
                lineColor.A = 128;

                ds.DrawLine(0, topLine, bottomRight.X, topLine, lineColor, 3);
                ds.DrawLine(0, bottomLine, bottomRight.X, bottomLine, lineColor, 3);
            }