Пример #1
0
        public void DrawWithSpriteBatch(SpriteBatch _spriteBatch, GameTime gameTime)
        {
            bool flip          = false;
            int  lineThickness = 2;

            // result point rows.
            for (int y = 0; y < _numOfCurvatureSegmentPoints - 1; y++)
            {
                for (int x = 0; x < _numOfCurvatureSegmentPoints - 1; x++)
                {
                    var index  = _numOfCurvatureSegmentPoints * y + x;
                    var index2 = _numOfCurvatureSegmentPoints * y + x + 1;
                    var index3 = _numOfCurvatureSegmentPoints * y + x + _numOfCurvatureSegmentPoints;
                    var col    = Color.Black;
                    if (flip)
                    {
                        col = Color.Green;
                    }
                    DrawHelpers.DrawBasicLine(ToVector2(curveLinePoints[index]), ToVector2(curveLinePoints[index2]), lineThickness, col);
                    DrawHelpers.DrawBasicLine(ToVector2(curveLinePoints[index]), ToVector2(curveLinePoints[index3]), lineThickness, col);
                    flip = !flip;
                }
            }

            for (int y = 0; y < cpHeight; y++)
            {
                for (int x = 0; x < cpWidth; x++)
                {
                    int index = y * cpWidth + x;
                    DrawHelpers.DrawBasicPoint(new Vector2(cps[index].X, cps[index].Y), 4, Color.Red);
                }
            }
        }
Пример #2
0
        public void DrawWithSpriteBatch(SpriteBatch _spriteBatch, GameTime gameTime)
        {
            bool flip = false;

            for (int i = 0; i < curveLinePoints.Length - 1; i++)
            {
                if (flip)
                {
                    DrawHelpers.DrawBasicLine(ToVector2(curveLinePoints[i]), ToVector2(curveLinePoints[i + 1]), 1, Color.Green);
                }
                else
                {
                    DrawHelpers.DrawBasicLine(ToVector2(curveLinePoints[i]), ToVector2(curveLinePoints[i + 1]), 1, Color.Black);
                }

                if (i < 3)
                {
                    DrawHelpers.DrawBasicLine(ToVector2(curveLinePoints[i]), ToVector2(curveLinePoints[i + 1]), 1, Color.Yellow);
                }

                flip = !flip;
            }

            for (int i = 0; i < artificialCpLine.Count - 1; i += 2)
            {
                DrawHelpers.DrawBasicLine(new Vector2(artificialCpLine[i].X, artificialCpLine[i].Y), new Vector2(artificialCpLine[i + 1].X, artificialCpLine[i + 1].Y), 1, Color.Purple);
            }

            for (int i = 0; i < cp.Length; i++)
            {
                DrawHelpers.DrawBasicPoint(new Vector2(cp[i].X, cp[i].Y), Color.Red);
            }
        }
Пример #3
0
        //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
        //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++


        public void DrawWithSpriteBatch(SpriteBatch _spriteBatch, GameTime gameTime)
        {
            _spriteBatch.Begin();

            bool flip = false;

            for (int i = 0; i < curveLinePoints.Length - 1; i++)
            {
                if (flip)
                {
                    DrawHelpers.DrawBasicLine(ToVector2(curveLinePoints[i]), ToVector2(curveLinePoints[i + 1]), 1, Color.Green);
                }
                else
                {
                    DrawHelpers.DrawBasicLine(ToVector2(curveLinePoints[i]), ToVector2(curveLinePoints[i + 1]), 1, Color.Black);
                }
                flip = !flip;
            }

            for (int i = 0; i < cp.Length; i++)
            {
                DrawHelpers.DrawBasicPoint(new Vector2(cp[i].X, cp[i].Y), Color.Red);
            }

            //_spriteBatch.DrawString(_font, " time " + t, new Vector2(10, 10), Color.Black);

            _spriteBatch.End();
        }
Пример #4
0
        public void DrawWithSpriteBatch(SpriteBatch _spriteBatch, GameTime gameTime)
        {
            bool flip          = false;
            int  lineThickness = 2;

            //if (_showTangents)
            //{
            //    for (int i = 0; i < artificialCpLine.Count - 1; i += 2)
            //    {
            //        DrawHelpers.DrawBasicLine(new Vector2(artificialCpLine[i].X, artificialCpLine[i].Y), new Vector2(artificialCpLine[i + 1].X, artificialCpLine[i + 1].Y), 1, Color.Purple);
            //    }

            //    for (int i = 0; i < artificialCpLine.Count - 1; i += 2)
            //    {
            //        DrawHelpers.DrawBasicLine(new Vector2(artificialTangentLine[i].X, artificialTangentLine[i].Y), new Vector2(artificialTangentLine[i + 1].X, artificialTangentLine[i + 1].Y), 1, Color.Pink);
            //    }
            //}

            for (int i = 0; i < cps.Length; i++)
            {
                DrawHelpers.DrawBasicPoint(new Vector2(cps[i].position.X, cps[i].position.Y), 4, Color.Red);
            }

            for (int i = 0; i < curveLinePoints.Length - 1; i++)
            {
                if (flip)
                {
                    DrawHelpers.DrawBasicLine(ToVector2(curveLinePoints[i]), ToVector2(curveLinePoints[i + 1]), lineThickness, Color.Green);
                }
                else
                {
                    DrawHelpers.DrawBasicLine(ToVector2(curveLinePoints[i]), ToVector2(curveLinePoints[i + 1]), lineThickness, Color.Black);
                }

                if (i < 1)
                {
                    DrawHelpers.DrawBasicLine(ToVector2(curveLinePoints[i]), ToVector2(curveLinePoints[i + 1]), lineThickness, Color.Yellow);
                }

                flip = !flip;
            }
        }
Пример #5
0
        public void DrawBsplineWithSpriteBatch(GameTime gameTime)
        {
            _spriteBatch.Begin();

            for (int i = 0; i < bezierCurveLines.Length - 1; i++)
            {
                DrawHelpers.DrawBasicLine(ToVector2(bezierCurveLines[i]), ToVector2(bezierCurveLines[i + 1]), 1, Color.Green);
            }

            DrawHelpers.DrawBasicLine(ToVector2(bspline.solved[0]), ToVector2(bspline.solved[1]), 1, Color.Blue);
            DrawHelpers.DrawBasicLine(ToVector2(bspline.solved[1]), ToVector2(bspline.solved[2]), 1, Color.Blue);
            DrawHelpers.DrawBasicLine(ToVector2(bspline.solved[2]), ToVector2(bspline.solved[3]), 1, Color.Blue);

            DrawHelpers.DrawBasicLine(ToVector2(bspline.solved[4]), ToVector2(bspline.solved[5]), 1, Color.Yellow);
            DrawHelpers.DrawBasicLine(ToVector2(bspline.solved[5]), ToVector2(bspline.solved[6]), 1, Color.Yellow);

            DrawHelpers.DrawBasicLine(ToVector2(bspline.solved[7]), ToVector2(bspline.solved[8]), 1, Color.Orange);

            DrawHelpers.DrawBasicPoint(ToVector2(bspline.solved[9]), Color.Red);

            _spriteBatch.DrawString(_font, msg, new Vector2(10, 20), Color.White);

            _spriteBatch.End();
        }