anyplotlib 0.7.2__py3-none-any.whl → 0.7.3__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
anyplotlib/figure_esm.js CHANGED
@@ -8182,7 +8182,13 @@ fn fs(in : VsOut) -> @location(0) vec4<f32> {
8182
8182
  // outer radius handle
8183
8183
  if (Math.hypot(mx - (ccx + cr), my - ccy) <= HR)
8184
8184
  return { idx:i, mode:'resize_r', snapW:{...w}, startMX:mx, startMY:my };
8185
- // body (inside ring ± tolerance)
8185
+ // body (inside ring ± tolerance). `lock_center` refuses the grab
8186
+ // outright rather than letting the drag run and correcting afterwards:
8187
+ // a centre snapped back on release still tracks the cursor for the
8188
+ // whole drag, which reads as a broken lock. Refusing here also leaves
8189
+ // the hover cursor at 'default' and lets the drag fall through to the
8190
+ // plot's own pan, so the ring is simply not a handle any more.
8191
+ if (w.lock_center) continue;
8186
8192
  if (Math.abs(Math.hypot(mx-ccx, my-ccy) - cr) <= Math.max(HR, cr*0.18) ||
8187
8193
  Math.hypot(mx-ccx, my-ccy) <= HR)
8188
8194
  return { idx:i, mode:'move', snapW:{...w}, startMX:mx, startMY:my };
@@ -8441,7 +8447,9 @@ fn fs(in : VsOut) -> @location(0) vec4<f32> {
8441
8447
  }
8442
8448
 
8443
8449
  if (w.type === 'circle') {
8444
- if (d.mode === 'move') {
8450
+ // A drag already in flight when `lock_center` is turned on must not keep
8451
+ // translating the widget: the hit-test gate only runs at grab time.
8452
+ if (d.mode === 'move' && !w.lock_center) {
8445
8453
  w.cx = s.cx + dix; w.cy = s.cy + diy;
8446
8454
  } else if (d.mode === 'resize_r') {
8447
8455
  // distance from centre in image-px
@@ -1731,15 +1731,24 @@ class Plot2D(_BasePlot, _PanelMixin, _MarkerMixin):
1731
1731
  def add_circle_widget(self, cx: float | None = None, cy: float | None = None,
1732
1732
  r: float | None = None, color: str = "#00e5ff",
1733
1733
  linewidth: float = 2,
1734
- show_handles: bool = True) -> CircleWidget:
1735
- """Add a draggable circle overlay."""
1734
+ show_handles: bool = True,
1735
+ lock_center: bool = False) -> CircleWidget:
1736
+ """Add a draggable circle overlay.
1737
+
1738
+ ``lock_center`` pins the centre and leaves only the radius draggable —
1739
+ a grab on the ring body is refused and pans the plot instead. Use it
1740
+ when the centre is fixed by the data (a ring on a power spectrum is
1741
+ centred on the DC term), so it cannot be nudged off and silently
1742
+ corrupt every radius measured from it.
1743
+ """
1736
1744
  iw, ih = self._state["image_width"], self._state["image_height"]
1737
1745
  widget = CircleWidget(lambda: None,
1738
1746
  cx=float(cx) if cx is not None else iw / 2,
1739
1747
  cy=float(cy) if cy is not None else ih / 2,
1740
1748
  r=float(r) if r is not None else iw * 0.1,
1741
1749
  color=color, linewidth=linewidth,
1742
- show_handles=show_handles)
1750
+ show_handles=show_handles,
1751
+ lock_center=lock_center)
1743
1752
  widget._push_fn = self._make_widget_push_fn(widget)
1744
1753
  self._widgets[widget.id] = widget
1745
1754
  self._push()
@@ -74,13 +74,29 @@ class CircleWidget(Widget):
74
74
  Outline stroke width in px. Default 2.
75
75
  show_handles : bool, optional
76
76
  Draw the radius grab handle. Default ``True``.
77
+ lock_center : bool, optional
78
+ Pin ``cx, cy`` and let only the radius change. Default ``False``.
79
+
80
+ The centre is refused at HIT-TEST time, not corrected afterwards: a
81
+ grab on the ring body is simply not a widget grab, so it falls through
82
+ to the plot's own pan and the hover cursor never promises a move.
83
+ Enforcing it from Python instead — snapping the centre back when the
84
+ drag settles — cannot work, because the JS drag recomputes the position
85
+ from its own grab-time snapshot on every frame; the ring tracks the
86
+ cursor for the whole drag and only jumps back on release.
87
+
88
+ Use it when the centre is not a free parameter — a ring on a power
89
+ spectrum is centred on the DC term, so a draggable centre is a control
90
+ that can only ever be wrong, and one nudged off-centre silently
91
+ corrupts every radius measured from it.
77
92
  """
78
93
  def __init__(self, push_fn, *, cx, cy, r, color="#00e5ff",
79
- linewidth=2, show_handles=True):
94
+ linewidth=2, show_handles=True, lock_center=False):
80
95
  super().__init__("circle", push_fn,
81
96
  cx=float(cx), cy=float(cy), r=float(r), color=color,
82
97
  linewidth=float(linewidth),
83
- show_handles=bool(show_handles))
98
+ show_handles=bool(show_handles),
99
+ lock_center=bool(lock_center))
84
100
 
85
101
 
86
102
  class AnnularWidget(Widget):
@@ -1,6 +1,6 @@
1
- Metadata-Version: 2.4
1
+ Metadata-Version: 2.5
2
2
  Name: anyplotlib
3
- Version: 0.7.2
3
+ Version: 0.7.3
4
4
  Summary: A plotting library using python, javascript and anywidget for performant in browser plotting.
5
5
  Project-URL: Homepage, https://cssfrancis.github.io/anyplotlib/
6
6
  Project-URL: Repository, https://github.com/CSSFrancis/anyplotlib
@@ -6,7 +6,7 @@ anyplotlib/_repr_utils.py,sha256=DZM2mTTX7lpg9LaqHjOVNvnYSVRKNaKrJvEYBmdQ5A4,191
6
6
  anyplotlib/_utils.py,sha256=fvkMnNiCljG11p6Fsn2engKzsYhI1ILcZE5wog5Rcu0,14584
7
7
  anyplotlib/callbacks.py,sha256=lTmL-UYPN6y0VY82MqDKSMTqBgUgezbSM7SoP8t5s0o,14620
8
8
  anyplotlib/embed.py,sha256=cSDgjRSwqaJb6OvuJ5g3QFlNg0k0EEQH48VtVaR0K_I,7389
9
- anyplotlib/figure_esm.js,sha256=bPU56QCD5lA0Ut_kjvWV79PeX9g4ABbrO5kMyTtjWEY,477090
9
+ anyplotlib/figure_esm.js,sha256=cNABIgGsjbc3zOLHmn0gYti5tFHhb_wOs4UpNRaZOGw,477718
10
10
  anyplotlib/keys.py,sha256=nmzrppnuuh3K-JYV6rsat-MGWiaZxfJjO-IDN8Ruzdo,9307
11
11
  anyplotlib/markers.py,sha256=e6r2t8lFs9c5OjkxeRsV1Le34G7icJRgO2ciPx3e5nM,26870
12
12
  anyplotlib/axes/__init__.py,sha256=vsMU_WjFcha17Xozxe7v4_oYQ_6qatk8GZlbwKm-cAc,186
@@ -21,7 +21,7 @@ anyplotlib/plot1d/_plot1d.py,sha256=H0bK4ThKV-3haxs0ish48Ye65M-K9KRNwzoFRNTXjso,
21
21
  anyplotlib/plot1d/_plotbar.py,sha256=2hbj3I86TJr5Zds4a179iNQ9CyQTG8ys9MqY8xBTX_Y,17356
22
22
  anyplotlib/plot2d/__init__.py,sha256=_BVLJeGKuTmlZPpfPW2d99qRamBvOSyx3hsru7ylTzk,264
23
23
  anyplotlib/plot2d/_layer.py,sha256=gONf5R2bYsf_Oymx3Y0RmPrTvFDzVnbDGBKFWkhyAKM,5598
24
- anyplotlib/plot2d/_plot2d.py,sha256=w1p0eIm_MQnacBZsvZ5yKV9YpR3ybM0qH-aHHwH-7Rc,119353
24
+ anyplotlib/plot2d/_plot2d.py,sha256=zf6AKRa8_renfTLXRywmMw68N9uoFLBDskjQpH24kyk,119825
25
25
  anyplotlib/plot2d/_plotmesh.py,sha256=qXOsiQQ13yhPar5KToAIz02sqivdKz3eXcHI7QZsv04,4547
26
26
  anyplotlib/plot2d/_tile_backend.py,sha256=BfJ0X-AbWJvImeNcBW9PzkO3b-JQ_CDBP3vOfdNocOw,7225
27
27
  anyplotlib/plot3d/__init__.py,sha256=m851XQKGzx5bywIbBK0qntBxzJU7zwxqf6xnOQ8pD1M,138
@@ -38,9 +38,9 @@ anyplotlib/sphinx_anywidget/static/anywidget_overlay.css,sha256=TlIWo4OUsEZFNROH
38
38
  anyplotlib/widgets/__init__.py,sha256=uzGX0R_X4xw8c2MJTGPBeaoOucJznWN1Vzcj2YNRGG8,723
39
39
  anyplotlib/widgets/_base.py,sha256=WMY_s_KKNVpd-3VceAwZeY5JHhtvJp1nuVbYkmqNiBw,9512
40
40
  anyplotlib/widgets/_widgets1d.py,sha256=SXnBDm25th1u9lPHlpQIdVACaQcVCvKUeF-ZJ9VMeVs,7784
41
- anyplotlib/widgets/_widgets2d.py,sha256=XZmqmgRq7g0P2-xkC2hMRPfZFtq8t-nfjbRc7w2wIXA,19938
41
+ anyplotlib/widgets/_widgets2d.py,sha256=mP0m6yA4cSB2hD71AVpik_FwUHzPCiLYBfju21G5DWk,20930
42
42
  anyplotlib/widgets/_widgets3d.py,sha256=zRd2q5O2KePxU5raCnvO-LatMlpGQjnDMPhG61d40Ks,1638
43
- anyplotlib-0.7.2.dist-info/METADATA,sha256=IyT9uH8qJxx6r-0zp3yeeayG9yBxI0B3DXk9rfImZY0,7163
44
- anyplotlib-0.7.2.dist-info/WHEEL,sha256=lCkmxWfQsSc9CfIClYeavTdQeEX2toPqufh9gI35EQA,87
45
- anyplotlib-0.7.2.dist-info/licenses/LICENSE,sha256=NonSXCjWxcYbaMxPnkgFzPpP0bVBTwUDpuDKyKC2uvQ,1071
46
- anyplotlib-0.7.2.dist-info/RECORD,,
43
+ anyplotlib-0.7.3.dist-info/METADATA,sha256=FLbLHYJSpO91KLIo6MN90DY0MBvwWOHAf9OrXnOS988,7163
44
+ anyplotlib-0.7.3.dist-info/WHEEL,sha256=zOwg4jB6zX2kU910N-cMawjivD6tO8NEWvE12je1bVk,87
45
+ anyplotlib-0.7.3.dist-info/licenses/LICENSE,sha256=NonSXCjWxcYbaMxPnkgFzPpP0bVBTwUDpuDKyKC2uvQ,1071
46
+ anyplotlib-0.7.3.dist-info/RECORD,,
@@ -1,4 +1,4 @@
1
1
  Wheel-Version: 1.0
2
- Generator: hatchling 1.31.0
2
+ Generator: hatchling 1.32.0
3
3
  Root-Is-Purelib: true
4
4
  Tag: py3-none-any