# Mapping Basics 101

**URL:** <https://forum.electromage.com/t/mapping-basics-101/109>\
**Category:** Ideas and Tips\
**Created:** [October 30, 2019, 1:27am UTC](https://forum.electromage.com/t/mapping-basics-101/109 "2019-10-30T01:27:54Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![dllnoah](https://forum.electromage.com/letter_avatar_proxy/v4/letter/d/4af34b/32.png) [@dllnoah](https://forum.electromage.com/u/dllnoah)\
**Post date:** [October 30, 2019, 1:27am UTC](https://forum.electromage.com/t/mapping-basics-101/109/1 "2019-10-30T01:27:54Z")

</div>

Hello, new user here. Just wondering if someone could explain the mapping process clearly. I have tried everything I can do to incorporate a mapped pattern but no luck the patterns never seem to change.

Any help would be greatly appreciated.

---

<div class="post-metadata">

**Author:** ![wizard](https://forum.electromage.com/user_avatar/forum.electromage.com/wizard/32/4_2.png) [@wizard](https://forum.electromage.com/u/wizard)\
**Post date:** [November 1, 2019, 11:24pm UTC](https://forum.electromage.com/t/mapping-basics-101/109/2 "2019-11-01T23:24:08Z")

</div>

Hi,

Does your pixel map preview look ok? Can you provide your map code, and what you are looking to do?

I think the most confusing thing (or at least the area I know I want to improve on) is that having a pixel map won’t do anything unless the pattern has a render2D or render3D function. Otherwise it just calls render() which doesn’t use the map. You can have all 3 render function variants in a single pattern, and it will use whichever is appropriate.

There are some really basic examples of a pattern that uses render2D and render3D in the [mapper docs](https://github.com/simap/pixelblaze/blob/master/README.mapper.md) or on the mapper page, scroll down below the editor.

[Regorlas](https://twitter.com/Regorlas) made a really cool 3d mapper test pattern, and talks a bit about it here:

> **[Pixelblaze Pattern: RGB-XYZ 3D Sweep](https://newscrewdriver.com/2019/07/06/pixelblaze-pattern-rgb-xyz-3d-sweep/)**
>
> The success of a static test pattern in 3D space is encouraging, but it’s still in the realm of something fairly easy to replicate with a simple microcontroller. We have barely tapped into th…

---

<div class="post-metadata">

**Author:** ![captain\_morgan](https://forum.electromage.com/user_avatar/forum.electromage.com/captain_morgan/32/106_2.png) [@captain\_morgan](https://forum.electromage.com/u/captain_morgan)\
**Post date:** [February 6, 2020, 2:15am UTC](https://forum.electromage.com/t/mapping-basics-101/109/3 "2020-02-06T02:15:18Z")

</div>

Howdy Ben, just getting back to some PixelBlaze hackin and for the life of me I cannot get the mapper to work. The preview on the Mapper tab looks right but it just doesn’t seem like render2D is called with the right x,y.

To start I use the Matrix example in the Mapper and change width to 30. Right away the preview looks correct, but I cannot seem to do much with the x,y coords.

Couple of tests that demonstrate odd behaviors.

```
export function render2D(i, x, y) {
  if(x>0) hsv(0.1,1,1)
  else hsv(1,1,1)
}

```

this results in the left most column being red, the rest being… mustard? sounds about right.

```
export function render2D(i, x, y) {
  if(x>1) hsv(0.1,1,1)
  else hsv(1,1,1)
}

```

but when I change to this, I would expect two red columns and beautiful mustard for the rest but instead it’s all red. Tons of variations on this result in the same, I can light the top row, or single columns but it doesnt’ actually seem to calling with the proper values.

---

<div class="post-metadata">

**Author:** ![wizard](https://forum.electromage.com/user_avatar/forum.electromage.com/wizard/32/4_2.png) [@wizard](https://forum.electromage.com/u/wizard)\
**Post date:** [February 6, 2020, 4:45pm UTC](https://forum.electromage.com/t/mapping-basics-101/109/4 "2020-02-06T16:45:49Z")

</div>

Hi @captain_morgan,  
Good to hear from you!  
So the trick is that your map is normalized to world units, values between 0 and 1. I did this so for 2 reasons. The first is so you don’t have to know and divide by the width to get a positional ratio for math based patterns. The second is that it makes patterns portable to any map/layout.

Of course the downside is if you want to know a pixel in integer position you have to multiply it back out, and be weary of rounding errors.

I plan to add a raster projection setup in v3, so you can have regular integer pixels, paint images and text, then project these onto an arbitrary pixel map.

---

<div class="post-metadata">

**Author:** ![captain\_morgan](https://forum.electromage.com/user_avatar/forum.electromage.com/captain_morgan/32/106_2.png) [@captain\_morgan](https://forum.electromage.com/u/captain_morgan)\
**Post date:** [February 6, 2020, 5:02pm UTC](https://forum.electromage.com/t/mapping-basics-101/109/5 "2020-02-06T17:02:40Z")

</div>

OOOOOoooohhhhh (he says as he rereads and sees it right there).  
Thanks Ben, don’t know how I kept missing this. Anyhow, been fun diving back in, got a couple cools post coming up (New picture frame, MQTT controls?). Will post updates on the forums here.
