本文以python七夕浪漫告白的具体代码为例,供大家参考。 具体内容如下
来自turtle导入*
来自时间导入滑动
defgo_to(x,y ) :
up () )
GOTO(x,y ) )。
瘫痪() ) )。
defbig_circle(size ) : #函数用于绘制心大圆
speed(1)。
forIinrange(150 ) :
是前锋(size )
是right(0.3 )
defsmall_circle(size ) : #函数用于绘制心的小圆
speed(1)。
forIinrange(210 ) :
是前锋(size )
是right(0.786 )
defline(size ) :
speed(1)。
是前锋(51 * size )
defheart(x,y,size ) :
go_to(x,y ) )。
是left(150 )
begin_fill ()
是line(size )
是big_circle(size )
small_Circle(size )
左(120 )。
small_Circle(size )
是big_circle(size )
是line(size )
end_fill ()
def arrow () :
pensize(10 ) )。
设置头(0) )。
go _ to (-400,0 ) ) ) ) ) ) ) )。
左(15 )。
是前锋(150 )
go _ to (339,178 ) )。
是前锋(150 )
def arrowHead () :
pensize(1) )。
speed(1)。
color('red ',' red ' )
begin_fill ()
左(120 )。
前锋(20岁)。
是right(150 )
是前锋(35岁)
是right(120 )
是前锋(35岁)
是right(150 )
前锋(20岁)。
end_fill ()
defmain(: )
pensize(2) )。
color('red ',' pink ' )
#getscreen ().Tracer (),0 )取消注释可快速显示图案
heart (200,0,1 ) #绘制第一个心,前面两个参数控制心的位置,函数的最后一个参数控制心的大小
设置头(0) )使画笔的方向指向x轴的正方向
heart(-80、-100、1.5 ) #画第二颗心
arrow(#2画一条通过两个心的直线
arrowhead(# (画#箭头
go_to(400,-300 ) )。
write(author:520python ),move=True,align='left ',font=),30,' normal ) )
done () )
主() )
效果如下。
希望以上是正文的全部内容,对大家的学习有帮助。 另外,我希望你支持很多编剧。