Exemplo n.º 1
0
        private void InitializePaths()
        {
            var bounds = VisibleBoundsWorldspace;
            var center = bounds.Center;
            //var center = new CCVector2(200, 200);

            Pen lilypadPen = new Pen(CCColor4B.Green, 15)
            {
                Alignment = PenAlignment.Center
            };

            _lilypadPath = BuildLillyPad(center, 150, 0);
            _lilypadStroke = _lilypadPath.Stroke(lilypadPen, PathType.Closed);

            Pen outerFlowerPen = new Pen(CCColor4B.White * 0.75f, 15)
            {
                Alignment = PenAlignment.Outset
            };

            _outerFlowerStroke = BuildFlower(center, 8, 120, 100, (float)(Math.PI / 8)).Stroke(outerFlowerPen, PathType.Closed);

            Pen innerFlowerPen = new Pen(Microsoft.Xna.Framework.Color.MediumPurple * 0.5f, 10)
            {
                Alignment = PenAlignment.Outset
            };

            _innerFlowerStroke = BuildFlower(center, 16, 105, 60, 0).Stroke(innerFlowerPen, PathType.Closed);
        }
        public GraphicsPathTest()
        {
            _thickPen = new Pen(Microsoft.Xna.Framework.Color.Green, 15);

            List<CCVector2> path1 = new List<CCVector2>() {
                new CCVector2(50, 50), new CCVector2(100, 50), new CCVector2(100, 100), new CCVector2(50, 100),
            };

            _gpathf = new GraphicsPath(_thickPen, path1, PathType.Closed);

            path1.Reverse();
            for (int i = 0; i < path1.Count; i++)
                path1[i] = new CCVector2(path1[i].X + 100, path1[i].Y);

            _gpathr = new GraphicsPath(_thickPen, path1, PathType.Closed);

            for (int i = 0; i < path1.Count; i++)
                path1[i] = new CCVector2(path1[i].X, path1[i].Y + 100);

            _gpath2r = new GraphicsPath(_thickPen, path1);

            path1.Reverse();
            for (int i = 0; i < path1.Count; i++)
                path1[i] = new CCVector2(path1[i].X - 100, path1[i].Y);

            _gpath2f = new GraphicsPath(_thickPen, path1);
        }
Exemplo n.º 3
0
        public override void Setup (GraphicsDevice device)
        {
            _thickPen = new Pen(Color.Green, 15);

            List<Vector2> path1 = new List<Vector2>() {
                new Vector2(50, 50), new Vector2(100, 50), new Vector2(100, 100), new Vector2(50, 100),
            };

            _gpathf = new GraphicsPath(_thickPen, path1, PathType.Closed);

            path1.Reverse();
            for (int i = 0; i < path1.Count; i++)
                path1[i] = new Vector2(path1[i].X + 100, path1[i].Y);

            _gpathr = new GraphicsPath(_thickPen, path1, PathType.Closed);

            for (int i = 0; i < path1.Count; i++)
                path1[i] = new Vector2(path1[i].X, path1[i].Y + 100);

            _gpath2r = new GraphicsPath(_thickPen, path1);

            path1.Reverse();
            for (int i = 0; i < path1.Count; i++)
                path1[i] = new Vector2(path1[i].X - 100, path1[i].Y);

            _gpath2f = new GraphicsPath(_thickPen, path1);
        }
Exemplo n.º 4
0
        public override void Setup (GraphicsDevice device)
        {
            Pen penOuterFlower = new Pen(Color.White * 0.75f, 15) { Alignment = PenAlignment.Outset };
            _lilyOuterFlower = CreateFlowerGP(penOuterFlower, _origin, 8, 120, 100, (float)(Math.PI / 8));

            Pen penInnerFlower = new Pen(Color.MediumPurple * 0.5f, 10) { Alignment = PenAlignment.Outset };
            _lilyInnerFlower = CreateFlowerGP(penInnerFlower, _origin, 16, 105, 60, 0);
        }
Exemplo n.º 5
0
        public WaterLilly()
        {
            Pen penOuterFlower = new Pen(Microsoft.Xna.Framework.Color.White * 0.75f, 15) { Alignment = PenAlignment.Outset };
            _lilyOuterFlower = CreateFlowerGP(penOuterFlower, _origin, 8, 120, 100, (float)(Math.PI / 8));

            Pen penInnerFlower = new Pen(Microsoft.Xna.Framework.Color.MediumPurple * 0.5f, 10) { Alignment = PenAlignment.Outset };
            _lilyInnerFlower = CreateFlowerGP(penInnerFlower, _origin, 16, 105, 60, 0);
        }
Exemplo n.º 6
0
        public override void Setup (GraphicsDevice device)
        {
            _gradWidth = new GradientPen(Color.Lime, Color.Blue, 15);
            _gradLength = new PathGradientPen(Color.Lime, Color.Blue, 15);

            PathBuilder pathBuilder = new PathBuilder() { CalculateLengths = true };
            pathBuilder.AddPath(StarPoints(new Vector2(325, 75), 5, 50, 25, 0, false));

            _widthStar = pathBuilder.Stroke(_gradWidth, PathType.Open);
            _lengthStar = pathBuilder.Stroke(_gradLength, Matrix.CreateTranslation(0, 125, 0), PathType.Open);
        }
Exemplo n.º 7
0
        public GradientPens()
        {

            _gradWidth = new GradientPen(Microsoft.Xna.Framework.Color.Lime, Microsoft.Xna.Framework.Color.Blue, 15);
            _gradLength = new PathGradientPen(Microsoft.Xna.Framework.Color.Lime, Microsoft.Xna.Framework.Color.Blue, 15);

            PathBuilder pathBuilder = new PathBuilder() { CalculateLengths = true };
            pathBuilder.AddPath(StarPoints(new CCVector2(325, 75), 5, 50, 25, 0, false));

            _widthStar = pathBuilder.Stroke(_gradWidth, PathType.Open);
            _lengthStar = pathBuilder.Stroke(_gradLength, 
                CCAffineTransform.Translate(CCAffineTransform.Identity, 0, 125, 0), 
                PathType.Open);
        }
Exemplo n.º 8
0
        public override void Setup (GraphicsDevice device)
        {
            _starPoints1 = StarPoints(new Vector2(125, 150), 5, 100, 50, 0, false);
            _starPoints2 = StarPoints(new Vector2(350, 275), 5, 100, 50, 0, false);
            _starPoints3 = StarPoints(new Vector2(125, 400), 5, 100, 50, 0, false);

            _insetPen = new Pen(Color.MediumTurquoise, 10) {
                Alignment = PenAlignment.Inset
            };
            _centerPen = new Pen(Color.MediumTurquoise, 10) {
                Alignment = PenAlignment.Center
            };
            _outsetPen = new Pen(Color.MediumTurquoise, 10) {
                Alignment = PenAlignment.Outset
            };

            _insetPath = new GraphicsPath(_insetPen, _starPoints1, PathType.Closed);
            _centerPath = new GraphicsPath(_centerPen, _starPoints2, PathType.Closed);
            _outsetPath = new GraphicsPath(_outsetPen, _starPoints3, PathType.Closed);
        }
Exemplo n.º 9
0
        public override void Setup (GraphicsDevice device)
        {
            for (int i = 0; i < 20; i++) {
                if (i % 2 == 0)
                    _wavy.Add(new Vector2(50 + i * 10, 100));
                else
                    _wavy.Add(new Vector2(50 + i * 10, 110));
            }

            _thickBlue = new Pen(Color.Blue, 15);
            _thickRed = new Pen(Color.Red, 15) {
                EndCap = LineCap.Square,
                StartCap = LineCap.Square,
            };
            _thickMagenta = new Pen(Color.Magenta, 15);
            _thickBlack = new Pen(Color.Black, 15);
            _thickDarkGray = new Pen(Color.DarkGray, 15);
            _thickGreen = new Pen(Color.Green, 15);

            _wavyPath = new GraphicsPath(_thickRed, _wavy);
        }
Exemplo n.º 10
0
        private void InitializePaths ()
        {
            Vector2 center = new Vector2(200, 200);

            Pen lilypadPen = new Pen(Color.Green, 15) {
                Alignment = PenAlignment.Center
            };

            _lilypadPath = BuildLillyPad(center, 150, 0);
            _lilypadStroke = _lilypadPath.Stroke(lilypadPen, PathType.Closed);

            Pen outerFlowerPen = new Pen(Color.White * 0.75f, 15) {
                Alignment = PenAlignment.Outset
            };

            _outerFlowerStroke = BuildFlower(center, 8, 120, 100, (float)(Math.PI / 8)).Stroke(outerFlowerPen, PathType.Closed);

            Pen innerFlowerPen = new Pen(Color.MediumPurple * 0.5f, 10) {
                Alignment = PenAlignment.Outset
            };

            _innerFlowerStroke = BuildFlower(center, 16, 105, 60, 0).Stroke(innerFlowerPen, PathType.Closed);
        }
Exemplo n.º 11
0
        public OutlineShapes()
        {

            for (int i = 0; i < 20; i++)
            {
                if (i % 2 == 0)
                    _wavy.Add(new CCVector2(50 + i * 10, 100));
                else
                    _wavy.Add(new CCVector2(50 + i * 10, 110));
            }

            _thickBlue = new Pen(Microsoft.Xna.Framework.Color.Blue, 15);
            _thickRed = new Pen(Microsoft.Xna.Framework.Color.Red, 15)
            {
                EndCap = LineCap.Square,
                StartCap = LineCap.Square,
            };
            _thickMagenta = new Pen(Microsoft.Xna.Framework.Color.Magenta, 15);
            _thickBlack = new Pen(Microsoft.Xna.Framework.Color.Black, 15);
            _thickDarkGray = new Pen(Microsoft.Xna.Framework.Color.DarkGray, 15);
            _thickGreen = new Pen(Microsoft.Xna.Framework.Color.Green, 15);

            _wavyPath = new GraphicsPath(_thickRed, _wavy);
        }
        public PenAlignmentTest()
        {

            _starPoints1 = StarPoints(new CCVector2(125, 150), 5, 100, 50, 0, false);
            _starPoints2 = StarPoints(new CCVector2(350, 275), 5, 100, 50, 0, false);
            _starPoints3 = StarPoints(new CCVector2(125, 400), 5, 100, 50, 0, false);

            _insetPen = new Pen(Microsoft.Xna.Framework.Color.MediumTurquoise, 10)
            {
                Alignment = PenAlignment.Inset
            };
            _centerPen = new Pen(Microsoft.Xna.Framework.Color.MediumTurquoise, 10)
            {
                Alignment = PenAlignment.Center
            };
            _outsetPen = new Pen(Microsoft.Xna.Framework.Color.MediumTurquoise, 10)
            {
                Alignment = PenAlignment.Outset
            };

            _insetPath = new GraphicsPath(_insetPen, _starPoints1, PathType.Closed);
            _centerPath = new GraphicsPath(_centerPen, _starPoints2, PathType.Closed);
            _outsetPath = new GraphicsPath(_outsetPen, _starPoints3, PathType.Closed);
        }
Exemplo n.º 13
0
        /*public void DrawPath (GraphicsPath path, ref Matrix vertexTransform)
        {
            if (!_inDraw)
                throw new InvalidOperationException();

            DrawPathInner(path, ref vertexTransform, true);

            if (_sortMode == DrawSortMode.Immediate)
                FlushBuffer();
        }*/

        private void DrawPathInner (GraphicsPath path, ref Matrix vertexTransform, bool applyVertexTransform)
        {
            RequestBufferSpace(path.VertexCount, path.IndexCount);

            AddInfo(PrimitiveType.TriangleList, path.VertexCount, path.IndexCount, path.Pen.Brush);

            if (path.VertexTextureData != null) {
                for (int i = 0; i < path.VertexCount; i++) {
                    _vertexBuffer[_vertexBufferIndex + i] = new VertexPositionColorTexture(
                        new Vector3(path.VertexPositionData[i], 0),
                        path.VertexColorData[i],
                        path.VertexTextureData[i]);
                }
            }
            else {
                for (int i = 0; i < path.VertexCount; i++) {
                    _vertexBuffer[_vertexBufferIndex + i] = new VertexPositionColorTexture(
                        new Vector3(path.VertexPositionData[i], 0),
                        path.VertexColorData[i],
                        Vector2.Zero);
                }
            }

            for (int i = 0; i < path.IndexCount; i++) {
                _indexBuffer[_indexBufferIndex + i] = (short)(path.IndexData[i] + _vertexBufferIndex);
            }

            _vertexBufferIndex += path.VertexCount;
            _indexBufferIndex += path.IndexCount;

            foreach (GraphicsPath outlinePath in path.OutlinePaths)
                DrawPathInner(outlinePath, ref vertexTransform, applyVertexTransform);
        }
Exemplo n.º 14
0
        /// <summary>
        /// Adds a precomputed path to the batch of figures to be rendered.
        /// </summary>
        /// <param name="path">A path that has already been stroked with a <see cref="Pen"/>.</param>
        /// <exception cref="InvalidOperationException"><c>DrawPath</c> was called, but <see cref="Begin()"/> has not yet been called.</exception>
        public void DrawPath (GraphicsPath path)
        {
            if (!_inDraw)
                throw new InvalidOperationException();

            DrawPathInner(path, ref _identityMatrix, false);

            if (_sortMode == DrawSortMode.Immediate)
                FlushBuffer();
        }
Exemplo n.º 15
0
        public override void Setup (GraphicsDevice device)
        {
            _thickpen = new Pen(Color.Green, 15);

            _outlinePen = new Pen(Color.GreenYellow, 5);
            _outlinePenInset = new Pen(Color.GreenYellow, 5) { Alignment = PenAlignment.Inset };
            _outlinePenOutset = new Pen(Color.GreenYellow, 5) { Alignment = PenAlignment.Outset };

            List<Vector2> path1 = new List<Vector2>() {
                new Vector2(50, 50), new Vector2(100, 50), new Vector2(100, 100), new Vector2(50, 100),
            };

            _gpathf = new GraphicsPath(_thickpen, _outlinePen, path1, PathType.Closed);

            path1.Reverse();
            ShiftPath(path1, 100, 0);
            _gpathr = new GraphicsPath(_thickpen, _outlinePen, path1, PathType.Closed);

            ShiftPath(path1, 100, 0);
            _gpathfi = new GraphicsPath(_thickpen, _outlinePenInset, path1, PathType.Closed);

            path1.Reverse();
            ShiftPath(path1, 100, 0);
            _gpathri = new GraphicsPath(_thickpen, _outlinePenInset, path1, PathType.Closed);

            ShiftPath(path1, 100, 0);
            _gpathfo = new GraphicsPath(_thickpen, _outlinePenOutset, path1, PathType.Closed);

            path1.Reverse();
            ShiftPath(path1, 100, 0);
            _gpathro = new GraphicsPath(_thickpen, _outlinePenOutset, path1, PathType.Closed);

            ShiftPath(path1, -500, 100);
            _gpath2r = new GraphicsPath(_thickpen, _outlinePen, path1);

            path1.Reverse();
            ShiftPath(path1, 100, 0);
            _gpath2f = new GraphicsPath(_thickpen, _outlinePen, path1);

            ShiftPath(path1, 100, 0);
            _gpath2fi = new GraphicsPath(_thickpen, _outlinePenInset, path1);

            path1.Reverse();
            ShiftPath(path1, 100, 0);
            _gpath2ri = new GraphicsPath(_thickpen, _outlinePenInset, path1);

            ShiftPath(path1, 100, 0);
            _gpath2fo = new GraphicsPath(_thickpen, _outlinePenOutset, path1);

            path1.Reverse();
            ShiftPath(path1, 100, 0);
            _gpath2ro = new GraphicsPath(_thickpen, _outlinePenOutset, path1);

            ShiftPath(path1, -500, 100);
            _gpath3f = new GraphicsPath(_thickpen, _outlinePen, path1, PathType.Closed, StrokeType.Outline);

            path1.Reverse();
            ShiftPath(path1, 100, 0);
            _gpath3r = new GraphicsPath(_thickpen, _outlinePen, path1, PathType.Closed, StrokeType.Outline);

            ShiftPath(path1, 100, 0);
            _gpath4f = new GraphicsPath(_thickpen, _outlinePen, path1, StrokeType.Outline);

            path1.Reverse();
            ShiftPath(path1, 100, 0);
            _gpath4r = new GraphicsPath(_thickpen, _outlinePen, path1, StrokeType.Outline);
        }
        public GraphicsPathOutline()
        {

            _thickpen = new Pen(Microsoft.Xna.Framework.Color.Green, 15);

            _outlinePen = new Pen(Microsoft.Xna.Framework.Color.GreenYellow, 5);
            _outlinePenInset = new Pen(Microsoft.Xna.Framework.Color.GreenYellow, 5) { Alignment = PenAlignment.Inset };
            _outlinePenOutset = new Pen(Microsoft.Xna.Framework.Color.GreenYellow, 5) { Alignment = PenAlignment.Outset };

            List<CCVector2> path1 = new List<CCVector2>() {
                new CCVector2(50, 50), new CCVector2(100, 50), new CCVector2(100, 100), new CCVector2(50, 100),
            };

            _gpathf = new GraphicsPath(_thickpen, _outlinePen, path1, PathType.Closed);

            path1.Reverse();
            ShiftPath(path1, 100, 0);
            _gpathr = new GraphicsPath(_thickpen, _outlinePen, path1, PathType.Closed);

            ShiftPath(path1, 100, 0);
            _gpathfi = new GraphicsPath(_thickpen, _outlinePenInset, path1, PathType.Closed);

            path1.Reverse();
            ShiftPath(path1, 100, 0);
            _gpathri = new GraphicsPath(_thickpen, _outlinePenInset, path1, PathType.Closed);

            ShiftPath(path1, 100, 0);
            _gpathfo = new GraphicsPath(_thickpen, _outlinePenOutset, path1, PathType.Closed);

            path1.Reverse();
            ShiftPath(path1, 100, 0);
            _gpathro = new GraphicsPath(_thickpen, _outlinePenOutset, path1, PathType.Closed);

            ShiftPath(path1, -500, 100);
            _gpath2r = new GraphicsPath(_thickpen, _outlinePen, path1);

            path1.Reverse();
            ShiftPath(path1, 100, 0);
            _gpath2f = new GraphicsPath(_thickpen, _outlinePen, path1);

            ShiftPath(path1, 100, 0);
            _gpath2fi = new GraphicsPath(_thickpen, _outlinePenInset, path1);

            path1.Reverse();
            ShiftPath(path1, 100, 0);
            _gpath2ri = new GraphicsPath(_thickpen, _outlinePenInset, path1);

            ShiftPath(path1, 100, 0);
            _gpath2fo = new GraphicsPath(_thickpen, _outlinePenOutset, path1);

            path1.Reverse();
            ShiftPath(path1, 100, 0);
            _gpath2ro = new GraphicsPath(_thickpen, _outlinePenOutset, path1);

            ShiftPath(path1, -500, 100);
            _gpath3f = new GraphicsPath(_thickpen, _outlinePen, path1, PathType.Closed, StrokeType.Outline);

            path1.Reverse();
            ShiftPath(path1, 100, 0);
            _gpath3r = new GraphicsPath(_thickpen, _outlinePen, path1, PathType.Closed, StrokeType.Outline);

            ShiftPath(path1, 100, 0);
            _gpath4f = new GraphicsPath(_thickpen, _outlinePen, path1, StrokeType.Outline);

            path1.Reverse();
            ShiftPath(path1, 100, 0);
            _gpath4r = new GraphicsPath(_thickpen, _outlinePen, path1, StrokeType.Outline);
        }