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

Re: [pygame] Surfarray Help



Ian Mallett kirjoitti:
The array only needs to be generated once; i.e., the surface is generated once, then done. It doesn't have to be modified, just created.

ok for well for that i have written py functions and given them to the numpy thing that eats them, http://docs.scipy.org/doc/numpy/reference/generated/numpy.fromfunction.html

a random one is numpy.random.rand(320, 200, 3)

like this i think makes some sort of stripes .. wrote that when was learning the system, am now not too sure if that makes sense but it does something succesfully, was just a test, .. but the actual ones am using in that thing are generated in the initialization of the app using that same function defining technique.

def grid_shape_colors(i, j, c):
   x = i % 2 #vert stripes
   y = j % 2 #horiz stripes
   np.logical_and(x, y).astype(float)

.. so passing an array defining function to the lib array generating thing like e.g. this: change = np.fromfunction(grid_shape_colors, (GRIDSIZE[0], GRIDSIZE[1], 3)) #i think i have 3 here 'cause it's rgb.

Ian

~Toni