turtle绘制彩色实心立方体
请用turtle工具绘制彩色实心立方体,如图所示
要求
1.绘制2个平行四边形,颜色分别是红色,蓝色
2.绘制1个正方形,颜色是绿色
3.平行四边形边长:120,正方形边长:120
4.平行四边形锐角为45°,钝角135°
import turtle
#边长
x = 120
def right():
turtle.left(45)
turtle.forward(x)
turtle.right(135)
turtle.forward(x)
turtle.right(45)
turtle.forward(x)
turtle.right(135)
turtle.forward(x)
def left():
turtle.left(45)
turtle.forward(x)
turtle.left(135)
turtle.forward(x)
turtle.left(45)
turtle.forward(x)
turtle.left(135)
turtle.forward(x)
def top():
turtle.right(45)
turtle.forward(x)
turtle.left(90)
turtle.forward(x)
turtle.left(90)
turtle.forward(x)
turtle.left(90)
turtle.forward(x)
turtle.fillcolor('red')
turtle.begin_fill()
right()
turtle.end_fill()
turtle.fillcolor('blue')
turtle.begin_fill()
left()
turtle.end_fill()
turtle.fillcolor('green')
turtle.begin_fill()
top()
turtle.end_fill()
turtle.hideturtle()
turtle.done()