Skip to content
ExamplesOpen editor ↗

sutisa

→ translate()

Moves the (0, 0) point of the canvas to somewhere else.

sutisa(x, y)

By default (0, 0) sits at the top-left corner of the canvas. sutisa moves it somewhere else, and everything drawn afterwards is drawn from the new point.

That makes a complicated shape simple: draw it as though (0, 0) were its own centre, then use sutisa to put it where it belongs.

Transformations accumulate. Calling sutisa(10, 0) twice is the same as calling sutisa(20, 0) once. Use baya and tsaya to keep a transformation inside one group of drawing.

Transformations are reset at the start of tshwantsha. So calling sutisa(1, 0) inside tshwantsha does not make shapes travel — they simply stay in one place.

NameTypeDescription
xpaloHow far to move along the x-axis.
ypaloHow far to move along the y-axis.
One shape, drawn three times
tiro setaLoeto() {
  thalaKanefase(400, 400);
  bokamorago(238);

  // ntlo e thadilwe e le teng gore (0, 0) ke bogare jwa yona.
  // baya/tsaya di dira gore sutisa e nngwe le nngwe e se ame e e latelang.
  gopheta (diri i = 0; i < 3; i = i + 1) {
    baya();
    sutisa(90 + i * 110, 200);
    thalaNtlo();
    tsaya();
  }
}
tiro thalaNtlo() {
  tlatsaMmala(220, 200, 170);
  thalaKhutlonne(-35, -20, 70, 60);
  tlatsaMmala(180, 90, 70);
  thalaKhutlotharo(-45, -20, 0, -70, 45, -20);
}
Moving the origin to the mouse
tiro setaLoeto() {
  thalaKanefase(400, 400);
}
tiro tshwantsha() {
  bokamorago(24, 28, 44);
  tlogelaMothalo();

  baya();
  sutisa(pebaX, pebaY);

  // dikgolokwe tse di fa tlase di thadilwe go dikologa (0, 0),
  // mme (0, 0) e mo pebeng jaanong
  tlatsaMmala(240, 200, 90);
  thalaSediko(0, 0, 60);
  tlatsaMmala(250);
  thalaSediko(-14, -10, 18);
  thalaSediko(14, -10, 18);

  tsaya();

  // e e thadilwe morago ga tsaya ga e a sutisiwa
  tlatsaMmala(120, 200, 150);
  thalaSekwere(20, 20, 30);
}

dikolosa, godisa, baya, tsaya, simololaGape