PolygonComponent.relative constructor

PolygonComponent.relative(
  1. List<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. bool? shrinkToBounds,
})

With this constructor you define the PolygonComponent in relation to the parentSize of the shape.

Example: [[1.0, 0.0], [0.0, -1.0], [-1.0, 0.0], [0.0, 1.0]] This will form a diamond shape within the bounding size box. NOTE: Always define your shape in a counter-clockwise fashion (in the screen coordinate system).

Implementation

PolygonComponent.relative(
  List<Vector2> relation, {
  required Vector2 parentSize,
  Vector2? position,
  Vector2? scale,
  double? angle,
  Anchor? anchor,
  int? priority,
  Paint? paint,
  bool? shrinkToBounds,
}) : this(
        normalsToVertices(relation, parentSize),
        position: position,
        size: parentSize,
        angle: angle,
        anchor: anchor,
        scale: scale,
        priority: priority,
        paint: paint,
        shrinkToBounds: shrinkToBounds,
      );