# How do I light up any pixel with render2D

**URL:** <https://forum.electromage.com/t/how-do-i-light-up-any-pixel-with-render2d/3737>\
**Category:** Patterns and Code\
**Created:** [September 1, 2024, 3:43pm UTC](https://forum.electromage.com/t/how-do-i-light-up-any-pixel-with-render2d/3737 "2024-09-01T15:43:31Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Vitaliy](https://forum.electromage.com/letter_avatar_proxy/v4/letter/v/4bbf92/32.png) [@Vitaliy](https://forum.electromage.com/u/Vitaliy)\
**Post date:** [September 1, 2024, 3:43pm UTC](https://forum.electromage.com/t/how-do-i-light-up-any-pixel-with-render2d/3737/1 "2024-09-01T15:43:32Z")

</div>

I am trying to create an “Electronic Minora” pattern (lighted candles in a 2d 32x8 matrix).  
Here is a mapping functions which works as expected:

```auto
// Mapping for the 8x32 Matrix
// with vertical zigzagging
function (pixelCount)
{
  width = 32 // Info, this value is not used
  height = 8

  var map = []

  for (i = 0; i < pixelCount; i++)
  {
    x = Math.floor(i / height) 
    y = (i % height)

    // y adjustment for vertical zigzag wiring
    y = (x % 2) == 1 ? (height - 1 - y) : y
    map.push([x, y])
  }

  return map
}

```

And here is my very simple test pattern:

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

export function render2D(index, x, y)
{
  h = 0.05
  s = 1
  
  if ((x == 0) && (y == 0))
  {
    v = 1
  }
  else
  {
    v = 0
  }
  hsv(h, s, v)
}

```

I can turn on only pixel with x = 0 and y = 0 coordinates.  
Changing x and/or y to something other than 0 does not light up any led at all.  
I assume, for the 32x8 matrix and mapping as shown above the x range is 32 (0:31) and y range is 8 (0:7) but this is not working as expected. If I use Index instead of x,y I can light up any led as expected.  
What I am missing?

---

<div class="post-metadata">

**Author:** ![zranger1](https://forum.electromage.com/user_avatar/forum.electromage.com/zranger1/32/301_2.png) [@zranger1](https://forum.electromage.com/u/zranger1)\
**Post date:** [September 1, 2024, 4:18pm UTC](https://forum.electromage.com/t/how-do-i-light-up-any-pixel-with-render2d/3737/2 "2024-09-01T16:18:23Z")

</div>

Hi Vitaliy,

Mapped (x,y) coordinates passed as parameters to render2D (also z in 3D) are normalized to the range 0.0 to 1.0, so patterns will work regardless of the specific underlying display.

If you know the height and width of your display, `floor(x * width)` and `floor(y * height)` will get you the original coordinate values.

---

<div class="post-metadata">

**Author:** ![Vitaliy](https://forum.electromage.com/letter_avatar_proxy/v4/letter/v/4bbf92/32.png) [@Vitaliy](https://forum.electromage.com/u/Vitaliy)\
**Post date:** [September 2, 2024, 2:43pm UTC](https://forum.electromage.com/t/how-do-i-light-up-any-pixel-with-render2d/3737/3 "2024-09-02T14:43:43Z")

</div>

Thank you for the advice.  
I was thinking about x,y are normalized but did not figure out how to use this normalized values.
