Godot area determination

I have balls in my res/assets folder with godot, I randomly assign these balls to the screen using gdscript codes, but a Node2D/Area2D/Polygon2D area has been created in my scene, I want the balls to come to the part of this polygon I specified, what should I do?

extends Node2D

var top_count = 0
var min_position = Vector2(50, 50)  
var max_position = Vector2(350, 350)  
var vertical_spacing = 30  

func _ready():

func generate_random_position(tops, current_row):
	var area_center = (min_position + max_position) / 2  
	var new_position = Vector2(
		randf_range(area_center.x - (max_position.x - min_position.x) / 2, area_center.x + (max_position.x - min_position.x) / 2),
		randf_range(area_center.y - (max_position.y - min_position.y) / 2 + current_row * vertical_spacing, 
					area_center.y + (max_position.y - min_position.y) / 2 + current_row * vertical_spacing)

	for i in range(tops.get_child_count()):
		var existing_top = tops.get_child(i)
		var distance = new_position.distance_to(existing_top.position)

		if distance < (existing_top.texture.get_width() + existing_top.texture.get_height()) * 0.6:
			return generate_random_position(tops, current_row)

	return new_position

You could try using Geometry2D.is_point_in_polygon() to know if the random point is inside the polygon or not and repeat with another random point until the point is inside a polygon.

	extends Node

	@onready var polygon_2d: Polygon2D = $Polygon2D

	var min:Vector2 = Vector2.INF
	var max:Vector2 = -Vector2.INF

	func _ready() -> void:
		# get the min and max vectors from the polygon
		for point in polygon_2d.polygon:
			min.x = min(min.x, point.x)
			min.y = min(min.y, point.y)
			max.x = max(max.x, point.x)
			max.y = max(max.y, point.y)

		printt("Polygon min and max vectors:", min, max)

		# print 10 random points inside of the polygon
		for i in 10:

	func get_random_point_in_polygon() -> Vector2:
		var result = Vector2.ZERO
		while true:
			# Get random point
			result.x = randf_range(min.x, max.x)
			result.y = randf_range(min.y, max.y)
			if Geometry2D.is_point_in_polygon(result, polygon_2d.polygon):
				# if the point is inside the polygon, break out of the loop

		# return the point
		return result