If you think the Android project MakeWithMotoSampleApp listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.
Java Source Code
package com.makewithmoto.views;
/*fromwww.java2s.com*//*
* Taken from processing.org source code
*
*/publicclass CanvasUtils {
staticpublicfinalfloat lerp(float start, float stop, float amt) {
return start + (stop - start) * amt;
}
/**
* Normalize a value to exist between 0 and 1 (inclusive). Mathematically
* the opposite of lerp(), figures out what proportion a particular value is
* relative to start and stop coordinates.
*/staticpublicfinalfloat norm(float value, float start, float stop) {
return (value - start) / (stop - start);
}
/**
* Convenience function to map a variable from one coordinate space to
* another. Equivalent to unlerp() followed by lerp().
*/staticpublicfinalfloat map(float value, float istart, float istop, float ostart, float ostop) {
return ostart + (ostop - ostart) * ((value - istart) / (istop - istart));
}
}