Spaces:
Sleeping
Sleeping
| 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 | |