XTachometer: place numerals by per-label radial extent
Same radial-extent inset as C/Rust: the glyph box farthest corner in the radial direction stays inside the tick ring (inner end r-16) with 4 px clearance, so a wide 4-digit label never crosses the dial rim. Verified by re-shoot; full suite still 363 tests OK.
This commit is contained in:
1 parent
f93dbb8c84
commit
b657b6c360
1 file changed
+10
-2
@@ -1335,8 +1335,16 @@ class MonitorWidget(Widget):
|
||||
cr.restore()
|
||||
if major:
|
||||
label = "%.0f" % (lo + f * (hi - lo))
|
||||
lx = cx + (r - 26) * math.cos(ang)
|
||||
ly = cy + (r - 26) * math.sin(ang) \
|
||||
# Numeral centre radius: the glyph box's farthest
|
||||
# corner in the radial direction must stay inside the
|
||||
# tick ring (inner end r-16) with 4 px clearance, so a
|
||||
# wide 4-digit label never crosses the dial rim.
|
||||
lw = _text_width(cr, self, label, size=numeral_px, bold=True)
|
||||
extent = (lw / 2) * abs(math.cos(ang)) \
|
||||
+ (numeral_px / 2) * abs(math.sin(ang))
|
||||
lr = max(8.0, r - 16 - extent - 4)
|
||||
lx = cx + lr * math.cos(ang)
|
||||
ly = cy + lr * math.sin(ang) \
|
||||
+ numeral_px * 0.35
|
||||
rgb = _RED if f >= red_frac else _TEXT
|
||||
_wtext(cr, self, label, lx, ly, size=numeral_px,
|
||||
|
||||
Reference in new issue
Block a user