0 votes

godot draw_arc vs draw_circle_arc

extends Control

func _draw():
    var start = get_viewport_rect().size / 2.0
    var p1 = Vector2(128, 128)
    var p2 = Vector2(256, 256)
    draw_circle_arc(start, start.distance_to(p1), 0, 360, Color.purple)
    draw_arc(start, start.distance_to(p2), 0, 360, 32, Color.purple, 1)

func draw_circle_arc(center, radius, angle_from, angle_to, color):
    var nb_points = 32
    var points_arc = PoolVector2Array()

    for i in range(nb_points + 1):
        var angle_point = deg2rad(angle_from + i * (angle_to-angle_from) / nb_points - 90)
        points_arc.push_back(center + Vector2(cos(angle_point), sin(angle_point)) * radius)

    for index_point in range(nb_points):
        draw_line(points_arc[index_point], points_arc[index_point + 1], color)

is there any way to make drawarc behave like drawcircle_arc? am i doing something wrong or it supposed to look like that? wtf is it for spirograph?

custom drawing in 2d

in Engine by (1,884 points)

1 Answer

+1 vote
Best answer

oh sorry one takes radians and one takes angles :)
so 0 to 2*PI instead of 0 to 360

EDIT: 2*PI is defined for us as TAU! :)

by (1,884 points)
edited by
Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read Frequently asked questions and How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to [email protected] with your username.