Skip to content
ExamplesOpen editor ↗

bopaMmala

→ color()

Builds a colour value you can store and reuse.

bopaMmala(grey) | bopaMmala(r, g, b) | bopaMmala(r, g, b, alpha)

bopaMmala draws nothing. It only builds a value — a stored colour you can hand to tlatsaMmala, mothaloMmala or bokamorago later. When one colour is used in several places, building it once is clearer than retyping three numbers each time.

It accepts several shapes: one number (grey), two numbers (grey and alpha), three numbers (r, g, b), four numbers (r, g, b, alpha), a CSS string such as '#ff8040', or an array of numbers. Given a colour that already exists it returns that same colour — it does not copy it.

Components outside the range are clamped: bopaMmala(300, -20, 0) is the same as bopaMmala(255, 0, 0).

For a colour picker, dirisaMoGo(picker, bopaMmala) reads a colour object. Set the picker with bolengJwaElemente(picker, "#238b9c").

NameTypeDescription
rpaloRed component 0–255, or the grey value when given alone.
g (optional)paloGreen component 0–255.
b (optional)paloBlue component 0–255.
alpha (optional)paloOpacity 0–255, where 255 is fully opaque.
Store a colour and use it twice
tiro setaLoeto() {
  thalaKanefase(400, 200);
  bokamorago(220);
  metlha bohibidutona = bopaMmala(230, 60, 90);
  tlogelaMothalo();
  tlatsaMmala(bohibidutona);
  thalaSediko(130, 100, 90);
  mothaloMmala(bohibidutona);
  boketeMothalo(6);
  tlogelaGoTlatsa();
  thalaSediko(280, 100, 90);
}
Different shapes of the same colour
tiro setaLoeto() {
  thalaKanefase(400, 200);
  bokamorago(220);
  tlogelaMothalo();
  metlha mebala = [
    bopaMmala(120),
    bopaMmala(230, 60, 90),
    bopaMmala(30, 80, 200, 120),
    bopaMmala('#f0a030')
  ];
  gopheta (diri i = 0; i < 4; i = i + 1) {
    tlatsaMmala(mebala[i]);
    thalaKhutlonne(i * 96 + 26, 60, 72, 72);
  }
}

tlatsaMmala, mothaloMmala, magarengMmala, seeloSaMmala