From 7e38d2a71fc4f47fdcc5e8965ad041e32fe2a2f9 Mon Sep 17 00:00:00 2001 From: Adam Allport Date: Tue, 29 Aug 2017 09:06:28 +0100 Subject: [PATCH] Added drawBar Made the turtle draw the silhouette RELEASE V0.1 --- main.py | 11 +++++++++-- units.py | 2 +- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/main.py b/main.py index 16aa98c..436d7b5 100644 --- a/main.py +++ b/main.py @@ -12,6 +12,8 @@ def main(): """ Main program function, Draws silhouette""" + template = [10, 10, 0, 8, 8, 0, 20, 18, 25, 18, 20, 0, 10, 10, 10, 0, 21, 22, 24, 22, 21, 0, 12, 14, 12, 0, 18, 16, + 20, 0, 20, 22, 24, 0, 0, 8, 8, 7, 8, 7, 10, 12] charles = turtle.Turtle() screen = charles.screen charles.penup() @@ -19,8 +21,8 @@ def main(): charles.setheading(0) charles.pendown() charles.speed(1000) - for i in range(units.wu2px(screen, 45)): - draw_peak(charles, units.vu2px(screen, 10)) + for h in template: + draw_bar_u(screen, charles, 1, h) turtle.done() @@ -35,5 +37,10 @@ def draw_peak(drawer, height): drawer.left(90) +def draw_bar_u(screen, drawer, width, height): + for i in range(units.wu2px(screen, width)): + draw_peak(drawer, units.vu2px(screen, height)) + + if __name__ == "__main__": main() diff --git a/units.py b/units.py index 9d053ae..392574f 100644 --- a/units.py +++ b/units.py @@ -9,7 +9,7 @@ def vu2px(screen, units): """ Returns the px's for a vertical unit (25ths of height)""" - return int((screen.window_height() / 50) * units) + return int((screen.window_height() / 25) * units) def wu2px(screen, units):