Skip to content

Instantly share code, notes, and snippets.

@lukewilson2002
Last active April 24, 2019 02:57
Show Gist options
  • Save lukewilson2002/b99d81331ca8031d08224367e832ca00 to your computer and use it in GitHub Desktop.
Save lukewilson2002/b99d81331ca8031d08224367e832ca00 to your computer and use it in GitHub Desktop.
Unfilled cicle script for GDScript
func draw_unfilled_circle(circle_center: Vector2, radius: float, color: Color, width = 1, resolution: float = 1):
var draw_counter = 1.0
var vec_radius = Vector2(radius, 0)
var line_origin = vec_radius + circle_center
var line_end = Vector2()
while draw_counter <= 360.0:
line_end = vec_radius.rotated(deg2rad(draw_counter)) + circle_center
draw_line(line_origin, line_end, color, width)
draw_counter += 1.0 / resolution
line_origin = line_end
line_end = vec_radius.rotated(deg2rad(360)) + circle_center
draw_line(line_origin, line_end, color, width)
@lukewilson2002
Copy link
Author

There's an error and a few things that can be improved with this code. I'll update it with those improvements later.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment