当前位置:网站首页>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])
边栏推荐
- Learning directory
- 710. 黑名单中的随机数
- 做自媒体视频的各种常用工具合集奉上
- Redis learning - 03 transaction
- TP5 thinkphp5 report serialization of'closure'is not allowed
- 软件测试 - 基础篇
- 详细实操分享,下班刷了两小时的搞笑视频,一个月收益7000多
- 深度解析当贝盒子B3、腾讯极光5S、小米盒子4S之间的区别
- Xiaobai lazy special-win10-win11 one click installation version
- Research and development practice of Kwai real-time data warehouse support system
猜你喜欢
Adobe Acrobat阻止30款安全软件查看PDF文件 或存在安全风险

Scala-day03- operators and loop control

TP5 thinkphp5 report serialization of'closure'is not allowed
![[BSidesCF 2019]Kookie 1](/img/22/585d081668e67b8389a1b90aaebe9d.png)
[BSidesCF 2019]Kookie 1
![[solved] data duplication or data loss after laravel paginate() paging](/img/68/7bf51bbf893a91bee24f5f7d4a369f.jpg)
[solved] data duplication or data loss after laravel paginate() paging

Xiaobai lazy special-win10-win11 one click installation version

Spark-day03-core programming RDD operator

Several rare but useful JS techniques

【Spark】.scala文件在IDEA中几种图标的解释

Comparison of latest mobile phone processors in 2020 (with mobile phone CPU ladder diagram)
随机推荐
使用SSH密钥对登陆服务器
计组实践实验9——使用CMStudio设计基于分段模型机微程序指令(2)
TP5 thinkphp5 report serialization of'closure'is not allowed
[solved] laravel completes the scheduled job task (delayed distribution task) [execute a user-defined task at a specified time]
KVM 显卡透传 —— 筑梦之路
【网络是怎么连接的】第二章(下):一个网络包的接收
Analysis report on dynamic research and investment planning suggestions of China's laser medical market in 2022
Echart堆叠柱状图:色块之间添加白色间距效果设置
MySQL optimization - index (what is an index?)
Splunk iowait 报警的解决
Laravel+gatewayworker completes the im instant messaging and file transfer functions (Chapter 4: server debugging errors)
Tiger DAO VC产品正式上线,Seektiger生态的有力补充
【Spark】.scala文件在IDEA中几种图标的解释
el-form-item 包含两个input, 校验这两个input
Scala-day06- pattern matching - Generic
Learning directory
KITTI Tracking dataset whose format is letf_top_right_bottom to JDE normalied xc_yc_w_h
Implementing mixins scheme in applet
美学心得(第二百三十八集) 罗国正
New routing file in laravel framework