鱼C论坛

 找回密码
 立即注册
查看: 2061|回复: 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
想知道小甲鱼最近在做啥?请访问 -> ilovefishc.com
回复

使用道具 举报

发表于 2021-2-21 16:07:55 | 显示全部楼层
particles = []
def setup():
    size(1024,700)
    noStroke()
    for i in range(1,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)
想知道小甲鱼最近在做啥?请访问 -> ilovefishc.com
回复 支持 反对

使用道具 举报

发表于 2021-2-21 16:09:14 | 显示全部楼层    本楼为最佳答案   
'range' needs two values
Sorry,I am not good at speaking English
想知道小甲鱼最近在做啥?请访问 -> ilovefishc.com
回复 支持 反对

使用道具 举报

发表于 2021-2-21 16:13:30 | 显示全部楼层
Please agree to my friend request
If you has any questions,welcome to ask me
想知道小甲鱼最近在做啥?请访问 -> ilovefishc.com
回复 支持 反对

使用道具 举报

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

本版积分规则

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

GMT+8, 2025-1-16 10:50

Powered by Discuz! X3.4

© 2001-2023 Discuz! Team.

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