예제 #1
0
파일: Drawers.cs 프로젝트: medvedya/UShape
        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);
            }
        }