This is a template script for Blender, it creates a new image and plots its pixels using Python.
This is useful if you need to create any kind of data-texture to use with a real-time shader, among other uses.
You're dealing with raw pixels so you can code exactly how those pixels should be generated: you can use mathematical formulas, load any files and use that data w/ color algorithms etc.
How to use
Then press the Run Script button on the Text Editor header. It should
create the image seen in that picture -- it's a simple formula, just mapping the X and Y coordinates of each pixel to their red and green channels.
You need to modify the code in the generatePixels()
function to do what you want. That's where it loops through each X and Y unit and you yield a new pixel. The pixel format is R,G,B,A and the channels use floating point values from 0.0 to 1.0.
Note that if you create images larger than
4096px the script might take a while to finish, like from 30 seconds up
depending on your CPU.
(I posted this same thread in Blenderartists.)