当前位置:网站首页>Processing 多面体变化
Processing 多面体变化
2022-06-26 12:37:00 【天人合一peng】
SimpleFrom.py
class Form:
def __init__(self, x, y, r): # Constructor
self.x = x; self.y = y # Set x and y position
self.rad = r # Set radius
self.x_speed = random(-2, 2) # Set random x speed
self.y_speed = random(-2, 2) # Set random y speed
# self.x_speed = random(-10, 10) # Set random x speed
# self.y_speed = random(-10, 10) # Set random y speed
def update_me(self):
self.x = (self.x + self.x_speed) % width # Moves x and wrap
self.y = (self.y + self.y_speed) % height # Moves y and wrap
def draw_me(self):
stroke(200)
point(self.x, self.y) # Draw a dot
noStroke(); fill(200,50)
ellipse(self.x, self.y, self.rad, self.rad) # Draw a circle
def line_to(self, other):
stroke(200)
line(self.x, self.y, other.x, other.y)运行
from SimpleForm import Form
def setup():
size(600, 600)
background(50)
global forms
forms = []
for i in range(10):
starting_x = width/4 * random(1, 3)
starting_y = height/4 * random(1, 3)
forms.append(Form(starting_x, starting_y, 10))
def draw():
background(50) # Clear the screen each time
for i in range(len(forms)):
forms[i].update_me() # Update the position of each
for a in range(len(forms)):
for b in range(len(forms)):
if a > b: # Prevents lines drawing twice
forms[a].line_to(forms[b])
边栏推荐
猜你喜欢

老司机总结的12条 SQL 优化方案(非常实用)

Comparison of latest mobile phone processors in 2020 (with mobile phone CPU ladder diagram)

.NET MAUI 性能提升

BigInt:处理大数字(任意长度的整数)

初识-软件测试

PHP uses laravel pay component to quickly access wechat jsapi payment (wechat official account payment)

Scala problem solving the problem of slow SBT Download

程序员必备,一款让你提高工作效率N倍的神器uTools

TSMC Samsung will mass produce 3nm chips in 2022: will the iPhone be the first?

国标GB28181协议EasyGBS视频平台TCP主动模式拉流异常情况修复
随机推荐
goto语句实现关机小程序
PHP calculates excel coordinate values, starting with subscript 0
"Pinduoduo and short video speed version", how can I roast!
2022 edition of China's medical robot industry investment status investigation and prospect dynamic analysis report
Software testing - Fundamentals
第十章 设置结构化日志记录(二)
Scala-day03- operators and loop control
Configuring Apache digest authentication
KVM 显卡透传 —— 筑梦之路
Less than 40 lines of code to create a blocprovider
KITTI Tracking dataset whose format is letf_top_right_bottom to JDE normalied xc_yc_w_h
Analysis report on dynamic research and investment planning suggestions of China's laser medical market in 2022
程序员必备,一款让你提高工作效率N倍的神器uTools
面试题积累
洛谷P3426 [POI2005]SZA-Template 题解
记一次phpcms9.6.3漏洞利用getshell到内网域控
老司机总结的12条 SQL 优化方案(非常实用)
power designer - 自定义注释按钮
710. random numbers in the blacklist
计组实践实验9——使用CMStudio设计基于分段模型机微程序指令(2)