Skip to content
ExamplesOpen editor ↗

setshwantshoMmala

→ tint()

Gives every picture drawn after it a colour, or makes it see-through.

setshwantshoMmala(r, g, b, [alpha])

setshwantshoMmala does for pictures what mothaloMmala does for lines: it sets a colour that keeps working until you change it.

It multiplies the colour rather than replacing it. Each of the picture’s colours is multiplied by the colour you give, with each part divided by 255. Which means:

  • setshwantshoMmala(255, 0, 0) on a red pixel (255, 0, 0) leaves it red — measured: [255, 0, 0].
  • setshwantshoMmala(0, 255, 0) on that same pixel makes it black — measured: [0, 0, 0]. There is no green in a red pixel to multiply.
  • setshwantshoMmala(128) halves everything — [128, 0, 0].

A fourth number is see-through. setshwantshoMmala(255, 128) leaves the colour alone and makes the picture half transparent — over a white background a red pixel becomes [255, 127, 127], measured.

It follows seeloSaMmala. Under seeloSaMmala(HSB) the numbers are read as HSB — measured, and setshwantshoMmala(0, 100, 100) in HSB gave red as expected.

Use tlogelaSetshwantshoMmala to stop.

NameTypeDescription
khibidupaloThe red part, 0–255 — or a grey level if it is the only number.
talapaloThe green part, optional.
tala jwa loapipaloThe blue part, optional.
go bonalapaloTransparency, 0–255, optional.
One cow, three colours
tiro setaLoeto() {
  thalaKanefase(400, 160);
  bokamorago(245);

  diri kgomo = letela tlisaSetshwantsho('kgomo.png');

  tlogelaSetshwantshoMmala();
  thalaSetshwantsho(kgomo, 10, 10, 120, 120);

  setshwantshoMmala(255, 120, 120);
  thalaSetshwantsho(kgomo, 140, 10, 120, 120);

  setshwantshoMmala(255, 100);
  thalaSetshwantsho(kgomo, 270, 10, 120, 120);

  tlhalosa('Dikgomo tse tharo: ya ntlha ka mmala wa yona, ya bobedi e e khibidu, ya boraro e e bonalang.');
}

tlogelaSetshwantshoMmala, thalaSetshwantsho, seeloSaMmala, mothaloMmala