baya
→ push()Begins a drawing group with its own colours and transformations.
baya()baya and tsaya are taught together because they do one job between them: they fence off colours and transformations inside a single group of drawing. They are always used as a pair — baya opens the group, tsaya closes it.
Think of baya as putting down your drawing state so you can pick the same one back up afterwards. Anything you change after baya — tlatsaMmala, boketeMothalo, sutisa, dikolosa, godisa — is dropped again when tsaya is called.
baya();sutisa(pebaX, pebaY);tlatsaMmala(0, 200, 0);thalaSediko(0, 0, 60);tsaya();// drawing from here on is not moved, and its colour is unchangedThey can also be nested: a group can hold smaller groups inside it, each with its own baya and tsaya.
Forget the tsaya and your transformations carry on into everything that follows. Call tsaya without a baya before it and you get an error.
Note:
bayais the name of a drawing function only. If you have a list and want to add something to it, you writelenaneo.push(x), and Bopa leaves it alone.
Examples
Section titled “Examples”tiro setaLoeto() {
thalaKanefase(400, 400);
bokamorago(240);
// mo teng ga setlhopha: mmala o mongwe, boemo jo bongwe
baya();
sutisa(120, 130);
tlatsaMmala(220, 90, 90);
thalaSediko(0, 0, 120);
tsaya();
// kwa ntle ga sona: tlatsaMmala e sa ntse e le e e neng e le teng pele,
// mme (0, 0) e boetse kwa sekhutlong sa godimo-molema
thalaSediko(280, 270, 120);
}tiro setaLoeto() {
thalaKanefase(400, 400);
bokamorago(26, 30, 46);
seeloSaSekhutlo(DEGREES);
tlogelaMothalo();
baya();
sutisa(200, 200);
gopheta (diri i = 0; i < 6; i = i + 1) {
baya(); // setlhopha se sennye mo teng ga se segolo
dikolosa(i * 60);
sutisa(110, 0);
tlatsaMmala(240, 190, 90);
thalaSediko(0, 0, 44);
baya(); // le se sengwe gape mo teng ga sona
godisa(0.4);
tlatsaMmala(40, 50, 80);
thalaSediko(0, 0, 44);
tsaya();
tsaya();
}
tsaya();
}