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
drawImageand a list of HTML element types. Measured. Check that you usedletela— without it you are handing over a promise, not a picture.
Parameters
Section titled “Parameters”| Name | Type | Description |
|---|---|---|
setshwantsho | setshwantsho | What tlisaSetshwantsho returned, or a bopaBoalo buffer. |
x | palo | The x position. |
y | palo | The y position. |
bophara | palo | The width to draw it at, optional. |
boleele | palo | The height to draw it at, optional. |
Examples
Section titled “Examples”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.');
}See also
Section titled “See also”tlisaSetshwantsho, seeloSaSetshwantsho, setshwantshoMmala, bopaBoalo, borethe