Skip to content
ExamplesOpen editor ↗

mmalaWaPhikisele

→ get()

Gives back the colour of one dot on the canvas.

mmalaWaPhikisele(x, y)

mmalaWaPhikisele(x, y) gives back the colour at that spot. It is a noun rather than a verb, in line with bopharaFensetere and paloYaUra: what you are asking for is a value, not an action.

What comes back is a list of four numbers, not a bopaMmala — measured: mmalaWaPhikisele(2, 2) returns [255, 0, 0, 255]. So colour[0] is red, colour[1] green, colour[2] blue and colour[3] transparency.

Outside the canvas it returns [0, 0, 0, 0] rather than throwing. Measured with mmalaWaPhikisele(-5, -5) and mmalaWaPhikisele(9999, 9999).

With four numbers it gives back a picture. mmalaWaPhikisele(x, y, width, height) returns a patch of the canvas as a picture thalaSetshwantsho can draw; with no numbers at all it returns the whole canvas. The name is for the common use — one dot’s colour — and the other two forms sit underneath it.

⚠ It is slow when called many times. For many dots, one balaDiphikisele is faster than a thousand mmalaWaPhikisele calls.

NameTypeDescription
xpaloThe x position of the dot.
ypaloThe y position of the dot.
Pick up the colour under the mouse
diri mmala;

tiro setaLoeto() {
  thalaKanefase(400, 200);
  mmala = letela tlisaSetshwantsho('mmala.png');
  tlogelaBorethe();
  tlhalosa('Ditsela tse nne tsa mmala. Sekwere se se fa thoko se supa mmala o o fa tlase ga peba.');
}

tiro tshwantsha() {
  bokamorago(245);
  thalaSetshwantsho(mmala, 20, 20, 160, 160);

  diri o = mmalaWaPhikisele(pebaX, pebaY);
  tlatsaMmala(o[0], o[1], o[2]);
  thalaKhutlonne(230, 20, 140, 160);
}

tlatsaPhikisele, balaDiphikisele, diphikisele, bopaMmala