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

asked Jun 12 in Engine by rakkarage (871 points)

1 Answer

0 votes
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! :)

answered Jun 12 by rakkarage (871 points)
edited Jun 12 by rakkarage
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 How to use this Q&A? before posting your first questions.