Skip to content
ExamplesOpen editor ↗

thalaSetshwantsho

→ image()

Draws a picture that has already been fetched onto the canvas.

thalaSetshwantsho(picture, x, y, [width], [height])

thalaSetshwantsho(picture, x, y) draws it at its real size. Add two more numbers — thalaSetshwantsho(picture, x, y, width, height) — and it is stretched to the size you ask for.

By default x and y are the picture’s top-left corner. seeloSaSetshwantsho(BOGARE) changes that.

The name takes thala like every other drawing keyword. That is Bopa’s rule: anything that puts marks on the canvas begins with thala. It also settles a collision: the word setshwantsho stays an ordinary Setswana word — this page and others use it to mean the picture in the preview pane — while the function is thalaSetshwantsho. It is the route thalaMokwalo took.

It can draw a bopaBoalo buffer too. A buffer is a picture, so thalaSetshwantsho(buffer, 0, 0) puts it on the canvas.

⚠ Given something that is not a picture, the sketch stops with an unreadable error about drawImage and a list of HTML element types. Measured. Check that you used letela — without it you are handing over a promise, not a picture.

NameTypeDescription
setshwantshosetshwantshoWhat tlisaSetshwantsho returned, or a bopaBoalo buffer.
xpaloThe x position.
ypaloThe y position.
bopharapaloThe width to draw it at, optional.
boleelepaloThe height to draw it at, optional.
One picture, at three sizes
tiro setaLoeto() {
  thalaKanefase(400, 200);
  bokamorago(245);

  diri naledi = letela tlisaSetshwantsho('naledi.png');
  thalaSetshwantsho(naledi, 20, 60, 40, 40);
  thalaSetshwantsho(naledi, 90, 40, 80, 80);
  thalaSetshwantsho(naledi, 200, 20, 120, 120);

  tlhalosa('Dinaledi tse tharo tse di serolwana tse di golang go tswa kwa molemeng go ya kwa mojeng.');
}

tlisaSetshwantsho, seeloSaSetshwantsho, setshwantshoMmala, bopaBoalo, borethe