Skip to content
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions rendercanvas/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -550,6 +550,25 @@ def get_pixel_ratio(self) -> float:
"""
return self.__size_info["total_pixel_ratio"]

def get_zoom(self) -> float:
"""Get the zoom factor.

The zoom factor is similar to the zoom setting in browsers; it's a
fraction (in browsers it's a percentage) that can be used to enlarge
rendered objects that are sized in logical pixels. Increasing the zoom
factor reduces the logical size of the canvas.

More technically, the zoom factor represents a canvas-specific
pixel-ratio, which is multiplied with the backend-specified pixel-ratio
(which usually matches the OS pixel ratio).
"""
return self.__size_info["canvas_pixel_ratio"]

def set_zoom(self, zoom: float) -> None:
"""Set the zoom factor."""
self.__size_info["canvas_pixel_ratio"] = float(zoom)
self.__resolve_total_pixel_ratio_and_logical_size()

def close(self) -> None:
"""Close the canvas."""
# Clear the draw-function, to avoid it holding onto e.g. wgpu objects.
Expand Down