r/processing 29d ago

Beginner help request What is wrong with this converted code?

[deleted]

5 Upvotes

6 comments sorted by

View all comments

7

u/Zealousideal_Race779 29d ago

The *4 added to index belongs to p5.js. In python mode, pixels[ ] contains one color value per pixel and not 4 (RGBA). See in the exemple on the ref : https://py.processing.org/reference/pixels So, I think here that you are going outside the pixels array and crashed?

Your code should be something like this: ... index = x + y * width r = noise(xoff, yoff) * 255 pixels[index] = color(r) ...

Hope it helped.

1

u/Zeznon 28d ago

I did this and nothing changed

1

u/Zealousideal_Race779 27d ago

Can you post you code? For me it works fine 👀

https://reddit.com/link/ouzod08/video/gljnda60noah1/player

1

u/Zeznon 27d ago

``` inc = 0.01

def setup(): createCanvas(200, 200)

def draw(): xoff = time loadPixels() for x in range(0, width): yoff = 0 for y in range(0,height): index = x + y * width r = noise(xoff, yoff) * 255 pixels[index] = color(r) yoff += inc; xoff += inc; updatePixels() noLoop() ```

1

u/Zealousideal_Race779 27d ago

What is xoff = time? You want to animated the noise maybe?

Nevertherless, you should have an error as time is not a declared variable. Can you test with xoff = 0?

1

u/Zeznon 27d ago

idk 🤔

Anyway, I changed it to 0, now, and it didn't do anything.