godotengine / godot-proposals

Godot Improvement Proposals (GIPs)
MIT License
1.17k stars 98 forks source link

Add a draw_ellipse and draw_ellipse_arc function #8461

Open StanberyTrask opened 1 year ago

StanberyTrask commented 1 year ago

Describe the project you are working on

2D space game focusing on orbital mechanics and realism like children of a dead earth

Describe the problem or limitation you are having in your project

there is no built in way to draw ellipses and the best solution I've found is making a Curve2D and then drawing that with a polyline

Describe the feature / enhancement and how it helps to overcome the problem or limitation

add a draw_ellipse and draw_ellipse_arc function that would take parameters: draw_ellipse(position: Vector2, axes: Vector2, color: Color), draw_ellipse_arc(position: Vector2, axes: Vector2, start_angle: float, end_angle: float, point_count: int, color: Color, width: float = -1.0, antialiased: bool = false)

the axes argument being the major and minor axes of the ellipse.

Describe how your proposal will work, with code, pseudo-code, mock-ups, and/or diagrams

extends Node2D

func _draw():
    draw_ellipse(Vector2(0, 0), Vector2(50, 20), Color.BLUE)
        draw_ellipse_arc(Vector2(0, 0), Vector2(100, 40), 0, PI/2, 50, Color.RED, 5)

would draw a filled blue ellipse 50 pixels wide and 20 tall from 0, 0 and a quarter arc of an ellipse starting from 100, 0 and going counterclockwise

If this enhancement will not be used often, can it be worked around with a few lines of script?

you can work around this by using a Curve2Dand then drawing a polyline or polygon but these methods are cumbersome to code, and would take more resources in both memory and cpu time

Is there a reason why this should be core and not an add-on in the asset library?

this would be an addition to CanvasItem

Calinou commented 1 year ago
Calinou commented 2 weeks ago

@Maximon9 Please don't bump issues without contributing significant new information. Use the :+1: reaction button on the first post instead.