diff options
| author | Ray <[email protected]> | 2024-06-16 10:41:47 +0200 |
|---|---|---|
| committer | Ray <[email protected]> | 2024-06-16 10:41:47 +0200 |
| commit | 715633e0de101cb1a2b7b322455e4eab047f5f15 (patch) | |
| tree | 8f1f25c80d54d64583bc77b08e4d013900ef7ab2 /src | |
| parent | 4119b6dd660544bff9f6431fa04f162eacb612a3 (diff) | |
| download | raylib-715633e0de101cb1a2b7b322455e4eab047f5f15.tar.gz raylib-715633e0de101cb1a2b7b322455e4eab047f5f15.zip | |
REVIEWED: Spline cubic bezier example
Diffstat (limited to 'src')
| -rw-r--r-- | src/rshapes.c | 30 |
1 files changed, 14 insertions, 16 deletions
diff --git a/src/rshapes.c b/src/rshapes.c index 2c4a57d3..95c54770 100644 --- a/src/rshapes.c +++ b/src/rshapes.c @@ -1759,7 +1759,8 @@ void DrawSplineBasis(const Vector2 *points, int pointCount, float thick, Color c DrawTriangleStrip(vertices, 2*SPLINE_SEGMENT_DIVISIONS + 2, color); } - DrawCircleV(currentPoint, thick/2.0f, color); // Draw end line circle-cap + // Cap circle drawing at the end of every segment + DrawCircleV(currentPoint, thick/2.0f, color); } // Draw spline: Catmull-Rom, minimum 4 points @@ -1825,34 +1826,31 @@ void DrawSplineCatmullRom(const Vector2 *points, int pointCount, float thick, Co DrawTriangleStrip(vertices, 2*SPLINE_SEGMENT_DIVISIONS + 2, color); } - DrawCircleV(currentPoint, thick/2.0f, color); // Draw end line circle-cap + // Cap circle drawing at the end of every segment + DrawCircleV(currentPoint, thick/2.0f, color); } // Draw spline: Quadratic Bezier, minimum 3 points (1 control point): [p1, c2, p3, c4...] void DrawSplineBezierQuadratic(const Vector2 *points, int pointCount, float thick, Color color) { - if (pointCount < 3) return; - for (int i = 2; i < pointCount - 2; i += 2) - { - DrawCircleV(points[i], thick/2.0f, color); - } - for (int i = 0; i < pointCount - 2; i += 2) + if (pointCount >= 3) { - DrawSplineSegmentBezierQuadratic(points[i], points[i + 1], points[i + 2], thick, color); + for (int i = 0; i < pointCount - 2; i += 2) DrawSplineSegmentBezierQuadratic(points[i], points[i + 1], points[i + 2], thick, color); + + // Cap circle drawing at the end of every segment + //for (int i = 2; i < pointCount - 2; i += 2) DrawCircleV(points[i], thick/2.0f, color); } } // Draw spline: Cubic Bezier, minimum 4 points (2 control points): [p1, c2, c3, p4, c5, c6...] void DrawSplineBezierCubic(const Vector2 *points, int pointCount, float thick, Color color) { - if (pointCount < 4) return; - for (int i = 3; i < pointCount - 3; i += 3) - { - DrawCircleV(points[i], thick/2.0f, color); - } - for (int i = 0; i < pointCount - 3; i += 3) + if (pointCount >= 4) { - DrawSplineSegmentBezierCubic(points[i], points[i + 1], points[i + 2], points[i + 3], thick, color); + for (int i = 0; i < pointCount - 3; i += 3) DrawSplineSegmentBezierCubic(points[i], points[i + 1], points[i + 2], points[i + 3], thick, color); + + // Cap circle drawing at the end of every segment + //for (int i = 3; i < pointCount - 3; i += 3) DrawCircleV(points[i], thick/2.0f, color); } } |
