magareng
→ lerp()Finds the number that lies between two numbers, at the fraction you give.
magareng(simolo, bofelo, tekanyo)Give magareng two numbers and a fraction between 0 and 1:
- 0 returns the first number
- 1 returns the second number
- 0.5 returns the number halfway between them
- 0.25 returns the number a quarter of the way from the first
This is what makes change look deliberate. Instead of jumping from one place to another, a shape can travel in small steps.
A fraction outside 0 and 1 is accepted, and carries you past the two numbers — magareng(0, 100, 1.5) is 150.
Parameters
Section titled “Parameters”| Name | Type | Description |
|---|---|---|
simolo | palo | The first number — returned when the fraction is 0. |
bofelo | palo | The second number — returned when the fraction is 1. |
tekanyo | palo | How far along from the first to the second, between 0 and 1. |
Examples
Section titled “Examples”tiro setaLoeto() {
thalaKanefase(400, 400);
bokamorago(20);
tlogelaMothalo();
gopheta (diri i = 0; i < 40; i = i + 1) {
metlha tekanyo = selekanyo(i, 0, 39);
// Go tswa mmaleng o mohibidu go ya go o motala
diri r = magareng(230, 40, tekanyo);
diri g = magareng(70, 160, tekanyo);
diri b = magareng(60, 210, tekanyo);
tlatsaMmala(r, g, b);
thalaKhutlonne(0, i * 10, 400, 10);
}
}tiro setaLoeto() {
thalaKanefase(400, 400);
bokamorago(240);
tlogelaMothalo();
metlha xYaNtlha = 50;
metlha yYaNtlha = 340;
metlha xYaBofelo = 350;
metlha yYaBofelo = 60;
gopheta (diri i = 0; i < 16; i = i + 1) {
metlha tekanyo = selekanyo(i, 0, 15);
diri x = magareng(xYaNtlha, xYaBofelo, tekanyo);
diri y = magareng(yYaNtlha, yYaBofelo, tekanyo);
tlatsaMmala(40, 120, 200);
thalaSediko(x, y, magareng(10, 44, tekanyo));
}
}