ccFIshTImehaha 发表于 2021-2-21 15:51:06

Processing Python

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 =
      particles.append(particle)
   
def draw():
    fill(0,10)
    rect(0,0,width,height)
    fill(255)
    for particle in particles:
      noiseValue = noise(0.001*particle,10+0.001*particle,frameCount*0.005)
      particle = map(noiseValue,0,1,-2*PI,2*PI)
      vx = particle*cos(particle)
      vy = particle*sin(particle)
      particle = particle + vx
      particle = particle + vy
    if particle>width or particle>height:
      particle = random(0,width)
      particle = random(0,height)
    circle(particle,particle,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: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 =
      particles.append(particle)
   
def draw():
    fill(0,10)
    rect(0,0,width,height)
    fill(255)
    for particle in particles:
      noiseValue = noise(0.001*particle,10+0.001*particle,frameCount*0.005)
      particle = map(noiseValue,0,1,-2*PI,2*PI)
      vx = particle*cos(particle)
      vy = particle*sin(particle)
      particle = particle + vx
      particle = particle + vy
    if particle>width or particle>height:
      particle = random(0,width)
      particle = random(0,height)
    circle(particle,particle,2)

青出于蓝 发表于 2021-2-21 16:09:14

'range' needs two values
Sorry,I am not good at speaking English

青出于蓝 发表于 2021-2-21 16:13:30

Please agree to my friend request
If you has any questions,welcome to ask me
页: [1]
查看完整版本: Processing Python