TextElementComponent.fromDocument constructor

TextElementComponent.fromDocument({
  1. required DocumentRoot document,
  2. DocumentStyle? style,
  3. Vector2? position,
  4. Vector2? size,
  5. Vector2? scale,
  6. double? angle,
  7. Anchor? anchor,
  8. List<Component>? children,
  9. int priority = 0,
  10. ComponentKey? key,
})

Implementation

factory TextElementComponent.fromDocument({
  required DocumentRoot document,
  DocumentStyle? style,
  Vector2? position,
  Vector2? size,
  Vector2? scale,
  double? angle,
  Anchor? anchor,
  List<Component>? children,
  int priority = 0,
  ComponentKey? key,
}) {
  final effectiveStyle = style ?? DocumentStyle();
  final effectiveSize = _coalesceSize(effectiveStyle, size);
  final element = document.format(
    effectiveStyle,
    width: effectiveSize.x,
    height: effectiveSize.y,
  );
  final box = element.boundingBox;
  return TextElementComponent(
    element: element,
    position: position,
    documentSize: effectiveSize,
    size: box.bottomRight.toVector2(),
    scale: scale,
    angle: angle,
    anchor: anchor,
    children: children,
    priority: priority,
    key: key,
  );
}