Scale Bar¶
compute_scale_bar¶
compute_scale_bar ¶
compute_scale_bar(um_per_pixel: float | None, screen_pixels_per_image_pixel: float, *, target_screen_px: float = 120.0, min_screen_px: float = 70.0, max_screen_px: float = 180.0) -> ScaleBarSpec | None
Choose a human-friendly scale bar size for the current zoom.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
um_per_pixel
|
float | None
|
Physical pixel size in µm. Returns None if unavailable. |
required |
screen_pixels_per_image_pixel
|
float
|
Current zoom factor (screen pixels per image pixel). |
required |
target_screen_px
|
float
|
Desired on-screen length of the bar in pixels. |
120.0
|
min_screen_px
|
float
|
Acceptable range of on-screen bar lengths. |
70.0
|
max_screen_px
|
float
|
Acceptable range of on-screen bar lengths. |
70.0
|
Returns:
| Type | Description |
|---|---|
ScaleBarSpec | None
|
Scale bar specification, or None if pixel size is unknown. |
ScaleBarSpec¶
ScaleBarSpec
dataclass
¶
Description of a scale bar to draw on screen.