Exemplo n.º 1
0
        public override void Setup(GraphicsDevice device)
        {
            _gradWidthInner = new GradientPen(Color.Lime, Color.Cyan, 15)
            {
                Alignment = PenAlignment.Inset, StartCap = LineCap.Square, EndCap = LineCap.Square
            };
            _gradWidthCenter = new GradientPen(Color.Lime, Color.Cyan, 15)
            {
                StartCap = LineCap.Square, EndCap = LineCap.Square
            };
            _gradWidthOuter = new GradientPen(Color.Lime, Color.Cyan, 15)
            {
                Alignment = PenAlignment.Outset, StartCap = LineCap.Square, EndCap = LineCap.Square
            };

            Pen[] pens = new Pen[] { _gradWidthInner, _gradWidthCenter, _gradWidthOuter };
            for (int i = 0; i < _gPaths.Length; i++)
            {
                PathBuilder builder = new PathBuilder();
                foreach (Vector2 v in _baseCoords)
                {
                    builder.AddPoint(v + Offset(i));
                }
                _gPaths[i] = builder.Stroke(pens[i]);
            }
        }
Exemplo n.º 2
0
        public GradientPensAlignment()
        {
            _gradWidthInner = new GradientPen(Microsoft.Xna.Framework.Color.Lime, Microsoft.Xna.Framework.Color.Cyan, 15)
            {
                Alignment = PenAlignment.Inset, StartCap = LineCap.Square, EndCap = LineCap.Square
            };
            _gradWidthCenter = new GradientPen(Microsoft.Xna.Framework.Color.Lime, Microsoft.Xna.Framework.Color.Cyan, 15)
            {
                StartCap = LineCap.Square, EndCap = LineCap.Square
            };
            _gradWidthOuter = new GradientPen(Microsoft.Xna.Framework.Color.Lime, Microsoft.Xna.Framework.Color.Cyan, 15)
            {
                Alignment = PenAlignment.Outset, StartCap = LineCap.Square, EndCap = LineCap.Square
            };

            Pen[] pens = new Pen[] { _gradWidthInner, _gradWidthCenter, _gradWidthOuter };
            for (int i = 0; i < _gPaths.Length; i++)
            {
                PathBuilder builder = new PathBuilder();
                foreach (CCVector2 v in _baseCoords)
                {
                    builder.AddPoint(v + Offset(i));
                }
                _gPaths[i] = builder.Stroke(pens[i]);
            }
        }
Exemplo n.º 3
0
        /// <summary>
        /// takes in a parsed path and returns a list of points that can be used to draw the path
        /// </summary>
        /// <returns>The drawing points.</returns>
        /// <param name="segments">Segments.</param>
        public Vector2[] getDrawingPoints(List <SvgPathSegment> segments, float flatness = 3)
        {
            var path = new PathBuilder();

            for (var j = 0; j < segments.Count; j++)
            {
                var segment = segments[j];
                if (segment is SvgMoveToSegment)
                {
                    path.AddPoint(segment.start);
                }
                else if (segment is SvgCubicCurveSegment)
                {
                    var cubicSegment = segment as SvgCubicCurveSegment;

                    path.AddBezier(segment.start, cubicSegment.firstCtrlPoint, cubicSegment.secondCtrlPoint, segment.end);
                }
                else if (segment is SvgClosePathSegment)
                {
                    if (path.Count > 0 && !path.Buffer[0].Equals(path.Buffer[path.Count - 1]))
                    {
                        path.ClosePath();
                    }
                }
                else if (segment is SvgLineSegment)
                {
                    path.AddPoint(segment.start);
                    path.AddPoint(segment.end);
                }
                else if (segment is SvgQuadraticCurveSegment)
                {
                    var quadSegment = segment as SvgQuadraticCurveSegment;

                    var segmentArray = new Vector2[] { segment.end, quadSegment.secondCtrlPoint, quadSegment.firstCtrlPoint, segment.end };

                    path.AddBeziers(segmentArray, BezierType.Quadratic);
                }
                else
                {
                    Debug.warn("unknown type in getDrawingPoints");
                }
            }

            return(path.Buffer);
        }
Exemplo n.º 4
0
        private static PathBuilder BuildLillyPad(CCVector2 center, int radius, float rotation)
        {
            float segment = (float)(Math.PI * 2 / 32);

            PathBuilder builder = new PathBuilder();

            builder.AddPoint(center);
            builder.AddLine(radius, segment * 25 + rotation);
            builder.AddArcByAngle(center, segment * 30, radius / 2);

            return(builder);
        }
Exemplo n.º 5
0
        private static PathBuilder BuildFlower(CCVector2 center, int petalCount, float petalLength, float petalWidth, float rotation)
        {
            List <CCVector2> points = StarPoints(center, petalCount / 2, petalLength, petalLength, rotation, false);

            PathBuilder builder = new PathBuilder();

            builder.AddPoint(center);

            foreach (var point in points)
            {
                builder.AddArcByPoint(point, petalWidth / 2);
                builder.AddArcByPoint(center, petalWidth / 2);
            }

            return(builder);
        }
Exemplo n.º 6
0
        private GraphicsPath CreateFlowerGP(Pen pen, CCVector2 center, int petalCount, float petalLength, float petalWidth, float rotation)
        {
            List <CCVector2> points = StarPoints(center, petalCount / 2, petalLength, petalLength, rotation, false);

            PathBuilder builder = new PathBuilder();

            builder.AddPoint(center);

            foreach (CCVector2 point in points)
            {
                builder.AddArcByPoint(point, petalWidth / 2);
                builder.AddArcByPoint(center, petalWidth / 2);
            }

            return(builder.Stroke(pen, PathType.Closed));
        }