本文實例為大家分享了python七夕浪漫表白的具體代碼,供大家參考,具體內容如下
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
|
from turtle import * from time import sleep def go_to(x, y): up() goto(x, y) down() def big_circle(size): #函數用于繪制心的大圓 speed( 1 ) for i in range ( 150 ): forward(size) right( 0.3 ) def small_circle(size): #函數用于繪制心的小圓 speed( 1 ) for i in range ( 210 ): forward(size) right( 0.786 ) def line(size): speed( 1 ) forward( 51 * size) def heart( x, y, size): go_to(x, y) left( 150 ) begin_fill() line(size) big_circle(size) small_circle(size) left( 120 ) small_circle(size) big_circle(size) line(size) end_fill() def arrow(): pensize( 10 ) setheading( 0 ) go_to( - 400 , 0 ) left( 15 ) forward( 150 ) go_to( 339 , 178 ) forward( 150 ) def arrowhead(): pensize( 1 ) speed( 1 ) color( 'red' , 'red' ) begin_fill() left( 120 ) forward( 20 ) right( 150 ) forward( 35 ) right( 120 ) forward( 35 ) right( 150 ) forward( 20 ) end_fill() def main(): pensize( 2 ) color( 'red' , 'pink' ) #getscreen().tracer(30, 0) #取消注釋后,快速顯示圖案 heart( 200 , 0 , 1 ) #畫出第一顆心,前面兩個參數控制心的位置,函數最后一個參數可控制心的大小 setheading( 0 ) #使畫筆的方向朝向x軸正方向 heart( - 80 , - 100 , 1.5 ) #畫出第二顆心 arrow() #畫出穿過兩顆心的直線 arrowhead() #畫出箭的箭頭 go_to( 400 , - 300 ) write( "author:520python" , move = true, align = "left" , font = ( "宋體" , 30 , "normal" )) done() main() |
效果如下:
以上就是本文的全部內容,希望對大家的學習有所幫助,也希望大家多多支持服務器之家。
原文鏈接:https://blog.csdn.net/ITxiaoangzai/article/details/81783519