renderTree method
Renders the world as seen through this camera.
If the world is not mounted yet, only the viewport and viewfinder elements will be rendered.
Implementation
@override
void renderTree(Canvas canvas) {
canvas.save();
canvas.translate(
viewport.position.x - viewport.anchor.x * viewport.size.x,
viewport.position.y - viewport.anchor.y * viewport.size.y,
);
// Render the world through the viewport
if ((world?.isMounted ?? false) &&
currentCameras.length < maxCamerasDepth) {
canvas.save();
viewport.clip(canvas);
viewport.transformCanvas(canvas);
backdrop.renderTree(canvas);
canvas.save();
try {
currentCameras.add(this);
canvas.transform2D(viewfinder.transform);
world!.renderFromCamera(canvas);
// Render the viewfinder elements, which will be in front of the world,
// but with the same transforms applied to them.
viewfinder.renderTree(canvas);
} finally {
currentCameras.removeLast();
}
canvas.restore();
// Render the viewport elements, which will be in front of the world.
viewport.renderTree(canvas);
canvas.restore();
}
canvas.restore();
}