set2DProjection method
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. Defaults to the canvas client width.height
: The height of the view. Defaults to the canvas client height.
After calculating the matrix, it calls setProjectionMatrix.
Implementation
void set2DProjection({double x = 0.0, double y = 0.0, double? width, double? height}) {
final double w = width ?? _canvas.clientWidth.toDouble();
final double h = height ?? _canvas.clientHeight.toDouble();
setProjectionMatrix(makeOrthographicMatrix(x, x + w, y + h, y, -1, 1));
}