Circle.gd 427 B

123456789101112131415161718192021222324
  1. extends Polygon2D
  2. var anglestep=6.28/30
  3. var radius
  4. class_name Circle
  5. func _init(_radius=30):
  6. radius = _radius
  7. var start = 0
  8. var finish = PI*2
  9. var pool = PoolVector2Array()
  10. var angle = start
  11. #arch
  12. while (angle <= finish):
  13. pool.push_back(radius * Vector2(cos(angle), sin(angle)))
  14. angle = angle + anglestep
  15. # close precisely
  16. angle = finish
  17. pool.push_back(radius*Vector2(cos(angle),sin(angle)))
  18. polygon=pool