Skip to content

Commit b3b0b1e

Browse files
authored
Merge pull request #9267 from JordanKlooster/patch-1
Fixed small code error in custom_drawing_in_2d.rst
2 parents e8c441e + faac14a commit b3b0b1e

File tree

1 file changed

+8
-6
lines changed

1 file changed

+8
-6
lines changed

tutorials/2d/custom_drawing_in_2d.rst

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1005,9 +1005,10 @@ Calculating this arc will be more complex than in the case of the line:
10051005
.. code-tab:: gdscript GDScript
10061006

10071007
func _draw():
1008-
# Calculate the arc parameters.
1009-
var center : Vector2 = Vector2((_point2.x - point1.x) / 2,
1010-
(_point2.y - point1.y) / 2)
1008+
# Average points to get center.
1009+
var center : Vector2 = Vector2((_point2.x + point1.x) / 2,
1010+
(_point2.y + point1.y) / 2)
1011+
# Calculate the rest of the arc parameters.
10111012
var radius : float = point1.distance_to(_point2) / 2
10121013
var start_angle : float = (_point2 - point1).angle()
10131014
var end_angle : float = (point1 - _point2).angle()
@@ -1022,9 +1023,10 @@ Calculating this arc will be more complex than in the case of the line:
10221023

10231024
public override void _Draw()
10241025
{
1025-
// Calculate the arc parameters.
1026-
Vector2 center = new Vector2((_point2.X - Point1.X) / 2.0f,
1027-
(_point2.Y - Point1.Y) / 2.0f);
1026+
// Average points to get center.
1027+
Vector2 center = new Vector2((_point2.X + Point1.X) / 2.0f,
1028+
(_point2.Y + Point1.Y) / 2.0f);
1029+
// Calculate the rest of the arc parameters.
10281030
float radius = Point1.DistanceTo(_point2) / 2.0f;
10291031
float startAngle = (_point2 - Point1).Angle();
10301032
float endAngle = (Point1 - _point2).Angle();

0 commit comments

Comments
 (0)