From 196d46f08ebfbd8c6804d926238f410bbe9a3a29 Mon Sep 17 00:00:00 2001 From: FlyPython <54256709+flypythoncom@users.noreply.github.com> Date: Fri, 13 Sep 2019 18:45:38 +0800 Subject: [PATCH] Add files via upload --- mooncake.py | 77 +++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 77 insertions(+) create mode 100644 mooncake.py diff --git a/mooncake.py b/mooncake.py new file mode 100644 index 0000000..0dce332 --- /dev/null +++ b/mooncake.py @@ -0,0 +1,77 @@ +#!/usr/bin/env python2 +#encoding=utf-8 + +import turtle as tt +import math +import time + +tt.hideturtle() +tt.speed(10) + +def draw_circle(r): + tt.penup() + tt.goto(0, -r) + tt.seth(0) + tt.pendown() + tt.pensize(5) + tt.color('#F8CD32','#FBA92D') + tt.begin_fill() + tt.circle(r) + tt.end_fill() + +def draw_petal(r, n): + tt.penup() + tt.goto(0, -r) + tt.seth(0) + tt.pendown() + + small_r = math.sin( math.pi/n) * r + + for i in range(n): + tt.penup() + tt.home() + tt.seth((360/n)*i) + tt.fd(r) + tt.left((360/n)*0.5) + tt.pendown() + tt.color('#F0BE7C') + tt.begin_fill() + tt.circle(small_r,180) + tt.end_fill() + +def draw_square(d, r): + tt.penup() + tt.seth(0) + tt.goto(d/2 + r, -d/2) + tt.left(90) + tt.pendown() + + for i in range(4): + tt.fd(d) + tt.circle(r, 90) + +def draw_word(word, x, y): + tt.penup() + tt.goto(x, y) + tt.pendown() + tt.color("Gold") + tt.write(word, font=("微软雅黑",35, "normal")) + + + +def draw(): + tt.title("FlyPython祝您中秋快乐") + draw_circle(120) + draw_petal(120,18) + #draw_square(100,10) + draw_word("五",-50,5) + draw_word("最",0,5) + draw_word("仁",-50,-40) + draw_word("棒",0,-40) + tt.done() + + +if __name__ == "__main__": + time.sleep(10) + draw() +