set2DProjection method

void set2DProjection({
  1. double x = 0.0,
  2. double y = 0.0,
  3. required double width,
  4. required double height,
})

Configures an orthographic 2D projection matrix.

This is commonly used for 2D games. The projection maps world coordinates directly to screen coordinates.

  • x: The left edge of the view. Defaults to 0.0.
  • y: The top edge of the view. Defaults to 0.0.
  • width: The width of the view.
  • height: The height of the view.

After calculating the matrix, it calls setProjectionMatrix.

Implementation

void set2DProjection({double x = 0.0, double y = 0.0, required double width, required double height}) {
  setProjectionMatrix(makeOrthographicMatrix(x, x + width, y + height, y, -1, 1));
}