RectangleComponent.fromRect constructor

RectangleComponent.fromRect(
  1. Rect rect, {
  2. Vector2? scale,
  3. double? angle,
  4. Anchor anchor = Anchor.topLeft,
  5. int? priority,
  6. Paint? paint,
  7. List<Paint>? paintLayers,
  8. ComponentKey? key,
  9. List<Component>? children,
})

This factory will create a RectangleComponent from a positioned Rect.

Implementation

factory RectangleComponent.fromRect(
  Rect rect, {
  Vector2? scale,
  double? angle,
  Anchor anchor = Anchor.topLeft,
  int? priority,
  Paint? paint,
  List<Paint>? paintLayers,
  ComponentKey? key,
  List<Component>? children,
}) {
  return RectangleComponent(
    position: anchor == Anchor.topLeft
        ? rect.topLeft.toVector2()
        : Anchor.topLeft.toOtherAnchorPosition(
            rect.topLeft.toVector2(),
            anchor,
            rect.size.toVector2(),
          ),
    size: rect.size.toVector2(),
    scale: scale,
    angle: angle,
    anchor: anchor,
    priority: priority,
    paint: paint,
    paintLayers: paintLayers,
    key: key,
    children: children,
  );
}