### Bookstore

 Computer Math and Games in Pascal (preview) Lazarus Handbook

### Author Topic: [LAMW] Bug: jCanvasES2.DrawCircle  (Read 374 times)

#### Handoko

• Hero Member
• Posts: 3434
• My goal: build my own game engine using Lazarus
##### [LAMW] Bug: jCanvasES2.DrawCircle
« on: March 26, 2019, 12:35:27 pm »
jCanvasES2.DrawCircle in Laz_And_GLESv2_Canvas.pas causes an out of range error:

Code: Pascal  [Select]
1. Procedure jCanvasES2.DrawCircle  (XY : TXY; Z, L : Single; Color : TRGBA; Width : Single = 0.3);
2. var
3.   i : Integer;
4. begin
5.   if not FInitialized then Exit;
6.   For i := 0 to 71 do
7.    DrawLine ( _XYZ(cCircle[(i+0)*2+0]*L+XY.X, cCircle[(i+0)*2+1]*L+XY.Y, Z),
8.               _XYZ(cCircle[(i+0)*2+2]*L+XY.X, cCircle[(i+0)*2+3]*L+XY.Y, Z),
9.               Color,Width);
10. end;

My suggestion for fixing the bug:

Code: Pascal  [Select]
1. Procedure jCanvasES2.DrawCircle(XY: TXY; Z, L: Single; AColor: TRGBA; AWidth: Single = 0.3);
2. var
3.   i: Integer;
4. begin
5.   if not FInitialized then Exit;
6.   For i := 0 to 70 do
7.     DrawLine(
8.       _XYZ(cCircle[i*2]  *L+XY.X, cCircle[i*2+1]*L+XY.Y, Z),
9.       _XYZ(cCircle[i*2+2]*L+XY.X, cCircle[i*2+3]*L+XY.Y, Z),
10.       AColor, AWidth
11.       );
12.   DrawLine(
13.     _XYZ(cCircle[0]  *L+XY.X, cCircle[1]  *L+XY.Y, Z),
14.     _XYZ(cCircle[142]*L+XY.X, cCircle[143]*L+XY.Y, Z),
15.     AColor, AWidth
16.     );
17. end;

I personally prefer AColor and AWidth as the names for the parameters but that is not necessary.

This bug report is related with this post:
https://forum.lazarus.freepascal.org/index.php/topic,44811
« Last Edit: March 27, 2019, 02:29:34 pm by Handoko »