magarengMmala
→ lerpColor()Finds a colour part-way between two colours.
magarengMmala(fromColour, toColour, amount)Where magareng finds a number part-way between two numbers, magarengMmala does the same with colours. An amount of 0 returns the first colour, 1 returns the second, and 0.5 returns the one halfway between.
⚠ It needs built colour values, not strings. magarengMmala('#ff0000', '#0000ff', 0.5) fails — build the colours with bopaMmala first. This is where it differs from magarengMebala, which does accept strings and numbers.
The amount is not clamped. 1.5 and -0.5 carry on past the two colours, which may be what you want — or a bug you cannot see.
Parameters
Section titled “Parameters”| Name | Type | Description |
|---|---|---|
mmalaNtlha | mmala | The colour to start from. It must have been built with bopaMmala. |
mmalaBofelo | mmala | The colour to move towards. |
selekanyo | palo | How far along, 0–1, where 0 is the first colour. |
Examples
Section titled “Examples”tiro setaLoeto() {
thalaKanefase(400, 200);
tlogelaMothalo();
metlha tshimologo = bopaMmala(230, 60, 90);
metlha bokhutlo = bopaMmala(30, 80, 200);
gopheta (diri x = 0; x < 400; x = x + 4) {
tlatsaMmala(magarengMmala(tshimologo, bokhutlo, x / 400));
thalaKhutlonne(x, 0, 4, 200);
}
}tiro setaLoeto() {
thalaKanefase(400, 200);
bokamorago(20);
tlogelaMothalo();
metlha tshimologo = bopaMmala(250, 200, 70);
metlha bokhutlo = bopaMmala(60, 180, 200);
gopheta (diri i = 0; i < 8; i = i + 1) {
tlatsaMmala(magarengMmala(tshimologo, bokhutlo, i / 7));
thalaSediko(i * 46 + 40, 100, 56);
}
}