当前位置:网站首页>Processing random generation line animation
Processing random generation line animation
2022-06-26 13:05:00 【Harmony between man and nature Peng】
def setup():
size(600, 600)
background(50)
def draw():
draw_me_a_line()
def draw_me_a_line(colour=200):
stroke(colour)
line(random(width), random(height),
random(width), random(height))

SimpleForm.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(-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)
circle(self.x, self.y, self.rad) # Draw a circle
def line_to(self, other):
stroke(200)
line(self.x, self.y, other.x, other.y)function
from SimpleForm import Form
def setup():
size(600, 600)
background(50)
global f1, f2 # Make f1 and f2 visible
f1 = Form(random(width), random(height), 10)
f2 = Form(random(width), random(height), 10)
def draw():
f1.update_me() # Update f1 position
f2.update_me() # Update f2 position
f1.draw_me() # Draw f1
f2.draw_me() # Draw f2
f1.line_to(f2) # Draw line from f1 to f2
边栏推荐
- 文件远程同步、备份神器rsync
- 软件测试报告应该包含的内容?面试必问
- HDU 5860
- Group counting practice experiment 9 -- using cmstudio to design microprogram instructions based on segment model machine (2)
- Photoshop 2022 23.4.1增加了哪些功能?有知道的吗
- Solution of Splunk iowait alarm
- Electron official docs series: Contributing
- EasyGBS如何解决对讲功能使用异常?
- Typescript
- Echart堆叠柱状图:色块之间添加白色间距效果设置
猜你喜欢
随机推荐
倍福PLC通过程序获取系统时间、本地时间、当前时区以及系统时间时区转换
Electron official docs series: Contributing
ES6:迭代器
OPLG: 新一代云原生可观测最佳实践
倍福将EtherCAT模块分到多个同步单元运行--Sync Units的使用
解中小企业之困,百度智能云打个样
openlayers 绘制动态迁徙线、曲线
使用SSH密钥对登陆服务器
postgis计算角度
PostGIS geographic function
[BSidesCF 2019]Kookie 1
记一次phpcms9.6.3漏洞利用getshell到内网域控
【shell】生成指定日期之间的字符串
E - Apple Catching
KVM 显卡透传 —— 筑梦之路
. Net Maui performance improvement
Electron official docs series: Examples
首批通过!百度智能云曦灵平台获信通院数字人能力评测权威认证
postgis 地理化函数
文件远程同步、备份神器rsync








