当前位置: 首页 > news >正文

中文设计网站站长之家网站查询

中文设计网站,站长之家网站查询,网站的主页按钮怎么做,秀米网站怎么做推文一、前言 🎄为了庆祝我们副山羊勒布朗詹姆斯,连续刷分6场30,特此画一幅圣诞雪人,也祝福湖人12月26日圣诞大战,再我詹的带领下,刷分60,圣诞之夜历史第一人。 二、创意名 Lebron James It’s f…

一、前言

🎄为了庆祝我们副山羊勒布朗詹姆斯,连续刷分6场30+,特此画一幅圣诞雪人,也祝福湖人12月26日圣诞大战,再我詹的带领下,刷分60+,圣诞之夜历史第一人。

二、创意名

Lebron James It’s for you!

三、效果展示

在这里插入图片描述

四、实现步骤

  1. 创建画布,设置背景,图片,设置雪球参数,风参数
  2. 创建画布中所有圆形对象
  3. 创建雪球
  4. 创建雪球移动函数
  5. 创建雪人
  6. 创建地面

五、编码实现

创建画布,设置背景,图片,设置雪球参数,风参数

import turtle
import random
import timewidth = height = 500window = turtle.Screen()
window.setup(width, height)
window.bgcolor("sky blue")
window.bgpic('jm.gif')
window.title("Happy Holidays")snowball_rate = 1, 3
snowball_size = 5, 15
wind_change = 1, 5
max_wind = 3

turtle.bgpic函数只接受gif格式的图片

创建画布中所有圆形对象

def make_circle(turtle_name, x, y, size, colour):turtle_name.color(colour)turtle_name.penup()turtle_name.setposition(x, y)turtle_name.dot(size)

创建雪球

list_of_snowballs = []
def make_snowball():snowball = turtle.Turtle()snowball.color("white")snowball.penup()snowball.setposition(random.randint(-2*width, width/2), height/2)snowball.hideturtle()snowball.size = random.randint(*snowball_size)list_of_snowballs.append(snowball)

创建雪球移动函数

def move_snowball(turtle_name, falling_speed=1, wind=0):turtle_name.clear()turtle_name.sety(turtle_name.ycor() - falling_speed)if wind:turtle_name.setx(turtle_name.xcor() + wind)turtle_name.dot(turtle_name.size)

创建雪人

# 雪人:身体
snowman = turtle.Turtle()
x_position = 100
y_positions = 75, 0, -100
size = 75
for y in y_positions:make_circle(snowman, x_position, y, size, "white")size = size *1.5# 雪人:按钮
button_seperation = 25
button_y_positions = [y_positions[1]-button_seperation,y_positions[1],y_positions[1]+button_seperation]
for y in button_y_positions:make_circle(snowman, x_position, y, 10, "black")# 雪人:眼睛
y_offset = 10
x_seperation = 15
for x in x_position-x_seperation, x_position+x_seperation:make_circle(snowman, x, y_positions[0] + y_offset, 20, "green")make_circle(snowman, x, y_positions[0] + y_offset, 10, "black")# 雪人:鼻子
snowman.color("orange")
snowman.setposition(x_position - 10, y_positions[0]-y_offset)
snowman.shape("triangle")
snowman.setheading(200)
snowman.turtlesize(0.5, 2.5)window.tracer(0)

创建地面

grass = turtle.Turtle()
grass.fillcolor("forest green")
grass.penup()
grass.setposition(-width/2, -height/2)
grass.begin_fill()
for _ in range(2):grass.forward(width)grass.left(90)grass.forward(70)grass.left(90)
grass.end_fill()ground = turtle.Turtle()
for x in range(int(-width/2), int(width/2), int(width/200)):make_circle(ground, x, -180, random.randint(5, 20), "white")

给画布添加文字

text = turtle.Turtle()
text.color("red")
text.penup()
text.setposition(-100,170)
text.write("Happy Holidays", font=("Apple Chancery", 30, "bold"), align="center")
text.setposition(130, 140)
text.color("dark green")
text.write("Lebron", font=("Avenir", 30, "normal"), align="right")
text.color("black")
text.write("James", font=("Avenir", 30, "normal"), align="left")
text.setx(50)
text.write("It's for you!", font=("Apple Chancery", 20, "bold"), align="right")
text.hideturtle()

定义画布的时间函数

time_delay = 0
start_time = time.time()
wind = 0
wind_delay = 5
wind_timer = time.time()
wind_step = 0.1
while True:if time.time() - start_time > time_delay:make_snowball()start_time = time.time()time_delay = random.randint(*snowball_rate)/10for snowball in list_of_snowballs:move_snowball(snowball, wind=wind)if snowball.ycor() < -height/2:snowball.clear()list_of_snowballs.remove(snowball)if time.time() - wind_timer > wind_delay:wind += wind_stepif wind >= max_wind:wind_step = -wind_stepelif wind <= 0:wind_step = abs(wind_step)wind_timer = time.time()wind_delay = random.randint(*wind_change)/10window.update()turtle.done()
http://www.lbrq.cn/news/2718217.html

相关文章:

  • 什么网站教你做美食360推广联盟
  • 没有网站如何做落地页网络广告案例以及分析
  • 城市建设规划网站app推广代理平台
  • 网站个人空间怎么做今日国内新闻10则
  • 网站内容seo广州seo优化外包公司
  • 暴雪公司现状seo快速排名百度首页
  • 让网站百度不到网络营销的渠道有哪些
  • SEO优化网站建设价格sem网站推广怎么做
  • 哪些网站可以做视频收费汕头网站建设方案优化
  • 新手做免费网站seo实战密码电子书
  • 北理工网站开发与应用答案百度一下首页登录入口
  • 温州网站建设案例seo搜索是什么意思
  • ks2e独服做网站手机优化软件哪个好用
  • 程序开源网站搜索网站排名
  • 深圳网站设计公司电话seo黑帽有哪些技术
  • 南宁市做网站百度的网站网址
  • 网站建设 风险今日国际新闻最新消息事件
  • 微信上微网站怎么做的常德今日头条新闻
  • 所有购物网站的名字如何在微信上做广告
  • 网站框架设计企业网络营销推广方案
  • 做网站需要学习什么百度seo是啥意思
  • 外贸建设网站网站优化及推广方案
  • 北海做网站的网络公司班级优化大师怎么用
  • wordpress 登录后查看网站优化排名软件
  • 网站缓存设置怎么做淄博新闻头条最新消息
  • b2b专业性平台seo优化服务是什么意思
  • wordpress投诉功能seo点石论坛
  • 福州婚庆网站建设哪家好营销说白了就是干什么的
  • 微网站制作公司百度推广客服电话
  • 手机网站和app有什么区别百度指数下载手机版
  • 《探秘浏览器Web Bluetooth API设备发现流程》
  • springboot博客实战笔记02
  • 云计算-Docker Compose 实战:从OwnCloud、WordPress、SkyWalking、Redis ,Rabbitmq等服务配置实例轻松搞定
  • 如何使用 Ollama 在本地设置并运行 Qwen3
  • TeamViewer 以数字化之力,赋能零售企业效率与客户体验双提升
  • 开源日志log4cplus—调用MultiByteToWideChar提示未定义,CP_UTF8未定义定原因有哪些,如何改进?