Updated to 4.4
This commit is contained in:
parent
eaa26d1361
commit
1aff15069a
151 changed files with 593 additions and 100 deletions
30
addons/PoissonDiscSampling/Demo/polygon_demo.gd
Normal file
30
addons/PoissonDiscSampling/Demo/polygon_demo.gd
Normal file
|
|
@ -0,0 +1,30 @@
|
|||
extends Node2D
|
||||
|
||||
|
||||
@onready var polygon: Array = $Polygon2D.polygon
|
||||
@onready var n = polygon.size()
|
||||
|
||||
var p_radius: int = 20
|
||||
var k: int = 0
|
||||
var points := []
|
||||
|
||||
|
||||
func _draw() -> void:
|
||||
for i in n:
|
||||
draw_line(polygon[i], polygon[(i+1)%n], Color(1,1,0), 2, 1)
|
||||
|
||||
draw_circle(points[k], p_radius / 2, Color( 1, 0, 0, 1 ))
|
||||
draw_circle(points[k], 2, Color( 1, 1, 0, 1 ))
|
||||
|
||||
|
||||
func _ready() -> void:
|
||||
var start_time = Time.get_ticks_msec()
|
||||
points = PoissonDiscSampling.generate_points_for_polygon($Polygon2D.polygon, p_radius, 30)
|
||||
# points = PoissonDiscSampling.generate_points_for_circle(Vector2(300,300),200, p_radius, 30)
|
||||
print(points.size(), " points generated in ", Time.get_ticks_msec() - start_time, " miliseconds" )
|
||||
|
||||
|
||||
func _process(delta: float) -> void:
|
||||
if k < points.size() - 1:
|
||||
queue_redraw()
|
||||
k += 1
|
||||
1
addons/PoissonDiscSampling/Demo/polygon_demo.gd.uid
Normal file
1
addons/PoissonDiscSampling/Demo/polygon_demo.gd.uid
Normal file
|
|
@ -0,0 +1 @@
|
|||
uid://ckgdl8g835gsm
|
||||
21
addons/PoissonDiscSampling/Demo/polygon_demo.tscn
Normal file
21
addons/PoissonDiscSampling/Demo/polygon_demo.tscn
Normal file
|
|
@ -0,0 +1,21 @@
|
|||
[gd_scene load_steps=2 format=3 uid="uid://c74o3ucws2ac4"]
|
||||
|
||||
[ext_resource type="Script" path="res://addons/PoissonDiscSampling/Demo/polygon_demo.gd" id="1_3y3ej"]
|
||||
|
||||
[node name="SubViewportContainer" type="SubViewportContainer"]
|
||||
offset_right = 40.0
|
||||
offset_bottom = 40.0
|
||||
|
||||
[node name="SubViewport" type="SubViewport" parent="."]
|
||||
handle_input_locally = false
|
||||
size = Vector2i(1152, 648)
|
||||
render_target_clear_mode = 1
|
||||
render_target_update_mode = 4
|
||||
|
||||
[node name="PolygonDemo" type="Node2D" parent="SubViewport"]
|
||||
script = ExtResource("1_3y3ej")
|
||||
|
||||
[node name="Polygon2D" type="Polygon2D" parent="SubViewport/PolygonDemo"]
|
||||
color = Color(1, 1, 1, 0)
|
||||
antialiased = true
|
||||
polygon = PackedVector2Array(123, 266, 378, 26, 682, 157, 1002, 118, 1077, 424, 747, 541, 843, 302, 810, 217, 553, 446, 468, 227, 430, 560, 103, 560, 261, 475, 361, 268)
|
||||
Loading…
Add table
Add a link
Reference in a new issue