Skip to content
ExamplesOpen editor ↗

tlisaSetshwantsho

→ loadImage()

Fetches a picture from the Bopa library so you can draw it.

letela tlisaSetshwantsho(name)

Fetching a picture takes time, so tlisaSetshwantsho goes together with letela:

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

What comes back is more than a picture — it is a thing with a bophara and a boleele, and thalaSetshwantsho can draw it.

Bopa library: letsatsi.png, naledi.png, mokolwane.png, kgomo.png and mmala.png are included.

Your own pictures: in the web editor, open Images and choose a PNG, JPG or WebP from your computer. Copy its loading expression, such as letela tlisaSetshwantsho('assets/photo.png'). These files stay in this browser; account saves contain code only. Publishing sketches with local images is not available yet. External image URLs are also supported under browser CORS and HTTPS rules.

Use it in setaLoeto. Bopa waits for setaLoeto, so pictures arrive before the canvas starts drawing. Fetching inside tshwantsha would fetch them many times a second.

NameTypeDescription
leinamokwaloAn image URL or bundled filename, e.g. 'kgomo.png'.
Fetch the cow, then draw it
diri kgomo;

tiro setaLoeto() {
  thalaKanefase(400, 240);
  kgomo = letela tlisaSetshwantsho('kgomo.png');
  bokamorago(245);
  thalaSetshwantsho(kgomo, 120, 40, 160, 160);
  tlhalosa('Setshwantsho sa kgomo e tshweu e e nang le marontho a mantsho, mo bogareng jwa kanefase.');
}
A picture knows its own size
tiro setaLoeto() {
  thalaKanefase(400, 200);
  bokamorago(245);

  diri naledi = letela tlisaSetshwantsho('naledi.png');
  thalaSetshwantsho(naledi, 20, 20, 160, 160);

  tlatsaMmala(40);
  bogoloJwaMokwalo(16);
  thalaMokwalo('bophara: ' + naledi.width, 210, 90);
  thalaMokwalo('boleele: ' + naledi.height, 210, 120);
  tlhalosa('Naledi e e mmalanyana kwa molemeng, le dipalo tsa bogolo jwa yona kwa mojeng.');
}

letela, thalaSetshwantsho, tlisaMofutatlhaka, seeloSaSetshwantsho