当前位置:网站首页>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
边栏推荐
- Vivado 错误代码 [DRC PDCN-2721] 解决
- 倍福PLC选型--如何看电机是多圈绝对值还是单圈绝对值编码器
- G - Cow Bowling
- [BSidesCF 2019]Kookie 1
- 首批通过!百度智能云曦灵平台获信通院数字人能力评测权威认证
- 倍福EtherCAT Xml描述文件更新和下载
- 倍福TwinCAT3实现CSV、TXT文件读写操作
- Explain C language 11 in detail (C language series)
- 【网络是怎么连接的】第二章(中):一个网络包的发出
- System tasks (display / print class) in Verilog - $display, $write, $strobe, $monitor
猜你喜欢

5月产品升级观察站

Beifu PLC passes MC_ Readparameter read configuration parameters of NC axis

The El form item contains two inputs. Verify the two inputs
![HDU1724[辛普森公式求积分]Ellipse](/img/57/fb5098e150b5f3d91a5d0983a336ee.png)
HDU1724[辛普森公式求积分]Ellipse

Deep parsing MySQL binlog

EasyGBS如何解决对讲功能使用异常?

自动化测试的局限性你知道吗?

P5733 【深基6.例1】自动修正

Explain C language 10 in detail (C language series)

OPLG: 新一代云原生可观测最佳实践
随机推荐
Deep parsing MySQL binlog
Unit practice experiment 8 - using cmstudio to design microprogram instructions based on basic model machine (1)
File remote synchronization and backup artifact Rsync
机器学习笔记 - 时间序列的季节性
D - 滑雪
postgis计算角度
E - Apple Catching
Group counting practice experiment 9 -- using cmstudio to design microprogram instructions based on segment model machine (2)
倍福PLC基于NT_Shutdown实现控制器自动关机重启
第01章_Linux下MySQL的安装与使用
zoopeeper设置acl权限控制(只允许特定ip访问,加强安全)
Accumulation of interview questions
第十章 设置结构化日志记录(二)
倍福CX5130换卡对已有的授权文件转移操作
Openlayers drawing dynamic migration lines and curves
Learning Processing Zoog
[BSidesCF 2019]Kookie 1
[esp32-C3][RT-THREAD] 基于ESP32C3运行RT-THREAD bsp最小系统
黑马笔记---常用API
Processing 多面体变化