用python画星空的代码
无所不能的python没想到还能画星空,现在就让我们来画一个
from turtle import *
from random import random,randint
screen = Screen()
width ,height = 800,600
screen.setup(width,height)
screen.title("模拟3D星空")
screen.bgcolor("black")
screen.mode("logo")
screen.delay(0)#这里要设为0,否则很卡
t = Turtle(visible = False,shape='circle')
t.pencolor("white")
t.fillcolor("white")
t.penup()
t.setheading(-90)
t.goto(width/2,randint(-height/2,height/2))
stars = []
for i in range(200): star = t.clone() s =random() /3 star.shapesize(s,s) star.speed(int(s*10)) star.setx(width/2 + randint(1,width)) star.sety( randint(-height/2,height/2)) star.showturtle() stars.append(star)
while True: for star in stars: star.setx(star.xcor() - 3 * star.speed()) if star.xcor()<-width/2: star.hideturtle() star.setx(width/2 + randint(1,width)) star.sety( randint(-height/2,height/2)) star.showturtle()
运行一下
用python画星空的代码相关推荐
- 用python画星空的代码_用python画星空源代码是什么?_后端开发
用python画星空源代码是什么? 用python画星空源代码是 from turtle import * from random import random,randint screen = Scr ...
- 用python画星空的代码简单-【Python】手把手教你绘制星空旅游线路图
0 前言 5月是美国的毕业季,我家领导也即将毕业了,我们将在美国进行为期两周的毕业旅行.其实类似这样的航线图我以前也用PPT绘制过,给领导用于发朋友圈,虽然总体能表达出意思,但是效果不能让自己满意,见 ...
- python星空代码_用python画星空源代码是什么?
用python画星空源代码是什么? 用python画星空源代码是from turtle import * from random import random,randint screen = Scre ...
- python绘制月亮_用python画月亮的代码是什么?
用python画月亮的代码是什么? 用python画月亮的代码是import turtle as t t.screensize(800,600,"#483d8b")#画布尺寸和颜色 ...
- 用python画月亮的代码-用python画月亮的代码是什么?
用python画月亮的代码是什么? 用python画月亮的代码是import turtle as t t.screensize(800,600,"#483d8b")#画布尺寸和颜色 ...
- python画星空的程序_用python画星空源代码是什么?
用python画星空源代码是什么? 用python画星空源代码是from turtle import * from random import random,randint screen = Scre ...
- python绘制星空_用python画星空源代码是什么?
用python画星空源代码是什么? 用python画星空源代码是from turtle import * from random import random,randint screen = Scre ...
- 用python画星空-用python画星空源代码是什么?
7mr少儿编程网-Scratch_Python_教程_免费儿童编程学习平台 用python画星空源代码是什么?7mr少儿编程网-Scratch_Python_教程_免费儿童编程学习平台 用python ...
- python源代码制作星空_用python画星空源代码是什么?
用python画星空源代码是什么? 用python画星空源代码是 from turtle import *from random import random,randintscreen = Scree ...
最新文章
- oracle lz压缩,LZ:Oracle热备期间过量Redo生成控制
- 深入理解 Linux的 I/O 系统
- 作业三_C#中的观察者模式解析
- ubuntu使用root权限登录的设置方法
- 福昕熊雨前:PDFium开源项目的背后
- lintcode433 岛屿的个数
- mysql用binlog恢复数据_利用mysql的binlog恢复数据
- python回归分析预测模型_在Python中如何使用Keras模型对分类、回归进行预测
- 车险赔付率分析报告_车险综合改革出台:下调附加费用率,三者限额提至千万...
- 垃圾回收机制GC知识再总结兼谈如何用好GC(转)
- python_14 多态,封装,反射
- webgame源码下载及网页游戏开发资源精华集合
- ROON1.8无法找到asio驱动的解决办法
- PDF转ONENOTE的方法
- legion--一款开源,易用,扩展性强的半自动化渗透测试工具
- Angular-路由设置
- 使用Power BI时常见的几个问题(持续更新)
- cordova 微信支付
- Ubuntu 22.04 LTS 是史诗级的版本?
- Blender新手入门试水作品:Low poly版敲击兽