Python教程:使用Turtles画出带有花瓣的花


Python教程:使用Turtles画出带有花瓣的花

文章插图
 
简单画出一朵带有花瓣的花# -*- coding:utf-8 -*-import turtle# create window and turtlewindow = turtle.Screen()babbage = turtle.Turtle()# draw stem and centre# draw stembabbage.color('green', 'black')babbage.left(90)babbage.forward(100)babbage.right(90)# draw centrebabbage.color('black', 'black')babbage.begin_fill()babbage.circle(10)babbage.end_fill()# draw all petalsfor i in range(1, 24): if babbage.color() == ('red', 'black'): babbage.color('orange', 'black') elif babbage.color() == ('orange', 'black'): babbage.color('yellow', 'black') else: babbage.color('red', 'black') babbage.left(15) babbage.forward(50) babbage.left(157) babbage.forward(50)# hide the turtlebabbage.hideturtle()# tidy up windowwindow.exitonclick()
【Python教程:使用Turtles画出带有花瓣的花】


    推荐阅读