CocoaPods trunk is moving to be read-only. Read more on the blog, there are 17 months to go.

AYBMap 0.2.0

AYBMap 0.2.0

TestsTested
LangLanguage Obj-CObjective C
License MIT
ReleasedLast Release Dec 2014

Maintained by Andy Barnard.



AYBMap 0.2.0

Map a value from one range to another using map().

CGFloat progress = 0.618;
CGFloat viewWidth = CGRectGetWidth([self bounds]);
CGFloat horizontalPosition = map(progress, 0.0, 1.0, 0.0, viewWidth);
[progressIndicator setCenter:CGPointMake(horizontalPosition, 0.0)];

Use expoMap() to non-linearly map from one range to another by applying an exponential curve across the target range.

for (int i = 0; i < 6; i++) {
    CGFloat progress = 0.2 * i;
    CGFloat exponent = 3.0;
    CGFloat mappedProgress = expoMap(progress, 0.0, 1.0, 0.0, 100.0, exponent);
    printf("%f, ", mappedProgress);
}
// Prints "0.000000, 4.307549, 12.156414, 26.457980, 52.517134, 100.000000, "

Specify a positive exponent to apply an increasing exponential mapping across the target range (ease in) or a negative exponent to apply a decaying exponential mapping across the target range (ease out), as shown below. An exponent of 0 will result in a linear mapping.

Exponent of 3.

Exponent of -2.