I’m working on putting together a map. My application is a long table, with a backboard (sideboard) on one side. My eventual goal is to use the sensor on the pixelblaze v3 sensor board to react to the direction that the table is tapped.
It seems that the preview in the map section doesn’t always display the code that is pasted into it. I assume this occurs when there is an error in the code.
As a starting point, I referenced the rectangle example:
function (pixelCount) {
function line(x, y, dx, dy, count) {
var line = [];
for (var i = 0; i < count; i++) {
line.push([x + dx * i, y + dy * i]);
}
return line;
}
var map = [];
// start at 0,0, move 1,0 for each pixel, 152 pixels
map = map.concat(line(0,0, 1, 0, 152))
//then moving down, assuming 1 pixel from above counts toward the 38 tall
// start at 152,1, move 0,1 for each pixel, 36 pixels
map = map.concat(line(152,1, 0, 1, 36))
//then from the bottom right to bottom left
map = map.concat(line(152, 37, -1, 0, 152))
//and back up
map = map.concat(line(0, 36, 0, -1, 36))
return map;
}
and the walled cube example to infer that the z-axis is inferred by simply adding an extra parameter to the array. I’m not sure this is true. Also, looking through the example codes, I’m not sure if semicolons are important in this language or not - sometimes they are there, sometimes they aren’t.
My map code is:
function (pixelCount) {
width = 55
lenght = 60
height = 30
// generate wireframe of tabletop with backboard
// a 3d adaptation of the 2d line function
// x, y, z is the starting position
// dx, dy, dz is how far each step is, 0=no movement, 1=move in positive direction, -1=move in negative direction
// count is the number of steps
function line (x, y, z, dx, dy, dz, count) {
var line = [];
for (var i = 0; i < count; i++) {
line.push([x + dx * i, y + dy * i, z + dz * i]);
}
return line;
}
var map = []
// start at 0,0, move 1,0 for each pixel, lengthPixels
// first long side of tabletop]
map = map.concat(line(0,0, 0, 1, 0, 0, length))
//then moving down, assuming 1 pixel from above counts toward the widthPixels
// start at lengthPixel,1, move 0,1 for each pixel, widthPixels
// short, back side of tabletop
map = map.concat(line(length,1, 0, 0, 1, 0, width))
//then from the bottom right to bottom left
//second long side of tabletop
map = map.concat(line(length, width, 0, -1, 0, 0, length))
//vertical leg up backboard
map = map.concat(line(0, width, 0, 0, 0, 1, height))
//second short side of tabletop, at higher *height
map = map.concat(line(0, width, height, 0, -1, 0, width))
// vertical leg down backboard
map = map.concat(line(0, 0, height, 0, 0, -1, 0))
return map;
}
(I recognize the code will have some duplicated pixels - I stripped out my embedded math to try and troubleshoot this lack of displaying)
Given that the demo is not displaying, I imagine there is a problem here.
Are there any obvious problems with this?
Thanks!