diff options
| author | Santiago Pelufo <[email protected]> | 2024-06-16 05:21:54 -0300 |
|---|---|---|
| committer | GitHub <[email protected]> | 2024-06-16 10:21:54 +0200 |
| commit | 640eaca8bf1d2b49a6a730c274b94a96c3a87146 (patch) | |
| tree | 6218934eb759ea278dbd0e62538ca279aabdfd1e /src | |
| parent | 81ff879b047186e1453cb682c70782c0bd338f2a (diff) | |
| download | raylib-640eaca8bf1d2b49a6a730c274b94a96c3a87146.tar.gz raylib-640eaca8bf1d2b49a6a730c274b94a96c3a87146.zip | |
[rshapes] Fix multisegment Bezier splines. (#3744)
* [rshapes] Fix multisegment Bezier splines.
It seems to me that these functions are wrong, if you step the index by 1 you move to a control point instead of the next segment.
* Fix example shapes/shapes_splines_drawing for bezier splines.
* Draw circles to fill gaps between bezier segments.
Diffstat (limited to 'src')
| -rw-r--r-- | src/rshapes.c | 14 |
1 files changed, 10 insertions, 4 deletions
diff --git a/src/rshapes.c b/src/rshapes.c index e9a84834..2c4a57d3 100644 --- a/src/rshapes.c +++ b/src/rshapes.c @@ -1832,8 +1832,11 @@ void DrawSplineCatmullRom(const Vector2 *points, int pointCount, float thick, Co void DrawSplineBezierQuadratic(const Vector2 *points, int pointCount, float thick, Color color) { if (pointCount < 3) return; - - for (int i = 0; i < pointCount - 2; i++) + 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) { DrawSplineSegmentBezierQuadratic(points[i], points[i + 1], points[i + 2], thick, color); } @@ -1843,8 +1846,11 @@ void DrawSplineBezierQuadratic(const Vector2 *points, int pointCount, float thic void DrawSplineBezierCubic(const Vector2 *points, int pointCount, float thick, Color color) { if (pointCount < 4) return; - - for (int i = 0; i < pointCount - 3; i++) + 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) { DrawSplineSegmentBezierCubic(points[i], points[i + 1], points[i + 2], points[i + 3], thick, color); } |
