I'm trying to draw functions and graphs using generators in Python (2.7.9), and found a problem: I can't flush my generated pixel data (RGB tuples) into a Pygame Pixel array. Here's my code (which i tryied to run):
using 2d arrays
pixArr = pygame.PixelArray(surface) pixArr=[[(0,0,function(x,y)) for x in range(1,screenX)] for y in range(1,screeny)] del pixArr
Here i've realized that pixArr isn't a ordinary 2d list becouse of my failure to output it (print pixArr)
Then i've tryied using range
pixArr[0:screenX*screenY] = [(0,0,function(curPix%screenX, curPix//screenY)) for curPix in range(0,screenX*screenY)]
I've found something like this code on pygame website HERE, but it gives me error "ValueError: sequence size mismatch", after playing around with it became clear that it works only with a single color (for example pixArr[0:screenX*screenY]=(0,0,255) colors the whole screen blue)
TL;DR: How can I set each pixel without using loops
For y in range(0,1000):
For x in range(0,1000):
gfx.draw(surface,x,y,(0,0,function(a,b))) #or pixArr in this line