code: September 2008 Archives

Map function in JavaScript

| | Comments (0) | TrackBacks (0)

While building out my new lifestream, I ran into a wall, and needed a function to map a variable from one coordinate space (specifically arrays). I remembered that Proce55ing had just such a function. OpenSource Software FTW!

function map(value, istart, istop, ostart, ostop) {
return ostart + (ostop - ostart) * ((value - istart) / (istop - istart));

}

About this Archive

This page is a archive of entries in the code category from September 2008.

code: April 2008 is the previous archive.

code: October 2008 is the next archive.

Find recent content on the main index or look in the archives to find all content.

code: September 2008: Monthly Archives