"""Draw a GNUvola chord study. Usage: python chord-study.py 29 > study.svg"""
import argparse
import math

def draw(multiplier):
    count = 144
    colours = ('#f18c59', '#eeb875', '#92b7bd', '#dbe0d5')
    points = []
    for index in range(count):
        angle = math.tau * index / count - math.pi / 2
        points.append((360 + 320 * math.cos(angle), 360 + 320 * math.sin(angle)))
    print('<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 720 720">')
    print('<rect width="720" height="720" fill="#202a36"/>')
    for index, (x1, y1) in enumerate(points):
        x2, y2 = points[index * multiplier % count]
        colour = colours[index // 36]
        print(f'<line x1="{x1:.2f}" y1="{y1:.2f}" x2="{x2:.2f}" '
              f'y2="{y2:.2f}" stroke="{colour}" stroke-width="1.5"/>')
    print('</svg>')

if __name__ == '__main__':
    parser = argparse.ArgumentParser(description=__doc__)
    parser.add_argument('multiplier', type=int)
    draw(parser.parse_args().multiplier)
