One Row of Pixels at a time

I’m new to writing Pixelblaze code and I’m not terribly skilled with code in general. Good news is that Pixelblaze has inspired me to learn. Bad news is I’m in crunch time and have to have a project completed within 48 hours that relies on a pattern I can’t yet find. Any assistance that could be provided before that time would be GREATLY appreciated.

I need a pattern that starts at the bottom of the Y axis and moves up the Y axis one row at a time only illuminating one row of LEDs at a time.

I have included my mapping in case that helps.

[
// Mapping is from the perspective of sitting in front of the hallway.
// The Pixelblaze is on the left side of the exit.
// The bottom of the mapper window is the front of the hallway.

// Up fourth left column
[1,1],
[2,1],
[3,1],
[4,1],
[5,1],
[6,1],
[7,1],
[8,1],
[9,1],
[10,1],
[11,1],
[12,1],
[13,1],
[14,1],
[15,1],
[16,1],
[17,1],
[18,1],
[19,1],
[20,1],
[21,1],
[22,1],
[23,1],
[24,1],
[25,1],
[26,1],
[27,1],
[28,1],
[29,1],
[30,1],
[31,1],
[32,1],
[33,1],
[34,1],
[35,1],
[36,1],
[37,1],
[38,1],
[39,1],
[40,1],
[41,1],
[42,1],
[43,1],
[44,1],
[45,1],
[46,1],
[47,1],
[48,1],
[49,1],
[50,1],
[51,1],
[52,1],
[53,1],
[54,1],
[55,1],
[56,1],
[57,1],
[58,1],
[59,1],
[60,1],
[61,1],
[62,1],
[63,1],
[64,1],
[65,1],
[66,1],
[67,1],
[68,1],
[69,1],
[70,1],
//  Upper-Left Horizontal Section 3 forward
[70,2],
[70,3],
[70,4],
[70,5],
[70,6],
[70,7],
[70,8],
[70,9],
[70,10],
[70,11],
[70,12],
[70,13],
[70,14],
[70,15],
[70,16],
[70,17],
[70,18],
[70,19],
[70,20],
[70,21],
[70,22],
[70,23],
[70,24],
[70,25],
[70,26],
[70,27],
[70,28],
[70,29],
[70,30],
[70,31],
[70,32],
[70,32],
[70,33],
[70,34],
[70,35],
[70,36],
[70,37],
[70,38],
[70,39],
[70,40],
[70,41],
[70,42],
[70,43],
[70,44],
[70,45],
[70,46],
[70,47],
[70,48],
[70,49],
[70,50],
[70,51],
[70,52],
[70,53],
[70,54],
[70,55],
[70,56],
[70,57],
[70,58],
[70,59],
[70,60],
[70,61],
[70,62],
[70,63],
[70,64],
[70,65],
[70,66],
[70,67],
[70,68],
//  Upper-Left Horizontal Section 2 forward
[70,70],
[70,71],
[70,72],
[70,73],
[70,74],
[70,75],
[70,76],
[70,77],
[70,78],
[70,79],
[70,80],
[70,81],
[70,82],
[70,83],
[70,84],
[70,85],
[70,86],
[70,87],
[70,88],
[70,89],
[70,90],
[70,91],
[70,92],
[70,93],
[70,94],
[70,95],
[70,96],
[70,97],
[70,98],
[70,99],
[70,100],
[70,101],
[70,102],
[70,103],
[70,104],
[70,105],
[70,106],
[70,107],
[70,108],
[70,109],
[70,110],
[70,111],
[70,112],
[70,113],
[70,114],
[70,115],
[70,116],
[70,117],
[70,118],
[70,119],
[70,120],
[70,121],
[70,122],
[70,123],
[70,124],
[70,125],
[70,126],
[70,127],
[70,128],
[70,129],
[70,130],
[70,131],
[70,132],
[70,133],
[70,134],
[70,135],
[70,136],
[70,137],
//  Upper-Left Horizontal Section 1 forward
[70,139],
[70,140],
[70,141],
[70,142],
[70,143],
[70,144],
[70,145],
[70,146],
[70,147],
[70,148],
[70,149],
[70,150],
[70,151],
[70,152],
[70,153],
[70,154],
[70,155],
[70,156],
[70,157],
[70,158],
[70,159],
[70,160],
[70,161],
[70,162],
[70,163],
[70,164],
[70,165],
[70,166],
[70,167],
[70,168],
[70,169],
[70,170],
[70,171],
[70,172],
[70,173],
[70,174],
[70,175],
[70,176],
[70,177],
[70,178],
[70,179],
[70,180],
[70,181],
[70,182],
[70,183],
[70,184],
[70,185],
[70,186],
[70,187],
[70,188],
[70,189],
[70,190],
[70,191],
[70,192],
[70,193],
[70,194],
[70,195],
[70,196],
[70,197],
[70,198],
[70,199],
[70,200],
[70,201],
[70,202],
[70,203],
[70,204],
[70,205],
[70,206],
[70,207],
[70,208],
// Down first left column
[70,209],
[69,209],
[68,209],
[67,209],
[66,209],
[65,209],
[64,209],
[63,209],
[62,209],
[61,209],
[60,209],
[59,209],
[58,209],
[57,209],
[56,209],
[55,209],
[54,209],
[53,209],
[52,209],
[51,209],
[50,209],
[49,209],
[48,209],
[47,209],
[46,209],
[45,209],
[44,209],
[43,209],
[42,209],
[41,209],
[40,209],
[39,209],
[38,209],
[37,209],
[36,209],
[35,209],
[34,209],
[33,209],
[32,209],
[31,209],
[30,209],
[29,209],
[28,209],
[27,209],
[26,209],
[25,209],
[24,209],
[23,209],
[22,209],
[21,209],
[20,209],
[19,209],
[18,209],
[17,209],
[16,209],
[15,209],
[14,209],
[13,209],
[12,209],
[11,209],
[10,209],
[9,209],
[8,209],
[7,209],
[6,209],
[5,209],
[4,209],
[3,209],
[2,209],
[1,209],
// Up second left column
[1,138],
[2,138],
[3,138],
[4,138],
[5,138],
[6,138],
[7,138],
[8,138],
[9,138],
[10,138],
[11,138],
[12,138],
[13,138],
[14,138],
[15,138],
[16,138],
[17,138],
[18,138],
[19,138],
[20,138],
[21,138],
[22,138],
[23,138],
[24,138],
[25,138],
[26,138],
[27,138],
[28,138],
[29,138],
[30,138],
[31,138],
[32,138],
[33,138],
[34,138],
[35,138],
[36,138],
[37,138],
[38,138],
[39,138],
[40,138],
[41,138],
[42,138],
[43,138],
[44,138],
[45,138],
[46,138],
[47,138],
[48,138],
[49,138],
[50,138],
[51,138],
[52,138],
[53,138],
[54,138],
[55,138],
[56,138],
[57,138],
[58,138],
[59,138],
[60,138],
[61,138],
[62,138],
[63,138],
[64,138],
[65,138],
[66,138],
[67,138],
[68,138],
[69,138],
[70,138],
// Down third left column
[70,69],
[69,69],
[68,69],
[67,69],
[66,69],
[65,69],
[64,69],
[63,69],
[62,69],
[61,69],
[60,69],
[59,69],
[58,69],
[57,69],
[56,69],
[55,69],
[54,69],
[53,69],
[52,69],
[51,69],
[50,69],
[49,69],
[48,69],
[47,69],
[46,69],
[45,69],
[44,69],
[43,69],
[42,69],
[41,69],
[40,69],
[39,69],
[38,69],
[37,69],
[36,69],
[35,69],
[34,69],
[33,69],
[32,69],
[31,69],
[30,69],
[29,69],
[28,69],
[27,69],
[26,69],
[25,69],
[24,69],
[23,69],
[22,69],
[21,69],
[20,69],
[19,69],
[18,69],
[17,69],
[16,69],
[15,69],
[14,69],
[13,69],
[12,69],
[11,69],
[10,69],
[09,69],
[08,69],
[07,69],
[06,69],
[05,69],
[04,69],
[03,69],
[02,69],
[01,69],
//  Middle-Left Horizontal Section 3 forward
[35,2],
[35,3],
[35,4],
[35,5],
[35,6],
[35,7],
[35,8],
[35,9],
[35,10],
[35,11],
[35,12],
[35,13],
[35,14],
[35,15],
[35,16],
[35,17],
[35,18],
[35,19],
[35,20],
[35,21],
[35,22],
[35,23],
[35,24],
[35,25],
[35,26],
[35,27],
[35,28],
[35,29],
[35,30],
[35,31],
[35,32],
[35,33],
[35,34],
[35,35],
[35,36],
[35,37],
[35,38],
[35,39],
[35,40],
[35,41],
[35,42],
[35,43],
[35,44],
[35,45],
[35,46],
[35,47],
[35,48],
[35,49],
[35,50],
[35,51],
[35,52],
[35,53],
[35,54],
[35,55],
[35,56],
[35,57],
[35,58],
[35,59],
[35,60],
[35,61],
[35,62],
[35,63],
[35,64],
[35,65],
[35,66],
[35,67],
//  Middle-Left Horizontal Section 2 forward
// Skip a pixel. Shorter strip?
[35,70],
[35,71],
[35,72],
[35,73],
[35,74],
[35,75],
[35,76],
[35,77],
[35,78],
[35,79],
[35,80],
[35,81],
[35,82],
[35,83],
[35,84],
[35,85],
[35,86],
[35,87],
[35,88],
[35,89],
[35,90],
[35,91],
[35,92],
[35,93],
[35,94],
[35,95],
[35,96],
[35,97],
[35,98],
[35,99],
[35,100],
[35,101],
[35,102],
[35,103],
[35,104],
[35,105],
[35,106],
[35,107],
[35,108],
[35,109],
[35,110],
[35,111],
[35,112],
[35,113],
[35,114],
[35,115],
[35,116],
[35,117],
[35,118],
[35,119],
[35,120],
[35,121],
[35,122],
[35,123],
[35,124],
[35,125],
[35,126],
[35,127],
[35,128],
[35,129],
[35,130],
[35,131],
[35,132],
[35,133],
[35,134],
[35,135],
[35,136],
[35,137],
//  Middle-Left Horizontal Section 1 forward
[35,139],
[35,140],
[35,141],
[35,142],
[35,143],
[35,144],
[35,145],
[35,146],
[35,147],
[35,148],
[35,149],
[35,150],
[35,151],
[35,152],
[35,153],
[35,154],
[35,155],
[35,156],
[35,157],
[35,158],
[35,159],
[35,160],
[35,161],
[35,162],
[35,163],
[35,164],
[35,165],
[35,166],
[35,167],
[35,168],
[35,169],
[35,170],
[35,171],
[35,172],
[35,173],
[35,174],
[35,175],
[35,176],
[35,177],
[35,178],
[35,179],
[35,180],
[35,181],
[35,182],
[35,183],
[35,184],
[35,185],
[35,186],
[35,187],
[35,188],
[35,189],
[35,190],
[35,191],
[35,192],
[35,193],
[35,194],
[35,195],
[35,196],
[35,197],
[35,198],
[35,199],
[35,200],
[35,201],
[35,202],
[35,203],
[35,204],
[35,205],
[35,206],
//  Middle-Right Horizontal Section 3 forward
[147,2],
[147,3],
[147,4],
[147,5],
[147,6],
[147,7],
[147,8],
[147,9],
[147,10],
[147,11],
[147,12],
[147,13],
[147,14],
[147,15],
[147,16],
[147,17],
[147,18],
[147,19],
[147,20],
[147,21],
[147,22],
[147,23],
[147,24],
[147,25],
[147,26],
[147,27],
[147,28],
[147,29],
[147,30],
[147,31],
[147,32],
[147,33],
[147,34],
[147,35],
[147,36],
[147,37],
[147,38],
[147,39],
[147,40],
[147,41],
[147,42],
[147,43],
[147,44],
[147,45],
[147,46],
[147,47],
[147,48],
[147,49],
[147,50],
[147,51],
[147,52],
[147,53],
[147,54],
[147,55],
[147,56],
[147,57],
[147,58],
[147,59],
[147,60],
[147,61],
[147,62],
[147,63],
[147,64],
[147,65],
[147,66],
[147,67],
[147,68],
[147,69], // Extra pixel vs other side?
//  Middle-Right Horizontal Section 2 forward
[147,71],
[147,72],
[147,73],
[147,74],
[147,75],
[147,76],
[147,77],
[147,78],
[147,79],
[147,80],
[147,81],
[147,82],
[147,83],
[147,84],
[147,85],
[147,86],
[147,87],
[147,88],
[147,89],
[147,90],
[147,91],
[147,92],
[147,93],
[147,94],
[147,95],
[147,96],
[147,97],
[147,98],
[147,99],
[147,100],
[147,101],
[147,102],
[147,103],
[147,104],
[147,105],
[147,106],
[147,107],
[147,108],
[147,109],
[147,110],
[147,111],
[147,112],
[147,113],
[147,114],
[147,115],
[147,116],
[147,117],
[147,118],
[147,119],
[147,120],
[147,121],
[147,122],
[147,123],
[147,124],
[147,125],
[147,126],
[147,127],
[147,128],
[147,129],
[147,130],
[147,131],
[147,132],
[147,133],
[147,134],
[147,135],
[147,136],
[147,137],
[147,138],
[147,139],
[147,140],
//  Middle-Right Horizontal Section 1 forward
[147,142],
[147,143],
[147,144],
[147,145],
[147,146],
[147,147],
[147,148],
[147,149],
[147,150],
[147,151],
[147,152],
[147,153],
[147,154],
[147,155],
[147,156],
[147,157],
[147,158],
[147,159],
[147,160],
[147,161],
[147,162],
[147,163],
[147,164],
[147,165],
[147,166],
[147,167],
[147,168],
[147,169],
[147,170],
[147,171],
[147,172],
[147,173],
[147,174],
[147,175],
[147,176],
[147,177],
[147,178],
[147,179],
[147,180],
[147,181],
[147,182],
[147,183],
[147,184],
[147,185],
[147,186],
[147,187],
[147,188],
[147,189],
[147,190],
[147,191],
[147,192],
[147,193],
[147,194],
[147,195],
[147,196],
[147,197],
[147,198],
[147,199],
[147,200],
[147,201],
[147,202],
[147,203],
[147,204],
[147,205],
[147,206],
[147,207],
[147,208],
[147,209],
// Up fourth right column
[182,1],
[181,1],
[180,1],
[179,1],
[178,1],
[177,1],
[176,1],
[175,1],
[174,1],
[173,1],
[172,1],
[171,1],
[170,1],
[169,1],
[168,1],
[167,1],
[166,1],
[165,1],
[164,1],
[163,1],
[162,1],
[161,1],
[160,1],
[159,1],
[158,1],
[157,1],
[156,1],
[155,1],
[154,1],
[153,1],
[152,1],
[151,1],
[150,1],
[149,1],
[148,1],
[147,1],
[146,1],
[145,1],
[144,1],
[143,1],
[142,1],
[141,1],
[140,1],
[139,1],
[138,1],
[137,1],
[136,1],
[135,1],
[134,1],
[133,1],
[132,1],
[131,1],
[130,1],
[129,1],
[128,1],
[127,1],
[126,1],
[125,1],
[124,1],
[123,1],
[122,1],
[121,1],
[120,1],
[119,1],
[118,1],
[117,1],
[116,1],
[115,1],
[114,1],
[113,1],
// Upper-Right Horizontal Section 3 forward
[113,2],
[113,3],
[113,4],
[113,5],
[113,6],
[113,7],
[113,8],
[113,9],
[113,10],
[113,11],
[113,12],
[113,13],
[113,14],
[113,15],
[113,16],
[113,17],
[113,18],
[113,19],
[113,20],
[113,21],
[113,22],
[113,23],
[113,24],
[113,25],
[113,26],
[113,27],
[113,28],
[113,29],
[113,30],
[113,31],
[113,32],
[113,33],
[113,34],
[113,35],
[113,36],
[113,37],
[113,38],
[113,39],
[113,40],
[113,41],
[113,42],
[113,43],
[113,44],
[113,45],
[113,46],
[113,47],
[113,48],
[113,49],
[113,50],
[113,51],
[113,52],
[113,53],
[113,54],
[113,55],
[113,56],
[113,57],
[113,58],
[113,59],
[113,60],
[113,61],
[113,62],
[113,63],
[113,64],
[113,65],
[113,66],
[113,67],
[113,68],
[113,69],
// Upper-Right Horizontal Section 2 forward
[113,71],
[113,72],
[113,73],
[113,74],
[113,75],
[113,76],
[113,77],
[113,78],
[113,79],
[113,80],
[113,81],
[113,82],
[113,83],
[113,84],
[113,85],
[113,86],
[113,87],
[113,88],
[113,89],
[113,90],
[113,91],
[113,92],
[113,93],
[113,94],
[113,95],
[113,96],
[113,97],
[113,98],
[113,99],
[113,100],
[113,101],
[113,102],
[113,103],
[113,104],
[113,105],
[113,106],
[113,107],
[113,108],
[113,109],
[113,110],
[113,111],
[113,112],
[113,113],
[113,114],
[113,115],
[113,116],
[113,117],
[113,118],
[113,119],
[113,120],
[113,121],
[113,122],
[113,123],
[113,124],
[113,125],
[113,126],
[113,127],
[113,128],
[113,129],
[113,130],
[113,131],
[113,132],
[113,133],
[113,134],
[113,135],
[113,136],
[113,137],
[113,138],
[113,139],
[113,140],
// Upper-Right Horizontal Section 1 forward
[113,142],
[113,143],
[113,144],
[113,145],
[113,146],
[113,147],
[113,148],
[113,149],
[113,150],
[113,151],
[113,152],
[113,153],
[113,154],
[113,155],
[113,156],
[113,157],
[113,158],
[113,159],
[113,160],
[113,161],
[113,162],
[113,163],
[113,164],
[113,165],
[113,166],
[113,167],
[113,168],
[113,169],
[113,170],
[113,171],
[113,172],
[113,173],
[113,174],
[113,175],
[113,176],
[113,177],
[113,178],
[113,179],
[113,180],
[113,181],
[113,182],
[113,183],
[113,184],
[113,185],
[113,186],
[113,187],
[113,188],
[113,189],
[113,190],
[113,191],
[113,192],
[113,193],
[113,194],
[113,195],
[113,196],
[113,197],
[113,198],
[113,199],
[113,200],
[113,201],
[113,202],
[113,203],
[113,204],
[113,205],
[113,206],
[113,207],
[113,208],
[113,209],
// Down first right column
[113,210],
[114,210],
[115,210],
[116,210],
[117,210],
[118,210],
[119,210],
[120,210],
[121,210],
[122,210],
[123,210],
[124,210],
[125,210],
[126,210],
[127,210],
[128,210],
[129,210],
[130,210],
[131,210],
[132,210],
[133,210],
[134,210],
[135,210],
[136,210],
[137,210],
[138,210],
[139,210],
[140,210],
[141,210],
[142,210],
[143,210],
[144,210],
[145,210],
[146,210],
[147,210],
[148,210],
[149,210],
[150,210],
[151,210],
[152,210],
[153,210],
[154,210],
[155,210],
[156,210],
[157,210],
[158,210],
[159,210],
[160,210],
[161,210],
[162,210],
[163,210],
[164,210],
[165,210],
[166,210],
[167,210],
[168,210],
[169,210],
[170,210],
[171,210],
[172,210],
[173,210],
[174,210],
[175,210],
[176,210],
[177,210],
[178,210],
[179,210],
[180,210],
[181,210],
[182,210],
// Up third right column
[182,141],
[181,141],
[180,141],
[179,141],
[178,141],
[177,141],
[176,141],
[175,141],
[174,141],
[173,141],
[172,141],
[171,141],
[170,141],
[169,141],
[168,141],
[167,141],
[166,141],
[165,141],
[164,141],
[163,141],
[162,141],
[161,141],
[160,141],
[159,141],
[158,141],
[157,141],
[156,141],
[155,141],
[154,141],
[153,141],
[152,141],
[151,141],
[150,141],
[149,141],
[148,141],
[147,141],
[146,141],
[145,141],
[144,141],
[143,141],
[142,141],
[141,141],
[140,141],
[139,141],
[138,141],
[137,141],
[136,141],
[135,141],
[134,141],
[133,141],
[132,141],
[131,141],
[130,141],
[129,141],
[128,141],
[127,141],
[126,141],
[125,141],
[124,141],
[123,141],
[122,141],
[121,141],
[120,141],
[119,141],
[118,141],
[117,141],
[116,141],
[115,141],
[114,141],
[113,141],
// Down second right column
[113,70],
[114,70],
[115,70],
[116,70],
[117,70],
[118,70],
[119,70],
[120,70],
[121,70],
[122,70],
[123,70],
[124,70],
[125,70],
[126,70],
[127,70],
[128,70],
[129,70],
[130,70],
[131,70],
[132,70],
[133,70],
[134,70],
[135,70],
[136,70],
[137,70],
[138,70],
[139,70],
[140,70],
[141,70],
[142,70],
[143,70],
[144,70],
[145,70],
[146,70],
[147,70],
[148,70],
[149,70],
[150,70],
[151,70],
[152,70],
[153,70],
[154,70],
[155,70],
[156,70],
[157,70],
[158,70],
[159,70],
[160,70],
[161,70],
[162,70],
[163,70],
[164,70],
[165,70],
[166,70],
[167,70],
[168,70],
[169,70],
[170,70],
[171,70],
[172,70],
[173,70],
[174,70],
[175,70],
[176,70],
[177,70],
[178,70],
[179,70],
[180,70],
[181,70],
[182,70],
]

I’m having a hard time picturing what’s going on in the mapping, and I’m not a home with a pixel blaze to throw into a mapper to see. Can you explain how the LEDs are actually laid out? Maybe draw a line on the picture that shows the path that the index numbers follow?

Does the map need to stay the way it is for compatibility with other patterns, or could the mapping change to accommodate the pattern you want better?

All that said, if the Y-axis does just move across the ground, then something like this would work:

export function beforeRender(delta) {
  t1 = time(.1) 
}

export function render2D(index, x, y) {
  v = 0
  if (y <= t1){
    v = 1
  }
  hsv(1, 1, v)
}

Since mapper coordinates are normalized to go from 0.0 to 1.0, and time variables go from 0.0 to 1.0, you can use the time variable directly to control the Y axis cutoff.

This is what I see from the map, but I had a hard time figuring out how that aligned with the photo.

I think I get it… you have 2 sides, wired as long strips in an intersecting grid. In the map your Y is going away from the camera in the photo. If you wrapped this map around a tube on the X (and added a space for the floor), I could see how it works.

Can you annotate your photo with the kind of animation you want?

@wizard You’re close! The gap in the middle is the ceiling. The top of the map is the part of the tube furthest away. The bottom of the map is the entrance or the opening closest in the photo.

@teaderechoweb If I’m understanding your code correctly, I believe this would run backwards. I’m looking for one column of pixels at a time to light up, no matter the strip they are on and increment from the entrance (bottom of the y axis) to the exit (top of the y axis.)

To further complicate things, I don’t really have a way to test the pattern until this structure is built again on-site as it’s currently completely disassembled. :sweat_smile:

Thank you both greatly for all of your help!

The map is the way it is because that’s how the LEDs are wired. I’m a bit stuck within the constraints. But this isn’t really a mapping issue. The map works. It’s the 2D pattern I’m most interested in.

Now you do! (some assembly and a $10 USB/serial adapter required :wink: )

Oooh! Or you can install the 3.22 test firmware for a live preview based on your pixelmapper!

To get it to run the other way, you can just subtract t1 from 1, and switch to greater-than:

export function beforeRender(delta) {
  t1 = time(.1) 
}

export function render2D(index, x, y) {
  v = 0
  if (y >= 1-t1){
    v = 1
  }
  hsv(1, 1, v)
}

How do you want it to “reset”? This will fill up the entire tunnel, but once it reaches the end it will just all turn off at once and start over.

Do you mean a pulse of light going down the tunnel, when it hits the vertical lines those light up as well? A gradient pulse would look cool, or do you want single pixels?

Yes! You got it! This is exactly what I’m looking for. A single row of LEDs or a pulse? Why not the option for both? lol Seriously, thank you all very much for your help. The Pixelblaze is a really rad controller and this forum is the icing on an already delicious cake.

1 Like

Here’s a blue pulse, slider to control sharpness.

It draws a triangle waveform, offset by a timer.
Then offsets that so that only part of the triangle is above positive.
Then scales that so the peak is still covering a range of 0-1.

blue pulse along Y.epe (8.5 KB)

Here’s a preview using the new preview system, with a few tweaks to the settings to capture it a little better.

Softer, faster, and different preview settings

1 Like

And here’s the code, brief as it is, I’ll try to explain the key bits

var sharpness = 20
var offset = 1-1/sharpness
var speed = 10 / 65.536 //animate over 3 seconds

export function sliderSharpness(v) {
  sharpness = 1 + v*v*100
  offset = 1-1/sharpness
}


export function beforeRender(delta) {
  t1 = time(speed)
  resetTransform()
  scale(1,.8) //scale y down a bit so that we don't wrap immediately
}

export function render2D(index, x, y) {
  h = 2/3 
  s = 1
  v = (triangle(t1 + y) - offset) * sharpness
  hsv(h, s, v)
}

The bulk of the pattern is this line

v = (triangle(t1 + y) - offset) * sharpness

Breaking that apart:

triangle(t1 + y)

It draws a triangle waveform along y, offset by a timer t1. It’s a full scale triangle waveform, so it’s very soft.

If we want most of the LEDs to be black, only showing a peak, we can “hide” most of it by subtracting.

triangle(t1 + y) - offset

If offset was 0.5, half the triangle would now be negative. The other half would go from 0 to 0.5, which is a start, but we want to scale that back up to be full brightness.

v = (triangle(t1 + y) - offset) * sharpness

The sharpness here is that scale, and the offset is based on that. In the example before, if offset was 0.5, sharpness would have been 2. The triangle waveform is now 50% black (since its negative) and the other half goes from 0 to 1.0.

The rest of the pattern is a framework for making that core bit of math work well.

The sharpness and offset bits are here:

var sharpness = 20
var offset = 1-1/sharpness

That will hide everything but 1/20th of the triangle. From this you can see that offset would be 1-1/20 == .95.

1 Like

This last pattern you sent over worked perfectly and was exactly what I was going for. The Lunarcrats Intergalactic Bass Station Corridor was a huge hit! Quite a few people asked what controller it was being driven with and/or how it all worked. Being able to whip out my phone and give a quick tutorial on how it was all laid out in moments blew a few minds for certain. Thank you for all of your help!

2 Likes