sekgala
→ dist()Returns the distance between two points.
sekgala(x1, y1, x2, y2)sekgala(x1, y1, x2, y2) returns the length of the straight line between the first point and the second.
The order does not matter — sekgala(0, 0, 3, 4) and sekgala(3, 4, 0, 0) both return 5.
It is most often used to ask how near one thing is to another: changing a colour as the mouse approaches, choosing the points that fall inside a circle, or building shapes that lean on a centre.
It also accepts points in three dimensions — sekgala(x1, y1, z1, x2, y2, z2) — though Bopa does not yet carry three-dimensional shapes.
Parameters
Section titled “Parameters”| Name | Type | Description |
|---|---|---|
x1 | palo | The x of the first point. |
y1 | palo | The y of the first point. |
x2 | palo | The x of the second point. |
y2 | palo | The y of the second point. |
Examples
Section titled “Examples”tiro setaLoeto() {
thalaKanefase(400, 400);
bokamorago(18, 20, 30);
tlogelaMothalo();
gopheta (diri x = 20; x < 400; x = x + 20) {
gopheta (diri y = 20; y < 400; y = y + 20) {
metlha kgakala = sekgala(x, y, 200, 200);
// 0..260 go ya go 255..40
diri mmala = lekanyetsa(kgakala, 0, 260, 255, 40);
diri bogolwane = lekanyetsa(kgakala, 0, 260, 18, 4);
tlatsaMmala(mmala, 120, 200);
thalaSediko(x, y, bogolwane);
}
}
}tiro setaLoeto() {
thalaKanefase(400, 400);
bokamorago(240);
tlogelaMothalo();
paloEpePeo(33);
gopheta (diri i = 0; i < 400; i = i + 1) {
diri x = paloEpe(bophara);
diri y = paloEpe(boleele);
fa (sekgala(x, y, 200, 200) < 150) {
tlatsaMmala(220, 90, 70);
} gongwe {
tlatsaMmala(200);
}
thalaSediko(x, y, 8);
}
}