render method

  1. @override
void render(
  1. Canvas canvas,
  2. String text,
  3. Vector2 position, {
  4. Anchor anchor = Anchor.topLeft,
})
inherited

Renders text on the canvas at a given position.

For example, if Anchor.center is specified, it's going to be drawn centered around position.

Implementation

@override
void render(
  Canvas canvas,
  String text,
  Vector2 position, {
  Anchor anchor = Anchor.topLeft,
}) {
  final txt = formatter.format(text);
  final box = txt.metrics;
  txt.translate(
    position.x - box.width * anchor.x,
    position.y - box.height * anchor.y - box.top,
  );
  txt.render(canvas);
}