/usr/share/pyshared/pyknon/plot.py is in python-pyknon 1.0-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
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 | import math
from pyknon.simplemusic import inversion
import Tkinter as Tk
MARGIN = 30
def x_y_points(tick, number_points, radius):
angle = tick * (360.0 / number_points)
rad_angle = math.radians(angle)
x = radius * math.sin(rad_angle)
y = radius * math.cos(rad_angle)
return int(round(x)), int(round(y))
def points_in_a_circle(n_points, radius):
return [x_y_points(n, n_points, radius) for n, p in enumerate(range(n_points))]
def scaled_points(radius):
points = points_in_a_circle(12, radius)
return [(x + radius + MARGIN, radius - y + MARGIN) for x, y in points]
def plot_circle(canvas, width, points):
canvas.create_oval(MARGIN, width, width, MARGIN)
def plot_points(canvas, points):
for x, y in points:
canvas.create_oval(x - 2, y - 2, x + 2, y + 2, fill="black")
def plot_numbers(canvas, points):
for n, (x, y) in enumerate(points):
canvas.create_text(x, y-10, text=str(n), font=("Helvetica Bold", 14))
def plot_notes(notes, canvas, points, color="black"):
p = points
for n1, n2 in zip(notes, notes[1:]):
p = points[n1] + points[n2]
canvas.create_line(*p, width=3, fill=color)
def canvas_notes(notes_list, width=400):
canvas = Tk.Canvas(width=width, height=width)
canvas.pack(side=Tk.TOP)
radius = (width / 2) - MARGIN
points = scaled_points(radius)
plot_points(canvas, points)
plot_numbers(canvas, points)
plot_circle(canvas, width - MARGIN, points)
for notes, color in notes_list:
plot_notes(notes, canvas, points, color)
return canvas
def view(notes_list, width=400):
canvas = canvas_notes(notes_list, width)
mainloop()
def notes_ps(notes_list, filename, width=400):
canvas = canvas_notes(notes_list, width)
L, T, R, B = canvas.bbox(Tk.ALL)
canvas.postscript(file=filename, height=B, width=R,
pageheight=B, pagewidth=R, x=0, y=0)
def plot2(notes1, notes2, filename):
notes_list = [(notes1, "black"), (notes2, "red")]
notes_ps(notes_list, filename)
|