当前位置:网站首页>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
边栏推荐
猜你喜欢

mariadb学习笔记

倍福PLC基于CX5130实现数据的断电保持

C语言:练习题二

Record a phpcms9.6.3 vulnerability to use the getshell to the intranet domain control

Explain C language 10 in detail (C language series)

轻流完成与「DaoCloud Enterprise 云原生应用云平台」兼容性认证

首批通过!百度智能云曦灵平台获信通院数字人能力评测权威认证

倍福PLC实现绝对值编码器原点断电保持---bias的使用
![HDU1724[辛普森公式求积分]Ellipse](/img/57/fb5098e150b5f3d91a5d0983a336ee.png)
HDU1724[辛普森公式求积分]Ellipse

processing 随机生成线动画
随机推荐
Software testing - concept
Beifu PLC passes MC_ Readparameter read configuration parameters of NC axis
单例的常用创建和使用方式
Electron official docs series: Distribution
倍福PLC通过MC_ReadParameter读取NC轴的配置参数
LeetCode_栈_中等_150. 逆波兰表达式求值
Explain C language 10 in detail (C language series)
P5733 【深基6.例1】自动修正
【shell】生成指定日期之间的字符串
Electron official docs series: Examples
UVA5009 Error Curves三分
710. random numbers in the blacklist
P5733 [deep foundation 6. example 1] automatic correction
面试题积累
Solution of Splunk iowait alarm
【Spark】.scala文件在IDEA中几种图标的解释
Electron official docs series: References
详细讲解C语言10(C语言系列)
源码学习:AtomicInteger类代码内部逻辑
National standard gb28181 protocol easygbs video platform TCP active mode streaming exception repair