RectangleComponent.relative constructor

RectangleComponent.relative(
  1. Vector2 relation, {
  2. required Vector2 parentSize,
  3. Vector2? position,
  4. Vector2? scale,
  5. double? angle,
  6. Anchor? anchor,
  7. int? priority,
  8. Paint? paint,
  9. List<Paint>? paintLayers,
  10. bool? shrinkToBounds,
  11. ComponentKey? key,
  12. List<Component>? children,
})

With this constructor you define the RectangleComponent in relation to the parentSize. For example having relation as of (0.8, 0.5) would create a rectangle that fills 80% of the width and 50% of the height of parentSize.

Implementation

RectangleComponent.relative(
  Vector2 relation, {
  required super.parentSize,
  super.position,
  super.scale,
  super.angle,
  super.anchor,
  super.priority,
  super.paint,
  super.paintLayers,
  super.shrinkToBounds,
  super.key,
  super.children,
}) : super.relative([
        relation.clone(),
        Vector2(relation.x, -relation.y),
        -relation,
        Vector2(-relation.x, relation.y),
      ]) {
  size.addListener(
    () => refreshVertices(
      newVertices: sizeToVertices(size, anchor),
      shrinkToBoundsOverride: false,
    ),
  );
}