跳转至

绘制四叶风轮

题目描述

在Turtle画布上画出如图所示的风轮,半径为100。要求: 1. 风轮由4个扇叶组成,每个扇叶大小相等,相邻两个扇叶间距相等; 2. 四个扇叶的颜色分别是('red', 'yellow', 'blue', 'green')

代码详解

展开查看
import turtle as t
t.shape("turtle")
colors = ["red", "yellow", "blue", "green"]

def drawleave(x): #函数定义
    t.seth(x*90)
    t.fillcolor(colors[x])
    t.begin_fill()
    t.forward(100)
    t.right(90)
    t.circle(-100, 45)
    t.right(90)
    t.forward(100)
    t.end_fill()

for x in range(4):
    drawleave(x) #函数调用

t.done()

运行结果