var ptarr = [600, 700, 800, 1000, 1200, 1400, 1600];
var muralHeight = 800;
var levelHeight = muralHeight / (ptarr.length - 1);
function points2px2(pt)
{
var level = -1;
for(var i = 0; i < ptarr.length; i++) {
if((ptarr[i] < pt) && (ptarr[i + 1] >= pt)) {
level = i;
break;
}
}
if(level == -1) {
console.log("The amount of points (" + pt + ") was incorrect and this doesn't fit any level. This value will be dropped")
return -1;
}
//Now points will be Level*LevelHeight + Tail. We have level, let's do tail now.
//Tail = PixPerLevel * (Score — Levels[ScoredLevels]) / (Levels[ScoredLevels + 1] — Levels[ScoredLevels]) (c) habr.ru/cjey
var tail = levelHeight * ((pt -ptarr[level])/ (ptarr[level+1] - ptarr[level] ))
return muralHeight - (levelHeight * level + tail);
}