Skip to content

Instantly share code, notes, and snippets.

@boopr boopr/
Last active Feb 9, 2016

What would you like to do?
#!/usr/bin/env python3
# coding: utf-8
# Created by Louis ETIENNE
import math
import simpleSVG
except Exception as e:
print("Le fichier '' doit être au même emplacement que ce fichier.")
print("Pour le télécharger :")
def to_global_coords(n):
return math.floor((n+1) * (RESOLUTION/2))
def to_x(n):
return math.sin(n * 2 * math.pi)
def to_y(n):
return math.cos(n * 2 * math.pi)
def to_coords(n):
return {'x': to_x(n), 'y': to_y(n)}
def build_circle(modulo, factor):
# Calcule les coordonnées des lignes
chords = []
for index in range(modulo):
chords.append({ 'start': to_coords(float(index) / modulo),
'end': to_coords(((factor * float(index)) % modulo) / modulo) })
return chords
if __name__ == '__main__':
modulo = 200
factor = 68
circle = build_circle(modulo, factor)
draw = simpleSVG.svg_class(fname='output.svg'.format(modulo, factor), bbx=RESOLUTION, bby=RESOLUTION, whiteback=False)
draw.rect(0, 0, RESOLUTION, RESOLUTION, fill='black')
draw.scale(), .5, 300, stroke='white', stroke_width=1)
for chord in circle:
draw.line(to_global_coords(chord['start']['x']), to_global_coords(chord['start']['y']),
to_global_coords(chord['end']['x']), to_global_coords(chord['end']['y']),
stroke='white', stroke_width=1)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.