Ejemplo n.º 1
0
        public static void DrawCubicBezier(this PolyShape polyShape, CubicBezier bezier, int segmentCount)
        {
            float segmentSize = 1f / segmentCount;

            for (int i = 0; i < segmentCount; i++)
            {
                var   t   = i * segmentSize;
                var   dir = bezier.CalculateCubicBezierDerivative(t).normalized;
                Point p   = new Point()
                {
                    position = bezier.CalculateCubicBezierPoint(t),
                    normal   = new Vector2(dir.y, -dir.x)
                };
                polyShape.TryAddPoint(p);
            }
        }