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 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152
| import turtle import time from turtle import mainloop, hideturtle
def clear_all(): turtle.penup() turtle.goto(0, 0) turtle.color('white') turtle.pensize(800) turtle.pendown() turtle.setheading(0) turtle.fd(300) turtle.bk(600)
def go_to(x, y, state): turtle.pendown() if state else turtle.penup() turtle.goto(x, y)
def draw_heart(size): turtle.color('red', 'pink') turtle.pensize(2) turtle.pendown() turtle.setheading(150) turtle.begin_fill() turtle.fd(size) turtle.circle(size * -3.745, 45) turtle.circle(size * -1.431, 165) turtle.left(120) turtle.circle(size * -1.431, 165) turtle.circle(size * -3.745, 45) turtle.fd(size) turtle.end_fill()
def draw_people(x, y): turtle.penup() turtle.goto(x, y) turtle.pendown() turtle.pensize(2) turtle.color('black') turtle.setheading(0) turtle.circle(60, 360) turtle.penup() turtle.setheading(90) turtle.fd(75) turtle.setheading(180) turtle.fd(20) turtle.pensize(4) turtle.pendown() turtle.circle(2, 360) turtle.setheading(0) turtle.penup() turtle.fd(40) turtle.pensize(4) turtle.pendown() turtle.circle(-2, 360) turtle.penup() turtle.goto(x, y) turtle.setheading(-90) turtle.pendown() turtle.fd(20) turtle.setheading(0) turtle.fd(35) turtle.setheading(60) turtle.fd(10) turtle.penup() turtle.goto(x, y) turtle.setheading(-90) turtle.pendown() turtle.fd(40) turtle.setheading(0) turtle.fd(35) turtle.setheading(-60) turtle.fd(10) turtle.penup() turtle.goto(x, y) turtle.setheading(-90) turtle.pendown() turtle.fd(60) turtle.setheading(-135) turtle.fd(60) turtle.bk(60) turtle.setheading(-45) turtle.fd(30) turtle.setheading(-135) turtle.fd(35) turtle.penup()
def draw_text(text, t_color, font_size, show_time): turtle.penup() turtle.goto(-350, 0) turtle.color(t_color) turtle.write(text, font=('宋体', font_size, 'normal')) time.sleep(show_time) clear_all()
def draw_(): turtle.speed(0) draw_people(-250, 20) turtle.penup() turtle.goto(-150, -30) draw_heart(14) turtle.penup() turtle.goto(-200, -200) turtle.color('pink') turtle.write('Biu~', font=('宋体', 60, 'normal')) turtle.penup() turtle.goto(-20, -60) draw_heart(25) turtle.penup() turtle.goto(-70, -200) turtle.color('pink') turtle.write('Biu~', font=('宋体', 60, 'normal')) turtle.penup() turtle.goto(200, -100) draw_heart(45) turtle.penup() turtle.goto(150, -200) turtle.color('pink') turtle.write('Biu~', font=('宋体', 60, 'normal')) turtle.hideturtle() time.sleep(3)
def main(): hideturtle() turtle.setup(900, 500)
draw_text("我想给你看个东西", "black", 60, 0) draw_text("准备好了吗?", "red", 60, 0) draw_text("接下来", "blue", 45, 0) draw_text("3", "skyblue", 45, 0) draw_text("2", "skyblue", 45, 0) draw_text("1", "skyblue", 45, 0) draw_text("七夕快乐!!!", "pink", 60, 0) draw_text("发射爱心!!!", "pink", 60, 3) draw_() mainloop()
main()
|