Skip to content
ExamplesOpen editor ↗

magarengBezier

→ bezierPoint()

Returns one coordinate of a point along a Bézier curve.

magarengBezier(a, b, c, d, t)

magarengBezier(a, b, c, d, t) tells you where a point partway along a Bézier curve is. The first four numbers are the coordinates of the four points, in the order thalaBezier wants them. The fifth, t, is how far along you are: 0 is the start, 1 the end, and 0.5 halfway.

It does one axis at a time. Give it the x coordinates and you get x back; give it the y coordinates and you get y. So you call it twice.

The name comes from magareng. What is happening is a search for a value in between — as magareng finds a number between two others, and magarengMmala a colour between two colours. magarengBezier finds the one in between along a bending path rather than a straight line.

⚠ It does not clamp t. It reads as “a number between 0 and 1”, and nothing holds it there: magarengBezier(0, 0, 100, 100, 2) returns −400. Measured. Use thibela if you want it held.

NameTypeDescription
apaloCoordinate of the first anchor point.
bpaloCoordinate of the first control point.
cpaloCoordinate of the second control point.
dpaloCoordinate of the second anchor point.
tpaloHow far along the curve, between 0 and 1.
A dot travelling along the curve
metlha x1 = 40;
metlha y1 = 200;
metlha x2 = 100;
metlha y2 = 40;
metlha x3 = 300;
metlha y3 = 40;
metlha x4 = 360;
metlha y4 = 200;

tiro setaLoeto() {
  thalaKanefase(400, 240);
  tlhalosa('Konego e le nngwe e e menaganeng, le sediko se sekhibidu se se tsamayang go tswa ntlheng nngwe go ya go e nngwe le go boa.');
}

tiro tshwantsha() {
  bokamorago(245);
  tlogelaGoTlatsa();
  mothaloMmala(30, 90, 170);
  boketeMothalo(3);
  thalaBezier(x1, y1, x2, y2, x3, y3, x4, y4);

  metlha t = (sin(paloYaDikgato * 0.02) + 1) / 2;
  metlha x = magarengBezier(x1, x2, x3, x4, t);
  metlha y = magarengBezier(y1, y2, y3, y4, t);

  tlogelaMothalo();
  tlatsaMmala(220, 70, 90);
  thalaSediko(x, y, 16);
}

thalaBezier, mothalokgomiBezier, magarengKonego, magareng, thibela