mix

Syntax

int mix(int a, int b, int n, int d)

Arguments

a
An integer value to be mixed in.
b
An integer value for the base value.
n
An integer value which controls the mixture.
d
An integer value for the range.

Return

An integer which is a mix of a into b, based on the position of n in range [0,d].

Description

This function calculates how much of a will be mixed into b, proportional to the position of n in the range from 0 to d. If n is 0, the value of b is returned, if n is equal to d, the value of a is returned. For any values of n in between 0 and d, a proportional value is calculated.

This version of the mix function maintains compatibility with the algorithm used by Filter Factory plugins.

Example

%ffp

ctl(0): "Darken", range = (0, 100)

R = mix(0, r, ctl(0), 100)
G = mix(0, g, ctl(0), 100)
B = mix(0, b, ctl(0), 100)

See Also

scl, mix1, mix2