Пример #1
0
        /// <summary>
        /// Creates a line with points evenly spaced.
        /// </summary>
        private Line2 CreateFromParametricBezier(ParametricBezier2 bezier, float spacing)
        {
            float length = bezier.Length(64);
            int   count  = (int)Mathf.Max(2, (length / spacing));

            Line2 line = new Line2();

            line.Control.AddRange(bezier.Control);

            for (int i = 0; i < count; i++)
            {
                float s = i / (count - 1.0f) * length;
                float t = bezier.Parametrize(s, length);

                line.Positions.Add(bezier.Position(t));
            }

            return(line);
        }
Пример #2
0
        protected override void OnCurveComplete(List <Vector2> control)
        {
            Line2 line;

            if (Parametric)
            {
                ParametricBezier2 curve = new ParametricBezier2(control);
                line = CreateFromParametricBezier(curve, 0.1f);
            }
            else
            {
                Bezier2 curve = new Bezier2(control);
                line = CreateFromBezier(curve, 0.1f);
            }

            lines.Add(line);

            ResetInput();
        }