This should work:
PHP Code:
function getAlignmentColor(value) {
if (value<=0) return {64,0,0};
if (value<=26) return {128+int(127*(value-1)/25),64-int(64*(value-1)/25),64-int(64*(value-1)/25)};
if (value<=49) return {255,int(255*(value-26)/24),int(255*(value-26)/24)};
if (value<=55) return {255,255,255};
if (value<=60) return {255-int(127*(value-55)/5),255,255-int(127*(value-55)/5)};
if (value<=70) return {128-int(128*(value-61)/10),255,128+int(127*(value-61)/10)};
if (value<=99) return {0,255-int(255*(value-70)/29),255};
return {224,196,0};
}
It's returning an array of {red,green,blue}, then you only need to use it like this:
PHP Code:
acolors = getAlignmentColors(player.ap);
changeimgcolors(index, acolors[0]/255, acolors[1]/255, acolors[2]/255, 1);