Exemplo n.º 1
0
        /// <summary>
        /// Draw nodes.
        /// </summary>
        /// <param name="drawingSession"> The drawing-session. </param>
        /// <param name="manager"> StopsManager </param>
        public void DrawNodes(CanvasDrawingSession drawingSession, StopsManager manager)
        {
            // Stops
            for (int i = 0; i < manager.Count; i++)
            {
                CanvasGradientStop stop     = manager.Stops[i];
                Vector2            position = new Vector2(this.OffsetToPositionConverter(stop.Position), this.Center);
                if (manager.Index == i)
                {
                    drawingSession.FillCircle(position, 11, Colors.Black);
                }
                drawingSession.DrawNode2(position, stop.Color);
            }

            // Left
            Vector2 left = new Vector2(this.Left, this.Center);

            if (manager.IsLeft)
            {
                drawingSession.FillCircle(left, 11, Colors.Black);
            }
            drawingSession.DrawNode2(left, manager.LeftColor);

            // Right
            Vector2 right = new Vector2(this.Right, this.Center);

            if (manager.IsRight)
            {
                drawingSession.FillCircle(right, 11, Colors.Black);
            }
            drawingSession.DrawNode2(right, manager.RightColor);
        }
 /// <summary>
 /// Draw a ⊙.
 /// </summary>
 /// <param name="drawingSession"> The drawing-session. </param>
 /// <param name="matrix"> The matrix. </param>
 public void DrawNode2(CanvasDrawingSession drawingSession, Matrix3x2 matrix)
 {
     if (base.IsXSnap && base.IsYSnap)
     {
         drawingSession.DrawNode2(Vector2.Transform(base.Source, matrix), Colors.Gold);
     }
     else if (base.IsXSnap)
     {
         drawingSession.DrawNode2(Vector2.Transform(base.Source, matrix), Colors.Red);
     }
     else if (base.IsYSnap)
     {
         drawingSession.DrawNode2(Vector2.Transform(base.Source, matrix), Colors.LimeGreen);
     }
 }
        private static void DrawBoundNodesCore(CanvasDrawingSession drawingSession, Vector2 leftTop, Vector2 rightTop, Vector2 rightBottom, Vector2 leftBottom, Windows.UI.Color accentColor, bool disabledRadian)
        {
            // Line
            CanvasDrawingSessionExtensions.DrawBoundCore(drawingSession, leftTop, rightTop, rightBottom, leftBottom, accentColor);

            // Center
            Vector2 centerLeft   = (leftTop + leftBottom) / 2;
            Vector2 centerTop    = (leftTop + rightTop) / 2;
            Vector2 centerRight  = (rightTop + rightBottom) / 2;
            Vector2 centerBottom = (leftBottom + rightBottom) / 2;

            // Scale2
            drawingSession.DrawNode2(leftTop, accentColor);
            drawingSession.DrawNode2(rightTop, accentColor);
            drawingSession.DrawNode2(rightBottom, accentColor);
            drawingSession.DrawNode2(leftBottom, accentColor);

            if (disabledRadian == false)
            {
                // Outside
                Vector2 outsideLeft   = Math.GetOutsidePointInTransformer(centerLeft, centerRight);
                Vector2 outsideTop    = Math.GetOutsidePointInTransformer(centerTop, centerBottom);
                Vector2 outsideRight  = Math.GetOutsidePointInTransformer(centerRight, centerLeft);
                Vector2 outsideBottom = Math.GetOutsidePointInTransformer(centerBottom, centerTop);

                // Radian
                drawingSession.DrawThickLine(outsideTop, centerTop);
                drawingSession.DrawNode(outsideTop, accentColor);

                // Skew
                // drawingSession.DrawNode2(outsideTop, accentColor);
                // drawingSession.DrawNode2(outsideLeft, accentColor);
                drawingSession.DrawNode2(outsideRight, accentColor);
                drawingSession.DrawNode2(outsideBottom, accentColor);
            }

            // Scale1
            if (Math.OutNodeDistance(centerLeft, centerRight))
            {
                drawingSession.DrawNode2(centerTop, accentColor);
                drawingSession.DrawNode2(centerBottom, accentColor);
            }
            if (Math.OutNodeDistance(centerTop, centerBottom))
            {
                drawingSession.DrawNode2(centerLeft, accentColor);
                drawingSession.DrawNode2(centerRight, accentColor);
            }
        }
        /// <summary>
        /// Draw bezier-curve by NodeCollection.
        /// </summary>
        /// <param name="drawingSession"> The drawing-session. </param>
        /// <param name="nodeCollection"> The NodeCollection. </param>
        /// <param name="matrix"> The matrix. </param>
        /// <param name="accentColor"> The accent color. </param>
        public static void DrawNodeCollection(this CanvasDrawingSession drawingSession, NodeCollection nodeCollection, Matrix3x2 matrix, Windows.UI.Color accentColor)
        {
            foreach (Node node in nodeCollection)
            {
                switch (node.Type)
                {
                case NodeType.BeginFigure:
                {
                    Vector2 vector = Vector2.Transform(node.Point, matrix);

                    if (node.IsChecked == false)
                    {
                        if (node.IsSmooth == false)
                        {
                            drawingSession.DrawNode3(vector, Windows.UI.Colors.Gold);
                        }
                        else
                        {
                            drawingSession.DrawNode(vector, Windows.UI.Colors.Gold);
                        }
                    }
                    else
                    {
                        if (node.IsSmooth == false)
                        {
                            drawingSession.DrawNode4(vector, Windows.UI.Colors.Gold);
                        }
                        else
                        {
                            //Right
                            Vector2 rightControlPoint = Vector2.Transform(node.RightControlPoint, matrix);
                            drawingSession.DrawLine(vector, rightControlPoint, accentColor);
                            drawingSession.DrawNode5(rightControlPoint, Windows.UI.Colors.Gold);

                            //Left
                            Vector2 leftControlPoint = Vector2.Transform(node.LeftControlPoint, matrix);
                            drawingSession.DrawLine(vector, leftControlPoint, accentColor);
                            drawingSession.DrawNode5(leftControlPoint, Windows.UI.Colors.Gold);

                            drawingSession.DrawNode2(vector, Windows.UI.Colors.Gold);
                        }
                    }
                }
                break;

                case NodeType.Node:
                {
                    Vector2 vector = Vector2.Transform(node.Point, matrix);

                    if (node.IsChecked == false)
                    {
                        if (node.IsSmooth == false)
                        {
                            drawingSession.DrawNode3(vector, accentColor);
                        }
                        else
                        {
                            drawingSession.DrawNode(vector, accentColor);
                        }
                    }
                    else
                    {
                        if (node.IsSmooth == false)
                        {
                            drawingSession.DrawNode4(vector, accentColor);
                        }
                        else
                        {
                            //Right
                            Vector2 rightControlPoint = Vector2.Transform(node.RightControlPoint, matrix);
                            drawingSession.DrawLine(vector, rightControlPoint, accentColor);
                            drawingSession.DrawNode5(rightControlPoint, accentColor);

                            //Left
                            Vector2 leftControlPoint = Vector2.Transform(node.LeftControlPoint, matrix);
                            drawingSession.DrawLine(vector, leftControlPoint, accentColor);
                            drawingSession.DrawNode5(leftControlPoint, accentColor);

                            drawingSession.DrawNode2(vector, accentColor);
                        }
                    }
                }
                break;

                case NodeType.EndFigure:
                    break;
                }
            }
        }
Exemplo n.º 5
0
        /// <summary>
        /// Draw stops and lines between all control points.
        /// </summary>
        /// <param name="drawingSession"> The drawing-session. </param>
        /// <param name="matrix"> The matrix. </param>
        /// <param name="accentColor"> The accent color. </param>
        public void Draw(CanvasDrawingSession drawingSession, Matrix3x2 matrix, Color accentColor)
        {
            switch (this.Type)
            {
            case BrushType.None: break;

            case BrushType.Color:
                break;
            }


            Vector2 center = Vector2.Transform(this.Center, matrix);
            Vector2 xPoint = Vector2.Transform(this.XPoint, matrix);
            Vector2 yPoint = Vector2.Transform(this.YPoint, matrix);

            switch (this.Type)
            {
            case BrushType.LinearGradient:
            case BrushType.RadialGradient:
            {
                // Line: white
                drawingSession.DrawLine(center, yPoint, Windows.UI.Colors.White, 4);

                // Circle: white
                drawingSession.FillCircle(center, 10, Windows.UI.Colors.White);
                drawingSession.FillCircle(yPoint, 10, Windows.UI.Colors.White);

                // Line: accent
                drawingSession.DrawLine(center, yPoint, accentColor, 2);

                foreach (CanvasGradientStop stop in this.Stops)
                {
                    Vector2 position = center * (1.0f - stop.Position) + yPoint * stop.Position;

                    // Circle: stop
                    drawingSession.FillCircle(position, 8, accentColor);
                    drawingSession.FillCircle(position, 6, stop.Color);
                }
            }
            break;

            case BrushType.EllipticalGradient:
            {
                // Line: white
                drawingSession.DrawLine(center, xPoint, Colors.White, 4);
                drawingSession.DrawLine(center, yPoint, Colors.White, 4);

                // Circle: white
                drawingSession.FillCircle(center, 10, Colors.White);
                drawingSession.FillCircle(yPoint, 10, Colors.White);

                // Line: accent
                drawingSession.DrawLine(center, xPoint, accentColor, 2);
                drawingSession.DrawLine(center, yPoint, accentColor, 2);

                foreach (CanvasGradientStop stop in this.Stops)
                {
                    Vector2 position = center * (1.0f - stop.Position) + yPoint * stop.Position;

                    // Circle: stop
                    drawingSession.FillCircle(position, 8, accentColor);
                    drawingSession.FillCircle(position, 6, stop.Color);
                }

                // Circle: node
                drawingSession.DrawNode2(xPoint);
            }
            break;

            case BrushType.Image:
            {
                // Line: white
                drawingSession.DrawLine(center, xPoint, Colors.White, 4);
                drawingSession.DrawLine(center, yPoint, Colors.White, 4);

                // Line: accent
                drawingSession.DrawLine(center, xPoint, Colors.LimeGreen, 2);
                drawingSession.DrawLine(center, yPoint, Colors.Red, 2);

                // Circle: node
                drawingSession.DrawNode2(center);
                drawingSession.DrawNode2(xPoint);
                drawingSession.DrawNode2(yPoint);
            }
            break;

            default:
                break;
            }
        }