tlhotlha
→ filter()Passes the whole canvas through the effect you choose.
tlhotlha(effect, [amount], [useWebGL])tlhotlha changes the whole canvas at once. The effects are:
BOPUTSWA— takes the colour out, leaving grey. Measured: a red dot[255, 0, 0]becomes[54, 54, 54].RIBEGA— turns every colour into its opposite. Measured:[255, 0, 0]becomes[0, 255, 255].MOLELWANE— every dot becomes either white or black, with nothing in between.PHIFALO— blurs the picture. A second number is how much; with no number it is the same astlhotlha(PHIFALO, 3)— measured.GO_SE_BONALE— removes all transparency. On an already-opaque canvas it does nothing; on a see-through one,[255, 0, 0, 128]becomes[255, 0, 0, 255]— measured.POSTERIZE— cuts the number of colours down. It does not change colours already at the extremes (0 or 255); it changes the ones in between.
It does not need balaDiphikisele first — measured.
⚠ An unknown name throws a readable error: “Unknown filter: …”. That is unlike
seeloSaMotswako, which throws an unreadable one.
⚠
DILATEandERODEare not in Bopa, and the reason is real. On the canvas, the two do exactly the same thing — and it is not growing or shrinking: they shift the picture by one dot. Measured — a 20×20 black square stays 400 dots after either, just moved. On a picture itself they work correctly.
Parameters
Section titled “Parameters”| Name | Type | Description |
|---|---|---|
mokgwa | konoketsi | BOPUTSWA, RIBEGA, MOLELWANE, PHIFALO, GO_SE_BONALE or POSTERIZE. |
bogolo | palo | An amount, optional — used only by PHIFALO and POSTERIZE. |
dirisaWebGL (optional) | nnetemaaka | Defaults to nnete (WebGL). Pass maaka last to use CPU filters when WebGL is unavailable, as these examples do. |
Examples
Section titled “Examples”tiro setaLoeto() {
thalaKanefase(400, 160);
bokamorago(245);
diri mokolwane = letela tlisaSetshwantsho('mokolwane.png');
thalaSetshwantsho(mokolwane, 20, 15, 130, 130);
thalaSetshwantsho(mokolwane, 250, 15, 130, 130);
tlhotlha(RIBEGA, maaka);
tlhalosa('Mekolwane e mebedi, ka bobedi e ribegilwe mebala, mo kanefaseng e ntsho.');
}