Spaces:
Sleeping
Sleeping
File size: 679 Bytes
eb1d6d3 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 | import math
def render_spiral_svg(turns=5, points=200):
width, height = 512, 512
cx, cy = width // 2, height // 2
max_radius = min(cx, cy) - 10
svg_header = f'<svg xmlns="http://www.w3.org/2000/svg" width="{width}" height="{height}">'
svg_footer = '</svg>'
spiral_path = '<path d="M '
for i in range(points):
angle = 2 * math.pi * turns * (i / points)
radius = max_radius * (i / points)
x = cx + radius * math.cos(angle)
y = cy + radius * math.sin(angle)
spiral_path += f'{x:.2f},{y:.2f} '
spiral_path += '" fill="none" stroke="blue" stroke-width="2"/>'
return svg_header + spiral_path + svg_footer
|