鱼C论坛

 找回密码
 立即注册
查看: 2467|回复: 3

[已解决]Processing Python

[复制链接]
发表于 2021-2-21 15:51:06 | 显示全部楼层 |阅读模式

马上注册,结交更多好友,享用更多功能^_^

您需要 登录 才可以下载或查看,没有账号?立即注册

x
I am writing processing with python mode these days.
When I run my project as this:
----------------------------------------------------------------------------------------------------
particles = []
def setup():
    size(1024,700)
    noStroke()
    for i in range(1000):
        x = random(0,width)
        y = random(0,height)
        v_mag = random(1.0,2.0)
        v_angle = random(-2*PI,2*PI)
        particle = [x,y,v_mag,v_angle]
        particles.append(particle)
   
def draw():
    fill(0,10)
    rect(0,0,width,height)
    fill(255)
    for particle in particles:
        noiseValue = noise(0.001*particle[0],10+0.001*particle[1],frameCount*0.005)
        particle[3] = map(noiseValue,0,1,-2*PI,2*PI)
        vx = particle[2]*cos(particle[3])
        vy = particle[2]*sin(particle[3])
        particle[0] = particle[0] + vx
        particle[1] = particle[1] + vy
    if particle[0]>width or particle[1]>height:
        particle[0] = random(0,width)
        particle[1] = random(0,height)
    circle(particle[0],particle[1],2)
------------------------------------------------------------------------------------------------------
There is only a particle,not a lot.
but I used 'for i in range(1000):',why does it happened?
Friends who have studied processing, please help me!


最佳答案
2021-2-21 16:09:14
'range' needs two values
Sorry,I am not good at speaking English
小甲鱼最新课程 -> https://ilovefishc.com
回复

使用道具 举报

发表于 2021-2-21 16:07:55 | 显示全部楼层
  1. particles = []
  2. def setup():
  3.     size(1024,700)
  4.     noStroke()
  5.     for i in range(1,1000):
  6.         x = random(0,width)
  7.         y = random(0,height)
  8.         v_mag = random(1.0,2.0)
  9.         v_angle = random(-2*PI,2*PI)
  10.         particle = [x,y,v_mag,v_angle]
  11.         particles.append(particle)
  12.    
  13. def draw():
  14.     fill(0,10)
  15.     rect(0,0,width,height)
  16.     fill(255)
  17.     for particle in particles:
  18.         noiseValue = noise(0.001*particle[0],10+0.001*particle[1],frameCount*0.005)
  19.         particle[3] = map(noiseValue,0,1,-2*PI,2*PI)
  20.         vx = particle[2]*cos(particle[3])
  21.         vy = particle[2]*sin(particle[3])
  22.         particle[0] = particle[0] + vx
  23.         particle[1] = particle[1] + vy
  24.     if particle[0]>width or particle[1]>height:
  25.         particle[0] = random(0,width)
  26.         particle[1] = random(0,height)
  27.     circle(particle[0],particle[1],2)
复制代码
小甲鱼最新课程 -> https://ilovefishc.com
回复 支持 反对

使用道具 举报

发表于 2021-2-21 16:09:14 | 显示全部楼层    本楼为最佳答案   
'range' needs two values
Sorry,I am not good at speaking English
小甲鱼最新课程 -> https://ilovefishc.com
回复 支持 反对

使用道具 举报

发表于 2021-2-21 16:13:30 | 显示全部楼层
Please agree to my friend request
If you has any questions,welcome to ask me
小甲鱼最新课程 -> https://ilovefishc.com
回复 支持 反对

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

小黑屋|手机版|Archiver|鱼C工作室 ( 粤ICP备18085999号-1 | 粤公网安备 44051102000585号)

GMT+8, 2025-6-27 13:56

Powered by Discuz! X3.4

© 2001-2023 Discuz! Team.

快速回复 返回顶部 返回列表