# Uneven distrobution instead of normal map()

**URL:** <https://discourse.processing.org/t/uneven-distrobution-instead-of-normal-map/5791>\
**Category:** Coding Questions\
**Created:** [November 21, 2018, 11:45am UTC](https://discourse.processing.org/t/uneven-distrobution-instead-of-normal-map/5791 "2018-11-21T11:45:16Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![noFun](https://avatars.discourse-cdn.com/v4/letter/n/839c29/32.png) [@noFun](https://discourse.processing.org/u/noFun)\
**Post date:** [November 21, 2018, 11:45am UTC](https://discourse.processing.org/t/uneven-distrobution-instead-of-normal-map/5791/1 "2018-11-21T11:45:16Z")

</div>

If you use something like map(n,0,100, 0,200), it will map things evenly. 0 maps to 0, 100 maps to 200, and each integer in-between is evenly spaced. But what if you don’t want the mapping to be as even? As in, when lower numbers get mapped they are closer together, and higher numbers are further away from each other. It seems like it should be a log or exponential kind of growth…or something?

I know I’m not explaining this the best, but I hope this resonates with someone, and they can send me down the right path.

---

<div class="post-metadata">

**Author:** ![kll](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/kll/32/964_2.png) [@kll](https://discourse.processing.org/u/kll)\
**Post date:** [November 21, 2018, 11:55am UTC](https://discourse.processing.org/t/uneven-distrobution-instead-of-normal-map/5791/2 "2018-11-21T11:55:34Z")

</div>

@noFun yes it should be fun!

map is just a prepared function to do a often occurring job for you.

so you have a special job? you write the function.  
you could start to just do the “map” thing again,  
( pls. show it here )  
and from there start to do a “maplog” version.

---

<div class="post-metadata">

**Author:** ![noFun](https://avatars.discourse-cdn.com/v4/letter/n/839c29/32.png) [@noFun](https://discourse.processing.org/u/noFun)\
**Post date:** [November 21, 2018, 12:04pm UTC](https://discourse.processing.org/t/uneven-distrobution-instead-of-normal-map/5791/3 "2018-11-21T12:04:24Z")

</div>

But that is the trouble, I don’t know what the function or math is to make that happen.

---

<div class="post-metadata">

**Author:** ![kll](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/kll/32/964_2.png) [@kll](https://discourse.processing.org/u/kll)\
**Post date:** [November 21, 2018, 12:05pm UTC](https://discourse.processing.org/t/uneven-distrobution-instead-of-normal-map/5791/4 "2018-11-21T12:05:32Z")

</div>

i help you with the

> **framework**
>
> ```auto
> int Nin = 33;
> float Nout;
> 
> float my_map(float n, float inlow, float inhigh, float outlow, float outhigh) {
> float in_range = 0;
> // you do the first math and show us
> return(in_range);
> }
> 
> void setup() {
> size(100, 100);
> Nout = my_map(Nin, 0, 100, 0, 200);
> println("Nin: "+Nin+" my_map "+Nout);
> }
> 
> void draw() {
> }
> 
> ```
> 
> inthere you start with some math

and as we are using processing we must have some minimal graphic show

```auto
int Nin = 33;
float Nout;

float my_map(float n, float inlow, float inhigh, float outlow, float outhigh) {
  float in_range = n;
  return(in_range);
}

void setup() {
  size(120, 220);
  Nout = my_map(Nin, 0, 100, 0, 200);
  println("Nin: "+Nin+" my_map "+Nout);
}

void draw_graph() {
  for ( int i=0;i<101;i++){
    int posx = i+10;
    int posy = 210 - int(my_map(i, 0, 100, 0, 200));
    if( i == Nin ) { stroke(200,0,0); } else { stroke(0); }
    line(posx,210,posx,posy);
  }
}

void draw() {
  draw_graph(); 
}

```

 ![snap-004](https://canada1.discourse-cdn.com/flex036/uploads/processingfoundation1/original/2X/3/345bd5ac5501483acf72bf8ac423384901553d8a.png)

if you want play p5.js [here](https://editor.p5js.org/kll/sketches/BkKE50zRm)
