getTrianglePath method

Path getTrianglePath(
  1. double x,
  2. double y
)

Constructs the triangular path for the given dimensions.

Creates a downward-pointing triangle path with the apex at the bottom center and the base along the top edge.

Parameters:

  • x: Width of the triangle
  • y: Height of the triangle

Returns a Path object defining the triangle's shape.

The triangle vertices are positioned at:

  • Top-left: (0, 0)
  • Bottom-center: (x/2, y)
  • Top-right: (x, 0)

Implementation

Path getTrianglePath(double x, double y) {
  return Path()
    ..moveTo(0, 0) // Start at the top-left corner
    ..lineTo(x / 2, y) // Draw line to the middle bottom
    ..lineTo(x, 0) // Draw line to the top-right corner
    ..close(); // Close the path
}