debugTextPaint property

TextPaint get debugTextPaint

Returns a TextPaint object with the debugColor set as color for the text.

Implementation

TextPaint get debugTextPaint {
  final viewfinder = CameraComponent.currentCamera?.viewfinder;
  final viewport = CameraComponent.currentCamera?.viewport;
  final zoom = viewfinder?.zoom ?? 1.0;

  final viewportScale = math.max(
    viewport?.transform.scale.x ?? 1,
    viewport?.transform.scale.y ?? 1,
  );

  if (!_debugTextPaintCache.isCacheValid([debugColor])) {
    final textPaint = TextPaint(
      style: TextStyle(
        color: debugColor,
        fontSize: 12 / zoom / viewportScale,
      ),
    );
    _debugTextPaintCache.updateCache(textPaint, [debugColor]);
  }
  return _debugTextPaintCache.value!;
}