Skip to content

Commit 8f741d8

Browse files
Minor fix in DrawLineBezier* (#3006)
When `i` starts with `0`, `t` is also `0`, which results in `previous == startPos == current`, this segment is not only redundant, but it also causes division-by-zero since `sqrtf(dx*dx + dy*dy)` is zero.
1 parent e57ee9c commit 8f741d8

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

src/rshapes.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -241,7 +241,7 @@ void DrawLineBezierQuad(Vector2 startPos, Vector2 endPos, Vector2 controlPos, fl
241241

242242
Vector2 points[2*BEZIER_LINE_DIVISIONS + 2] = { 0 };
243243

244-
for (int i = 0; i <= BEZIER_LINE_DIVISIONS; i++)
244+
for (int i = 1; i <= BEZIER_LINE_DIVISIONS; i++)
245245
{
246246
t = step*i;
247247
float a = powf(1 - t, 2);
@@ -286,7 +286,7 @@ void DrawLineBezierCubic(Vector2 startPos, Vector2 endPos, Vector2 startControlP
286286

287287
Vector2 points[2*BEZIER_LINE_DIVISIONS + 2] = { 0 };
288288

289-
for (int i = 0; i <= BEZIER_LINE_DIVISIONS; i++)
289+
for (int i = 1; i <= BEZIER_LINE_DIVISIONS; i++)
290290
{
291291
t = step*i;
292292
float a = powf(1 - t, 3);

0 commit comments

Comments
 (0)