|
33 | 33 | _maybe_set_colors, |
34 | 34 | _next_palette_colors, |
35 | 35 | _prepare_cmap_norm, |
| 36 | + _resolve_outline_toggle, |
36 | 37 | _set_outline, |
37 | 38 | ) |
38 | 39 | from spatialdata_plot.pl._validate import ( |
@@ -324,6 +325,7 @@ def render_shapes( |
324 | 325 | groups: list[str] | str | None = None, |
325 | 326 | palette: dict[str, str] | list[str] | str | None = None, |
326 | 327 | na_color: ColorLike | None = "default", |
| 328 | + outline: bool | None = None, |
327 | 329 | outline_width: float | int | tuple[float | int, float | int] | None = None, |
328 | 330 | outline_color: ColorLike | tuple[ColorLike] | None = None, |
329 | 331 | outline_alpha: float | int | tuple[float | int, float | int] | None = None, |
@@ -387,6 +389,10 @@ def render_shapes( |
387 | 389 | elements are hidden. Pass any explicit color (e.g. ``"lightgray"``) to show them in that color instead. |
388 | 390 | Accepts a named color (``"red"``), a hex string (``"#000000ff"``), or an RGB/RGBA list |
389 | 391 | (``[1.0, 0.0, 0.0, 1.0]``). Pass ``None`` to make NA values fully transparent. |
| 392 | + outline : bool | None, default None |
| 393 | + Convenience on/off switch. ``None`` infers visibility from the ``outline_*`` params; |
| 394 | + ``True`` forces an outline on (defaults fill in any unset width/color/alpha); ``False`` |
| 395 | + forces it off, overriding and warning about any ``outline_*`` you set. |
390 | 396 | outline_width : float | int | tuple[float | int, float | int], optional |
391 | 397 | Width of the border. If 2 values are given (tuple), 2 borders are shown with these widths (outer & inner). |
392 | 398 | If `outline_color` and/or `outline_alpha` are used to indicate that one/two outlines should be drawn, the |
@@ -465,6 +471,9 @@ def render_shapes( |
465 | 471 | """ |
466 | 472 | if as_points: |
467 | 473 | _validate_as_points_size(size) |
| 474 | + outline_alpha = _resolve_outline_toggle( |
| 475 | + outline, outline_alpha, outline_width is not None or outline_color is not None |
| 476 | + ) |
468 | 477 | panel_param_dicts = _expand_color_panels( |
469 | 478 | self._sdata, |
470 | 479 | color, |
@@ -967,6 +976,7 @@ def render_labels( |
967 | 976 | cmap: Colormap | str | None = None, |
968 | 977 | norm: Normalize | None = None, |
969 | 978 | na_color: ColorLike | None = "default", |
| 979 | + outline: bool | None = None, |
970 | 980 | outline_alpha: float | int = 0.0, |
971 | 981 | fill_alpha: float | int | None = None, |
972 | 982 | outline_color: ColorLike | None = None, |
@@ -1028,6 +1038,10 @@ def render_labels( |
1028 | 1038 | labels are hidden. Pass any explicit color (e.g. ``"lightgray"``) to show them in that color instead. |
1029 | 1039 | Accepts a named color (``"red"``), a hex string (``"#000000ff"``), or an RGB/RGBA list |
1030 | 1040 | (``[1.0, 0.0, 0.0, 1.0]``). Pass ``None`` to make NA values fully transparent. |
| 1041 | + outline : bool | None, default None |
| 1042 | + Convenience on/off switch; thickness is set by ``contour_px``. ``None`` infers visibility from |
| 1043 | + ``outline_color``/``outline_alpha``; ``True`` forces on (alpha defaults to 1.0); ``False`` |
| 1044 | + forces it off, overriding and warning about any params you set. |
1031 | 1045 | outline_alpha : float | int, default 0.0 |
1032 | 1046 | Alpha value for the outline of the labels. Invisible by default. |
1033 | 1047 | fill_alpha : float | int | None, optional |
@@ -1077,6 +1091,7 @@ def render_labels( |
1077 | 1091 | """ |
1078 | 1092 | if as_points: |
1079 | 1093 | _validate_as_points_size(size) |
| 1094 | + outline_alpha = cast("float | int", _resolve_outline_toggle(outline, outline_alpha, outline_color is not None)) |
1080 | 1095 | panel_param_dicts = _expand_color_panels( |
1081 | 1096 | self._sdata, |
1082 | 1097 | color, |
|
0 commit comments