# Doom Fire (v2.0) 2D question

@zranger1

Hi Jon,

I am trying to run Doom Fire (v2.0) 2D pattern in order to simulate virtual fireplace.
It runs very well on the default 16x16 matrix (except for the very top row of LEDs (index 0 to 15) is always inactive, not a big deal but a bit strange). However I cannot run this pattern correctly on the 16x32 matrix comprised from 2 serially connected 8x32 and staggered vertically. Pattern actually runs but somewhat oriented vertically like matrix is 32x16 (rotated 90 degree). Also changing width and height parameters seems to have no any effect:

// display size - enter the dimensions of your display here
var width = 32;
var height = 16;

I guess, matrix mapping is correct because test pattern “Red_Green_XY_2D_Sweep” runs correctly.
Just in case here is current mapping:

``````function (pixelCount) {
//set zigzag to true if every other LED row travels in reverse
//if they are all straight across, set it to false
zigzag = true

//rotate a point (x, y), along a center (cx, cy), by an angle in degrees
function rotate(cx, cy, x, y, angle) {
var radians = (Math.PI / 180) * angle,
nx = (cos * (x - cx)) + (sin * (y - cy)) + cx,
ny = (cos * (y - cy)) - (sin * (x - cx)) + cy;
return [nx, ny];
}

//create a set of coordinates for a matrix panel
//sized (w, h), rotated by an angle, and offset by (sx, sy)
function panel(w, h, sx, sy, angle) {
var x, x2, y, p, map = []
for (y = 0; y < h; y++) {
for (x = 0; x < w; x++) {
//for zigzag, flip direction every other row
if (zigzag && y % 2 == 1)
x2 = w - 1 - x
else
x2 = x
p = rotate((w-1)/2, (h-1)/2, x2, y, angle);
p[0] += sx
p[1] += sy
map.push(p)
}
}
return map;
}

//assemble one or more panels
var map = [];

map = map.concat(panel(8, 32, 0, 0, 0))
map = map.concat(panel(8, 32, 8, 0, 0))
//  map = map.concat(panel(8, 8, 0, 8, 0))
//  map = map.concat(panel(8, 8, 8, 8, 0))

return map
}
``````

Actually physical layout for the 16x16 and 8x32 matrix is very different and this could be part of a problem. Index-0 for the 16x16 matrix is in the upper right corner and than zigzagged right-to-left and top-to-bottom. For the 8x32 matrix Index-0 is in the lower right corner and than zigzagged bottom-to-top and right-to-left.

Do you have an idea what could be wrong and how to fix things?

Eventually I would like to use three 16x16 matrix driven by Pixelblaze Output Expander.

Hi!,
A couple of things to try:

• Get the latest version of DoomFire (2.1) from github. This fixes the “won’t light the top row” problem.
• Set both height and width to 32. Doomfire’s algorithm works best if it can compute on a square, or nearly square backbuffer. (Telling it the truth – that the display is effectively 16(x) by 32(y) will result in some blocky looking quantization effects, which might be interesting too.)

If you still can’t get a look you like, I’d suggest trying @wizard’s brand new “perlin fire wind” pattern from the library. It will work on pretty much any display configuration.

Your mapping function is fine. Using it with the changes suggested above, this is what my preview window looks like:

Thank you! This updated/latest version looks very good on 16x16 matrix. WAF is really high.

This one also looks very good but on the 16x16 matrix 2 upper rows, most left and most right columns are completely inactive. This is very strange to see. I am not really good with programming, so am not sure which parameters to play with.

I have one more question. My wife asked for the rectangular matrix shape. I was thinking about 16x48 matrix (three 16x16 matrix side-by-side, will arrive in a few days). This will be too far from the suggested square matrix shape. What will be the best pattern to run?

Here’s a version with a bunch of controls for changing the look.
perlin fire wind controls.epe (8.3 KB)

Thank you very much!
This looks very nice and could be fine tuned.
I hope, this will look very nice on the rectangular 48x16 (long side horizontal orientation) matrix.

I think it will look great!

Thank you, Jon!

I guess, I am having some mapping related problem. Testing results are very inconsistent.
I created a related post few min ago. Unfortunately I am not very good with programming and have a hard time to figure out what is not right.