Spaces:
Starting
on
L40S
Starting
on
L40S
File size: 5,228 Bytes
4450790 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 |
#---------------------------------------------------------------------------------------------------------------------#
# Comfyroll Studio custom nodes by RockOfFire and Akatsuzi https://github.com/Suzie1/ComfyUI_Comfyroll_CustomNodes
# for ComfyUI https://github.com/comfyanonymous/ComfyUI
#---------------------------------------------------------------------------------------------------------------------#
import math
def draw_circle(draw, center_x, center_y, size, aspect_ratio, color):
radius = size / 2
draw.ellipse([(center_x - radius, center_y - radius),
(center_x + radius, center_y + radius)], fill=color)
def draw_oval(draw, center_x, center_y, size, aspect_ratio, color):
aspect_ratio = aspect_ratio
draw.ellipse([(center_x - size / 2, center_y - size / 2 / aspect_ratio),
(center_x + size / 2, center_y + size / 2 / aspect_ratio)], fill=color)
def draw_diamond(draw, center_x, center_y, size, aspect_ratio, color):
aspect_ratio = aspect_ratio
draw.polygon([(center_x, center_y - size / 2 / aspect_ratio),
(center_x + size / 2, center_y),
(center_x, center_y + size / 2 / aspect_ratio),
(center_x - size / 2, center_y)], fill=color)
def draw_square(draw, center_x, center_y, size, aspect_ratio, color):
draw.rectangle([(center_x - size / 2, center_y - size / 2),
(center_x + size / 2, center_y + size / 2)], fill=color)
def draw_triangle(draw, center_x, center_y, size, aspect_ratio, color):
draw.polygon([(center_x, center_y - size / 2),
(center_x + size / 2, center_y + size / 2),
(center_x - size / 2, center_y + size / 2)], fill=color)
def draw_hexagon(draw, center_x, center_y, size, aspect_ratio, color):
hexagon_points = [
(center_x - size / 2, center_y),
(center_x - size / 4, center_y - size / 2),
(center_x + size / 4, center_y - size / 2),
(center_x + size / 2, center_y),
(center_x + size / 4, center_y + size / 2),
(center_x - size / 4, center_y + size / 2)
]
draw.polygon(hexagon_points, fill=color)
def draw_octagon(draw, center_x, center_y, size, aspect_ratio, color):
octagon_points = [
(center_x - size / 2, center_y - size / 4),
(center_x - size / 4, center_y - size / 2),
(center_x + size / 4, center_y - size / 2),
(center_x + size / 2, center_y - size / 4),
(center_x + size / 2, center_y + size / 4),
(center_x + size / 4, center_y + size / 2),
(center_x - size / 4, center_y + size / 2),
(center_x - size / 2, center_y + size / 4),
]
draw.polygon(octagon_points, fill=color)
def draw_quarter_circle(draw, center_x, center_y, size, aspect_ratio, color):
draw.pieslice([(center_x - size / 2, center_y - size / 2),
(center_x + size / 2, center_y + size / 2)], start=0, end=90, fill=color)
def draw_half_circle(draw, center_x, center_y, size, aspect_ratio, color):
draw.pieslice([(center_x - size / 2, center_y - size / 2),
(center_x + size / 2, center_y + size / 2)], start=0, end=180, fill=color)
def draw_starburst(draw, center_x, center_y, size, aspect_ratio, color):
num_rays = 16
for i in range(num_rays):
angle_ray = math.radians(i * (360 / num_rays))
x_end = center_x + size / 2 * math.cos(angle_ray)
y_end = center_y + size / 2 * math.sin(angle_ray)
draw.line([(center_x, center_y), (x_end, y_end)], fill=color, width=int(size / 20))
def draw_star(draw, center_x, center_y, size, aspect_ratio, color):
outer_radius = size / 4
inner_radius = outer_radius * math.cos(math.radians(36)) / math.cos(math.radians(72))
angle = -math.pi / 2
star_points = []
for _ in range(5):
x_outer = center_x + outer_radius * math.cos(angle)
y_outer = center_y + outer_radius * math.sin(angle)
star_points.extend([x_outer, y_outer])
angle += math.radians(72)
x_inner = center_x + inner_radius * math.cos(angle)
y_inner = center_y + inner_radius * math.sin(angle)
star_points.extend([x_inner, y_inner])
angle += math.radians(72)
draw.polygon(star_points, fill=color)
def draw_cross(draw, center_x, center_y, size, aspect_ratio, color):
# Define the points for the cross arms
cross_points = [
(center_x - size / 6, center_y - size / 2),
(center_x + size / 6, center_y - size / 2),
(center_x + size / 6, center_y - size / 6),
(center_x + size / 2, center_y - size / 6),
(center_x + size / 2, center_y + size / 6),
(center_x + size / 6, center_y + size / 6),
(center_x + size / 6, center_y + size / 2),
(center_x - size / 6, center_y + size / 2),
(center_x - size / 6, center_y + size / 6),
(center_x - size / 2, center_y + size / 6),
(center_x - size / 2, center_y - size / 6),
(center_x - size / 6, center_y - size / 6),
]
draw.polygon(cross_points, fill=color)
|