From: Pete S. <pe...@vi...> - 2000-06-03 01:24:50
|
Peter Nicolai wrote: > you mean integrating NumPy into SDL-specific calls or > something? It would be nice to use this for > generative-art type stuff --p well, i tried porting the SDL demo, XFlame. this just does the standard fire effect creeping up the screen. right now in pysdl, there's no way to go mess with pixels aside from the get_at and put_at. needless to say this is extremely slow. even a 200x150 window of the fire takes a couple seconds each frame. i've been spending time with Numeric, and it should be really simple to make some functions to transfer between surfaces and arrays. once this is done the fire demo should run swift under python. (i would hope) my current design is to add a few functions to the surface objects: get_array(rect) -> array set_array(rect, array) get_array_rgb(rect) -> (array, array, array) set_array_rgb(array, array, array) map_rgb_array(array, array, array) -> array they should be pretty common sense. getting the surface image data as an array of ints, and also the ability to get the array as a set of R, G, B arrays. we'll probably want something for the alpha as well? i am interested in hearing people's ideas of how best to lay this out? perhaps instead of the set_array style functions you are allowed to pass an array as a source for blit() and/or create new surfaces with an array in the constructor? numeric python has a great C-interface, so it should hook into pysdl really easily as well as be very quick. need input |