You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
In Processing you can use the get() method on an image, or the sketch to obtain the colour value of a particular pixel. This also works in p5js.
In p5py you can access the colour value of a pixel in an image by indexing into it as an array e.g: color = image_name[10,10] but I can't see how you do this on the sketch to obtain the colour of a pixel.
It would be great if there was a get() method that could be called which would return the colour value of a pixel in the sketch.
This would also return the colour value of a shape that was present in the sketch at that coordinate.
I've tried to create the same behaviour using the load_pixels() method but it doesn't appear to work as I would expect.
If there is no image present in the sketch it just returns the background colour. It ignores any shapes drawn in the sketch and also clears them from the sketch.
As a very simple example of what I mean in Processing and p5js (in a draw() function) the following works:
Simply retrieving that background colour and then the white of a rectangle and drawing another rectangle with the appropriate colour. I can't see how to do this in p5py.
I can see the _get_pixel method in the image class so presumably adding a get() method that forwards on to that would be fairly straightforward. I don't know how it would work for the whole sketch though.
The text was updated successfully, but these errors were encountered:
In Processing you can use the
get()
method on an image, or the sketch to obtain the colour value of a particular pixel. This also works in p5js.In p5py you can access the colour value of a pixel in an image by indexing into it as an array e.g:
color = image_name[10,10]
but I can't see how you do this on the sketch to obtain the colour of a pixel.It would be great if there was a
get()
method that could be called which would return the colour value of a pixel in the sketch.This would also return the colour value of a shape that was present in the sketch at that coordinate.
I've tried to create the same behaviour using the
load_pixels()
method but it doesn't appear to work as I would expect.If there is no image present in the sketch it just returns the background colour. It ignores any shapes drawn in the sketch and also clears them from the sketch.
As a very simple example of what I mean in Processing and p5js (in a
draw()
function) the following works:Simply retrieving that background colour and then the white of a rectangle and drawing another rectangle with the appropriate colour. I can't see how to do this in p5py.
I can see the
_get_pixel
method in the image class so presumably adding aget()
method that forwards on to that would be fairly straightforward. I don't know how it would work for the whole sketch though.The text was updated successfully, but these errors were encountered: