Skip to content
ExamplesOpen editor ↗

thalaArc

→ arc()

Draws an arc — a slice of the edge of an ellipse, from one angle to another.

thalaArc(x, y, bophara, boleele, tshimologo, bofelo, [mokgwa])

An arc is drawn on the ellipse that x, y, bophara and boleele describe — the same ellipse thalaSelee would draw. The next two numbers are the start and stop angles, and the arc is drawn clockwise from start to stop.

The angle follows seeloSaSekhutlo. By default it is read in radians, so a full turn is PEDI_PI. Call seeloSaSekhutlo(DEGREES) first and the arc counts in degrees.

The optional mode decides how the ends are closed: BULA leaves the two ends unjoined, TLHAMALALA joins them with a straight line, and SERIPA joins them through the centre — which is where a pie slice comes from.

Two things worth knowing. If start and stop are equal, nothing is drawn at all. And across a full turn the arc draws the whole ellipse, ignoring the mode.

NameTypeDescription
xpaloCenter x of the arc’s ellipse.
ypaloCenter y of the arc’s ellipse.
bopharapaloWidth of the arc’s ellipse.
boleelepaloHeight of the arc’s ellipse.
tshimologopaloAngle where the arc starts, in the current angle unit.
bofelopaloAngle where the arc stops. The arc runs clockwise from the start.
mokgwa (optional)tlhomamengBULA, TLHAMALALA or SERIPA — how the two ends are closed.
A Pac-Man opening its mouth
tiro setaLoeto() {
  thalaKanefase(400, 400);
  seeloSaSekhutlo(DEGREES);
}
tiro tshwantsha() {
  bokamorago(20, 24, 40);
  tlogelaMothalo();
  tlatsaMmala(250, 210, 60);

  // sutisa peba go bula le go tswala molomo: 2 go ya go 45 dikirii
  metlha molomo = lekanyetsa(thibela(pebaX, 0, 400), 0, 400, 2, 45);

  thalaArc(200, 200, 220, 220, molomo, 360 - molomo, SERIPA);

  // leitlho
  tlatsaMmala(20, 24, 40);
  thalaSediko(215, 150, 20);
}
The three modes, side by side
tiro setaLoeto() {
  thalaKanefase(400, 400);
  bokamorago(245);
  seeloSaSekhutlo(DEGREES);
  boketeMothalo(3);
  tlatsaMmala(120, 190, 240);

  // BULA: dintlha tsa bofelo ga di golaganngwe
  thalaArc(90, 150, 120, 120, 40, 320, BULA);

  // TLHAMALALA: di golaganngwa ka mothalo o o tlhamaletseng
  thalaArc(210, 150, 120, 120, 40, 320, TLHAMALALA);

  // SERIPA: di golaganngwa ka bogare
  thalaArc(330, 150, 120, 120, 40, 320, SERIPA);
}
A pie chart
tiro setaLoeto() {
  thalaKanefase(400, 400);
  bokamorago(250);
  seeloSaSekhutlo(DEGREES);
  tlogelaMothalo();

  metlha dikarolo = [35, 25, 20, 15, 5];
  diri simolo = -90;

  gopheta (diri i = 0; i < 5; i = i + 1) {
    metlha bophara_jwa_seripa = dikarolo[i] * 3.6;
    tlatsaMmala(60 + i * 40, 150, 230 - i * 30);
    thalaArc(200, 200, 260, 260, simolo, simolo + bophara_jwa_seripa, SERIPA);
    simolo = simolo + bophara_jwa_seripa;
  }
}

thalaSelee, thalaSediko, seeloSaSekhutlo, seeloSaSediko, SERIPA