turtle画风轮

效果

在这里插入图片描述

#PythonDraw.py
import turtle 
turtle.setup(800, 600, 650, 100 )
turtle.pencolor("black")
turtle.pensize(5)

turtle.right(45)
turtle.fd(150)
turtle.left(90)
turtle.circle(150,45)
turtle.left(90)
turtle.fd(150)

for i in range(3):
    turtle.right(135)
    turtle.fd(150)
    turtle.left(90)
    turtle.circle(150,45)
    turtle.left(90)
    turtle.fd(150)

turtle.done

下面是用turtle绘制摩天Python代码: ```python import turtle # 设置画布大小和背景颜色 turtle.setup(800, 600) turtle.bgcolor("#e9e9e9") # 定义变量 radius = 150 # 摩天半径 angle = 360 / 8 # 摩天每个车厢之间的夹角 car_width = 50 # 车厢宽度 car_height = 80 # 车厢高度 car_color = ["#ff0000", "#ffff00", "#00ff00", "#00ffff", "#0000ff", "#ff00ff", "#9900cc", "#33ccff"] # 车厢颜色 # 绘制摩天车厢 def draw_car(x, y, color): turtle.penup() turtle.goto(x, y) turtle.pendown() turtle.setheading(0) turtle.fillcolor(color) turtle.begin_fill() turtle.forward(car_width / 2) turtle.left(90) turtle.forward(car_height) turtle.left(90) turtle.forward(car_width) turtle.left(90) turtle.forward(car_height) turtle.left(90) turtle.forward(car_width / 2) turtle.end_fill() # 绘制摩天 def draw_ferris_wheel(x, y): turtle.penup() turtle.goto(x, y) turtle.pendown() turtle.setheading(0) turtle.pensize(3) turtle.color("#333333") turtle.circle(radius) for i in range(8): turtle.penup() turtle.goto(x, y) turtle.pendown() turtle.setheading(i * angle) draw_car(x + radius * 0.8 * turtle.cos(i * angle), y + radius * 0.8 * turtle.sin(i * angle), car_color[i]) # 绘制摩天支架 def draw_support(x, y): turtle.penup() turtle.goto(x, y) turtle.pendown() turtle.setheading(0) turtle.pensize(5) turtle.color("#333333") turtle.forward(radius * 1.2) turtle.backward(radius * 0.1) turtle.right(90) turtle.forward(50) turtle.backward(100) turtle.forward(50) turtle.left(90) turtle.forward(radius * 0.1) turtle.backward(radius * 1.1) # 调用函数绘制摩天 draw_ferris_wheel(0, 0) draw_support(0, -radius * 1.2) # 隐藏海龟 turtle.hideturtle() # 显示绘图窗口 turtle.mainloop() ``` 运行代码,即可看到绘制的摩天: ![](https://cdn.luogu.com.cn/upload/image_hosting/gtdf7q2b.png)
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值