renderAt method

void renderAt(
  1. Vector2 p,
  2. void fn(
    1. Canvas
    )
)

Utility method to render stuff on a specific place in an isolated way.

Some render methods don't allow to pass a vector. This method translate the canvas before rendering your fn. The changes are reset after the fn is run.

Implementation

void renderAt(Vector2 p, void Function(Canvas) fn) {
  save();
  translateVector(p);
  fn(this);
  restore();
}