Changes by last author:

Added:
= scl =

== Syntax ==

:int scl(int a, int il, int ih, int ol, int oh)

== Arguments ==

:a

::An integer value for the 'A' value.

:il

::An integer value for the lower limit of the input range.

:ih

::An integer value for the higher limit of the input range.

:ol

::An integer value for the lower limit of the output range.

:oh

::An integer value for the higher limit of the output range.

== Return ==

:An integer in the range of [ol,oh].

== Description ==

:Scales value a from range [il,ih] to range [ol,oh].

== Example ==

<code>

%ffp

ctl(0): "Stretch", range = (0, 255)

R = scl(r, 0, 255, -ctl(0), 255 + ctl(0));

G = scl(g, 0, 255, -ctl(0), 255 + ctl(0));

B = scl(b, 0, 255, -ctl(0), 255 + ctl(0));

</code>

== Also see ==

:mix

== Comments ==

:If il and oh are 0, the following simple formula performs better: result = a * oh / ih;

:Everyone can add his comments about his experiences with this function here. Tips for using it are welcome, too.