having a ton of issues, I’ll try to post as much detail as possible.
py -3 .\0-original.py .\logo.png
File "C:\Users\anthony\source\github\PixelBlaze\PixelBlaze\Patterns\POV Patterns\renderingImages\py\0-original.py", line 45
print("// Image #%u (%ux%u) generated from '%s'" % \ ^
SyntaxError: unexpected character after line continuation character
resolution: remove the backslash, and put these two lines all on one line of code
File "C:\Users\anthony\source\github\PixelBlaze\PixelBlaze\Patterns\POV Patterns\renderingImages\py\0-original.py", line 64
_a = 0 // TBD: figure out where transparency is stored
^
SyntaxError: invalid syntax
resolution: remove the //TBD etc.
File "C:\Users\anthony\source\github\PixelBlaze\PixelBlaze\Patterns\POV Patterns\renderingImages\py\0-original.py", line 2, in <module>
from PIL import Image
ModuleNotFoundError: No module named 'PIL'
PIL is for python 2, I'm using python 3 (which should use PILLOW). Switch to python 2
py -2 .\0-original.py .\logo.png
File ".\0-original.py", line 67
print(' ', end='')
^
SyntaxError: invalid syntax
https://stackoverflow.com/questions/2456148/getting-syntaxerror-for-print-with-keyword-argument-end
The correct idiom in Python 2.x for end=" " is:
print "foo" % bar,
(note the final comma, this makes it end the line with a space rather than a linebreak)
resolution:
change
print(' ', end='')
to
print ' ',
File ".\1-edited.py", line 68
print("putPixel(%u,%u,%u,%u,packRGBA(0x%02x,0x%02x,0x%02x,0x%02x)); " % (iterImage, iterFrame, iterRow, iterCol, _r, _g, _b, _a), end='')
^
SyntaxError: invalid syntax
resolution: repeat above
py -2 .\1-edited.py .\logo.png
now outputs code to screen
py -2 .\1-edited.py .\logo.png > code.js
Paste code.js into Edit tab of PixelBlaze
no valid render function found
makes sense, this pattern only has render2D, my poi is 1d
replace rendering functions section with code below
// Rendering functions
var col = 0;
dimension = sqrt(pixelCount);
export function beforeRender(delta){
col = (col+1) % dimension;
}
export function render(index) {
row = trunc(index * dimension);
pixval = getPixel(0, 0, row, col);
r = _r(pixval)/255;
g = _g(pixval)/255;
b = _b(pixval)/255;
rgb(r*r,g*g,b*b);
}
export function render2D(index, x, y) {
row = trunc(x * dimension);
col = trunc(y * dimension);
pixval = getPixel(0, 0, row, col);
r = _r(pixval)/255;
g = _g(pixval)/255;
b = _b(pixval)/255;
rgb(r*r,g*g,b*b);
}
// Image storage
no valid render function found
thinking at this point maybe I had too many pixels in my 50px50px bitmap logo for pixelblaze to parse, I reduced the image size to 10px10px
py -2 .\1-edited.py .\logo_10px.png > code_10px.js
paste code_10px.js into pixelblaze edit tab
error: array out of bounds
at line: function getPixel(image, frame, row, column) { return _images[image][frame][row][column]; }
Here’s my entire code file:
// Image helpers
function numImages() { return _images.length; }
function numFrames(image) { return _images[image].length; }
function numRows(image, frame) { return _images[image][frame].length; }
function numColumns(image, frame) { return _images[image][frame][0].length; }
// Pixel helpers
function putPixel(image, frame, row, column, value) { _images[image][frame][row][column] = value; }
function getPixel(image, frame, row, column) { return _images[image][frame][row][column]; }
function packRGBA(r, g, b, a) { return (r << 8) + g + (b >> 8) + (a >> 16); }
function _r(pixval) { return ((pixval >> 8) & 0xff) >> 8; }
function _g(pixval) { return ((pixval) & 0xff) >> 8; }
function _b(pixval) { return ((pixval << 8) & 0xff) >> 8; }
function _a(pixval) { return ((pixval << 16) & 0xff) >> 8; }
// Rendering functions
var col = 0;
dimension = sqrt(pixelCount);
export function beforeRender(delta){
col = (col+1) % dimension;
}
export function render(index) {
row = trunc(index * dimension);
pixval = getPixel(0, 0, row, col);
r = _r(pixval)/255;
g = _g(pixval)/255;
b = _b(pixval)/255;
rgb(r*r,g*g,b*b);
}
export function render2D(index, x, y) {
row = trunc(x * dimension);
col = trunc(y * dimension);
pixval = getPixel(0, 0, row, col);
r = _r(pixval)/255;
g = _g(pixval)/255;
b = _b(pixval)/255;
rgb(r*r,g*g,b*b);
}
// Image storage
var _images = array(1); // allocate image storage
// Image #0 (10x10) generated from '.\logo_small.png'
//getImage(0) = array(1); // allocate frame storage
_images[0] = array(1); // allocate frame storage
// Frame #0
_images[0][0] = array(10); // allocate row storage
// Row #0:
_images[0][0][0] = array(10); // allocate column storage
putPixel(0,0,0,0,packRGBA(0x00,0x00,0x00,0x00)); putPixel(0,0,0,1,packRGBA(0xc1,0x19,0x20,0x00)); putPixel(0,0,0,2,packRGBA(0x00,0x00,0x00,0x00));
putPixel(0,0,0,3,packRGBA(0x3d,0x09,0x0b,0x00)); putPixel(0,0,0,4,packRGBA(0xd3,0x1c,0x24,0x00)); putPixel(0,0,0,5,packRGBA(0x00,0x00,0x00,0x00));
putPixel(0,0,0,6,packRGBA(0x6d,0x0e,0x12,0x00)); putPixel(0,0,0,7,packRGBA(0x54,0x0b,0x0e,0x00)); putPixel(0,0,0,8,packRGBA(0x00,0x00,0x00,0x00));
putPixel(0,0,0,9,packRGBA(0x10,0x0a,0x00,0x00)); // end Row #0
// Row #1:
_images[0][0][1] = array(10); // allocate column storage
putPixel(0,0,1,0,packRGBA(0x00,0x00,0x00,0x00)); putPixel(0,0,1,1,packRGBA(0x1e,0x04,0x05,0x00)); putPixel(0,0,1,2,packRGBA(0xa6,0x16,0x1c,0x00));
putPixel(0,0,1,3,packRGBA(0xae,0x16,0x1c,0x00)); putPixel(0,0,1,4,packRGBA(0x87,0x12,0x17,0x00)); putPixel(0,0,1,5,packRGBA(0x69,0x0d,0x11,0x00));
putPixel(0,0,1,6,packRGBA(0xb8,0x18,0x1e,0x00)); putPixel(0,0,1,7,packRGBA(0x00,0x00,0x00,0x00)); putPixel(0,0,1,8,packRGBA(0x00,0x00,0x00,0x00));
putPixel(0,0,1,9,packRGBA(0x00,0x00,0x00,0x00)); // end Row #1
// Row #2:
_images[0][0][2] = array(10); // allocate column storage
putPixel(0,0,2,0,packRGBA(0x00,0x00,0x00,0x00)); putPixel(0,0,2,1,packRGBA(0x00,0x00,0x00,0x00)); putPixel(0,0,2,2,packRGBA(0x9a,0x13,0x19,0x00));
putPixel(0,0,2,3,packRGBA(0x77,0x10,0x14,0x00)); putPixel(0,0,2,4,packRGBA(0xe1,0x1c,0x24,0x00)); putPixel(0,0,2,5,packRGBA(0xae,0x17,0x1d,0x00));
putPixel(0,0,2,6,packRGBA(0x1b,0x03,0x04,0x00)); putPixel(0,0,2,7,packRGBA(0x00,0x00,0x00,0x00)); putPixel(0,0,2,8,packRGBA(0x00,0x00,0x00,0x00));
putPixel(0,0,2,9,packRGBA(0x00,0x00,0x00,0x00)); // end Row #2
// Row #3:
_images[0][0][3] = array(10); // allocate column storage
putPixel(0,0,3,0,packRGBA(0x00,0x00,0x00,0x00)); putPixel(0,0,3,1,packRGBA(0x00,0x00,0x00,0x00)); putPixel(0,0,3,2,packRGBA(0x00,0x00,0x00,0x00));
putPixel(0,0,3,3,packRGBA(0xbb,0x17,0x1f,0x00)); putPixel(0,0,3,4,packRGBA(0x00,0x00,0x00,0x00)); putPixel(0,0,3,5,packRGBA(0xb2,0x16,0x1d,0x00));
putPixel(0,0,3,6,packRGBA(0x00,0x00,0x00,0x00)); putPixel(0,0,3,7,packRGBA(0x00,0x00,0x00,0x00)); putPixel(0,0,3,8,packRGBA(0x00,0x00,0x00,0x00));
putPixel(0,0,3,9,packRGBA(0x00,0x00,0x00,0x00)); // end Row #3
// Row #4:
_images[0][0][4] = array(10); // allocate column storage
putPixel(0,0,4,0,packRGBA(0x00,0x00,0x00,0x00)); putPixel(0,0,4,1,packRGBA(0x00,0x00,0x00,0x00)); putPixel(0,0,4,2,packRGBA(0x00,0x00,0x00,0x00));
putPixel(0,0,4,3,packRGBA(0x8e,0x12,0x17,0x00)); putPixel(0,0,4,4,packRGBA(0x5a,0x0b,0x0f,0x00)); putPixel(0,0,4,5,packRGBA(0x36,0x07,0x09,0x00));
putPixel(0,0,4,6,packRGBA(0x00,0x00,0x00,0x00)); putPixel(0,0,4,7,packRGBA(0x00,0x00,0x00,0x00)); putPixel(0,0,4,8,packRGBA(0x00,0x00,0x00,0x00));
putPixel(0,0,4,9,packRGBA(0x00,0x00,0x00,0x00)); // end Row #4
// Row #5:
_images[0][0][5] = array(10); // allocate column storage
putPixel(0,0,5,0,packRGBA(0x00,0x00,0x00,0x00)); putPixel(0,0,5,1,packRGBA(0x00,0x00,0x00,0x00)); putPixel(0,0,5,2,packRGBA(0x00,0x00,0x00,0x00));
putPixel(0,0,5,3,packRGBA(0x89,0x11,0x16,0x00)); putPixel(0,0,5,4,packRGBA(0x61,0x0d,0x0f,0x00)); putPixel(0,0,5,5,packRGBA(0x32,0x06,0x08,0x00));
putPixel(0,0,5,6,packRGBA(0x00,0x00,0x00,0x00)); putPixel(0,0,5,7,packRGBA(0x00,0x00,0x00,0x00)); putPixel(0,0,5,8,packRGBA(0x00,0x00,0x00,0x00));
putPixel(0,0,5,9,packRGBA(0x00,0x00,0x00,0x00)); // end Row #5
// Row #6:
_images[0][0][6] = array(10); // allocate column storage
putPixel(0,0,6,0,packRGBA(0x00,0x00,0x00,0x00)); putPixel(0,0,6,1,packRGBA(0x00,0x00,0x00,0x00)); putPixel(0,0,6,2,packRGBA(0x00,0x00,0x00,0x00));
putPixel(0,0,6,3,packRGBA(0xb5,0x16,0x1d,0x00)); putPixel(0,0,6,4,packRGBA(0x17,0x03,0x04,0x00)); putPixel(0,0,6,5,packRGBA(0x7d,0x0f,0x13,0x00));
putPixel(0,0,6,6,packRGBA(0x00,0x00,0x00,0x00)); putPixel(0,0,6,7,packRGBA(0x00,0x00,0x00,0x00)); putPixel(0,0,6,8,packRGBA(0x00,0x00,0x00,0x00));
putPixel(0,0,6,9,packRGBA(0x00,0x00,0x00,0x00)); // end Row #6
// Row #7:
_images[0][0][7] = array(10); // allocate column storage
putPixel(0,0,7,0,packRGBA(0x00,0x00,0x00,0x00)); putPixel(0,0,7,1,packRGBA(0x00,0x00,0x00,0x00)); putPixel(0,0,7,2,packRGBA(0x10,0x02,0x02,0x00));
putPixel(0,0,7,3,packRGBA(0xad,0x15,0x1d,0x00)); putPixel(0,0,7,4,packRGBA(0x00,0x00,0x00,0x00)); putPixel(0,0,7,5,packRGBA(0xd0,0x1a,0x22,0x00));
putPixel(0,0,7,6,packRGBA(0x00,0x00,0x00,0x00)); putPixel(0,0,7,7,packRGBA(0x00,0x00,0x00,0x00)); putPixel(0,0,7,8,packRGBA(0x00,0x00,0x00,0x00));
putPixel(0,0,7,9,packRGBA(0x00,0x00,0x00,0x00)); // end Row #7
// Row #8:
_images[0][0][8] = array(10); // allocate column storage
putPixel(0,0,8,0,packRGBA(0x00,0x00,0x00,0x00)); putPixel(0,0,8,1,packRGBA(0x00,0x00,0x00,0x00)); putPixel(0,0,8,2,packRGBA(0x9c,0x13,0x19,0x00));
putPixel(0,0,8,3,packRGBA(0x39,0x08,0x0a,0x00)); putPixel(0,0,8,4,packRGBA(0x00,0x00,0x00,0x00)); putPixel(0,0,8,5,packRGBA(0xbc,0x18,0x20,0x00));
putPixel(0,0,8,6,packRGBA(0x1b,0x03,0x04,0x00)); putPixel(0,0,8,7,packRGBA(0x00,0x00,0x00,0x00)); putPixel(0,0,8,8,packRGBA(0x00,0x00,0x00,0x00));
putPixel(0,0,8,9,packRGBA(0x00,0x00,0x00,0x00)); // end Row #8
// Row #9:
_images[0][0][9] = array(10); // allocate column storage
putPixel(0,0,9,0,packRGBA(0x00,0x00,0x00,0x00)); putPixel(0,0,9,1,packRGBA(0x00,0x00,0x00,0x00)); putPixel(0,0,9,2,packRGBA(0xc1,0x19,0x21,0x00));
putPixel(0,0,9,3,packRGBA(0x00,0x00,0x00,0x00)); putPixel(0,0,9,4,packRGBA(0x00,0x00,0x00,0x00)); putPixel(0,0,9,5,packRGBA(0x30,0x06,0x08,0x00));
putPixel(0,0,9,6,packRGBA(0x7e,0x10,0x15,0x00)); putPixel(0,0,9,7,packRGBA(0x00,0x00,0x00,0x00)); putPixel(0,0,9,8,packRGBA(0x00,0x00,0x00,0x00));
putPixel(0,0,9,9,packRGBA(0x00,0x00,0x00,0x00)); // end Row #9
// end Frame #0
// end Image #0