initial commit
This commit is contained in:
@@ -0,0 +1,37 @@
|
||||
|
||||
extends Polygon2D
|
||||
|
||||
var num_circle_points: int = 100
|
||||
var circle_radius: float = 100.
|
||||
|
||||
var window_size: Vector2i
|
||||
var window_center: Vector2i
|
||||
|
||||
# Called when the node enters the scene tree for the first time.
|
||||
func _ready() -> void:
|
||||
window_size = DisplayServer.window_get_size()
|
||||
window_center = Vector2i(window_size.x/2, window_size.y/2)
|
||||
|
||||
|
||||
# Called every frame. 'delta' is the elapsed time since the previous frame.
|
||||
func _process(delta: float) -> void:
|
||||
pass
|
||||
|
||||
|
||||
func _on_option_button_item_selected(index: int) -> void:
|
||||
if index == 0:
|
||||
# circle
|
||||
_generate_circle_points()
|
||||
elif index == 1:
|
||||
# rectangle
|
||||
pass
|
||||
|
||||
func _generate_circle_points():
|
||||
var new_polygon = []
|
||||
for i in range(num_circle_points-1):
|
||||
var rot_angle: float = 2.*PI * ((i+1) / float(num_circle_points))
|
||||
var x = circle_radius * cos(rot_angle)
|
||||
var y = circle_radius * sin(rot_angle)
|
||||
new_polygon.append(Vector2(x, y))
|
||||
polygon = PackedVector2Array(new_polygon)
|
||||
|
||||
Reference in New Issue
Block a user