[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

Re: [pygame] Surfarray Help



Ian Mallett kirjoitti:
The values range from 0.0 to 3.0, starting with 0.0 at one corner and ending at 3.0 in the opposite, increasing going row by row. The value is to be encoded in each color. Because this is somewhat abstract, here's a small example (n=25), generated using the attached

ok,

code (it also multiplies the number by 255 to obtain a RGB color). The real version should be done by surfarray. This is where I need help; I have no idea how to even approach the problem.

i did recently this, http://playsign.fi/an/programming/browser/colorgrid/surfarray.py
- dunno if something there might be helpful as an example.

also there i'm manipulating rgb values, there to cycle colours with each pixel having an individual 'change vector', and the system ping-ponging values back-and-forth between 0 and 255.

i'm not generating new arrays per-frame, just applying an existing 'change map' to the current image.

[[  0,  0,  0],[ 32,  0,  0],[ 64,  0,  0],[ 96,  0,  0],[128,  0,  0],
Arrays like this need to be generated quite quickly, so the per-pixel method I presented will not work. How should I do it with surfarray?

seems easy enough, granted i'm not absolutely sure what you mean by 'generating' .. applying that simple algo / operation to some array you have to get a new version / the data modified?

Ian

~Toni