v0.90.0: Lint Oontz can look left or right in three-quarter view (Preferences › Visualizer › Looking)
This commit is contained in:
@@ -417,7 +417,9 @@ persistence) → GUI (Qt widgets that read the manager and connect to its signal
|
|||||||
panel's gray, in **three-quarter view** (default: face turned to our
|
panel's gray, in **three-quarter view** (default: face turned to our
|
||||||
right, the near cup seen whole, the far one clipped to what shows past
|
right, the near cup seen whole, the far one clipped to what shows past
|
||||||
the ball) or **head on** (`visualizer_lint_head_on`, Preferences' View
|
the ball) or **head on** (`visualizer_lint_head_on`, Preferences' View
|
||||||
combo; in `STYLE_KEYS`). The ball is filled with the panel colour so
|
combo; in `STYLE_KEYS`). `visualizer_lint_face_left` (Round 124, the
|
||||||
|
Looking combo, 3/4 only) mirrors the whole drawing about its centre; the
|
||||||
|
z's are only moved, so they still read as z's. The ball is filled with the panel colour so
|
||||||
what's behind it (legs' tops, the far arm in 3/4) is hidden.
|
what's behind it (legs' tops, the far arm in 3/4) is hidden.
|
||||||
**Stop motion**: the renderer steps at 8 fps on its own clock and
|
**Stop motion**: the renderer steps at 8 fps on its own clock and
|
||||||
`advance` is True only on a step; every step re-rolls each line's wobble
|
`advance` is True only on a step; every step re-rolls each line's wobble
|
||||||
|
|||||||
@@ -1,3 +1,3 @@
|
|||||||
"""LinTunes — iTunes-style music library manager and player for Linux."""
|
"""LinTunes — iTunes-style music library manager and player for Linux."""
|
||||||
|
|
||||||
__version__ = "0.89.0"
|
__version__ = "0.90.0"
|
||||||
|
|||||||
@@ -881,11 +881,27 @@ class PreferencesDialog(QDialog):
|
|||||||
view.setCurrentIndex(int(config["visualizer_lint_head_on"])) # before connect
|
view.setCurrentIndex(int(config["visualizer_lint_head_on"])) # before connect
|
||||||
view.setToolTip("Turned a little to one side, one headphone cup "
|
view.setToolTip("Turned a little to one side, one headphone cup "
|
||||||
"behind its head — or facing you")
|
"behind its head — or facing you")
|
||||||
view.currentIndexChanged.connect(
|
facing = QComboBox()
|
||||||
lambda i: self._prefs.set("visualizer_lint_head_on", i == 1))
|
facing.addItems(["Right", "Left"])
|
||||||
|
facing.setSizeAdjustPolicy(QComboBox.SizeAdjustPolicy.AdjustToContents)
|
||||||
|
facing.setCurrentIndex(int(config["visualizer_lint_face_left"]))
|
||||||
|
facing.setToolTip("Which way it looks in three-quarter view")
|
||||||
|
facing.setEnabled(view.currentIndex() == 0)
|
||||||
|
|
||||||
|
def view_chosen(i):
|
||||||
|
facing.setEnabled(i == 0)
|
||||||
|
self._prefs.set("visualizer_lint_head_on", i == 1)
|
||||||
|
|
||||||
|
view.currentIndexChanged.connect(view_chosen)
|
||||||
|
facing.currentIndexChanged.connect(
|
||||||
|
lambda i: self._prefs.set("visualizer_lint_face_left", i == 1))
|
||||||
self._viz_setters["visualizer_lint_head_on"] = (
|
self._viz_setters["visualizer_lint_head_on"] = (
|
||||||
lambda value: view.setCurrentIndex(int(bool(value))))
|
lambda value: view.setCurrentIndex(int(bool(value))))
|
||||||
|
self._viz_setters["visualizer_lint_face_left"] = (
|
||||||
|
lambda value: facing.setCurrentIndex(int(bool(value))))
|
||||||
|
self._lint_view, self._lint_facing = view, facing
|
||||||
form.addRow("View:", view)
|
form.addRow("View:", view)
|
||||||
|
form.addRow("Looking:", facing)
|
||||||
about = QLabel(
|
about = QLabel(
|
||||||
"A ball of lint in headphones: it bobs to the bass, dances when "
|
"A ball of lint in headphones: it bobs to the bass, dances when "
|
||||||
"the music is fast and full, sits down when it goes quiet and "
|
"the music is fast and full, sits down when it goes quiet and "
|
||||||
|
|||||||
@@ -26,7 +26,9 @@ What the music does to it:
|
|||||||
|
|
||||||
Two views (``visualizer_lint_head_on``): three-quarter (the default: the
|
Two views (``visualizer_lint_head_on``): three-quarter (the default: the
|
||||||
face turned to one side, one headphone cup seen whole and the other behind
|
face turned to one side, one headphone cup seen whole and the other behind
|
||||||
the ball) or head on. Same moves in both.
|
the ball) or head on. Same moves in both. Three-quarter looks to our right
|
||||||
|
unless ``visualizer_lint_face_left``: then the whole drawing is mirrored
|
||||||
|
(the z's only moved, so they still read as z's).
|
||||||
|
|
||||||
The lines are the colour the wheel picks — highlight, gray or black
|
The lines are the colour the wheel picks — highlight, gray or black
|
||||||
(``black_mode``: this style adds black to the wheel) — on the panel's gray.
|
(``black_mode``: this style adds black to the wheel) — on the panel's gray.
|
||||||
@@ -42,6 +44,7 @@ from PyQt6.QtGui import QColor, QPainterPath, QPen, QTransform
|
|||||||
|
|
||||||
STYLE = "lint"
|
STYLE = "lint"
|
||||||
HEAD_ON_KEY = "visualizer_lint_head_on"
|
HEAD_ON_KEY = "visualizer_lint_head_on"
|
||||||
|
FACE_LEFT_KEY = "visualizer_lint_face_left" # 3/4 view: looking to our left
|
||||||
FPS = 8 # stop motion: a new drawing this often
|
FPS = 8 # stop motion: a new drawing this often
|
||||||
STEP_S = 1.0 / FPS
|
STEP_S = 1.0 / FPS
|
||||||
INSET = 3
|
INSET = 3
|
||||||
@@ -155,6 +158,7 @@ class LintRenderer:
|
|||||||
self._hair_len = rng.uniform(0.12, 0.3, 9)
|
self._hair_len = rng.uniform(0.12, 0.3, 9)
|
||||||
self._rng = np.random.default_rng(104729)
|
self._rng = np.random.default_rng(104729)
|
||||||
self.head_on = False
|
self.head_on = False
|
||||||
|
self.face_left = False
|
||||||
self._behind = 0.0
|
self._behind = 0.0
|
||||||
self._clock = 0.0
|
self._clock = 0.0
|
||||||
self.step = 1 # 0 would be a blink
|
self.step = 1 # 0 would be a blink
|
||||||
@@ -181,6 +185,7 @@ class LintRenderer:
|
|||||||
|
|
||||||
def configure(self, config):
|
def configure(self, config):
|
||||||
self.head_on = bool(config.get(HEAD_ON_KEY, False))
|
self.head_on = bool(config.get(HEAD_ON_KEY, False))
|
||||||
|
self.face_left = bool(config.get(FACE_LEFT_KEY, False))
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def asleep(self) -> bool:
|
def asleep(self) -> bool:
|
||||||
@@ -364,7 +369,12 @@ class LintRenderer:
|
|||||||
|
|
||||||
ground = cell.bottom() - pen.widthF()
|
ground = cell.bottom() - pen.widthF()
|
||||||
cx = cell.center().x()
|
cx = cell.center().x()
|
||||||
|
mirror = self.face_left and not self.head_on
|
||||||
painter.save()
|
painter.save()
|
||||||
|
if mirror:
|
||||||
|
painter.translate(cx, 0)
|
||||||
|
painter.scale(-1, 1)
|
||||||
|
painter.translate(-cx, 0)
|
||||||
if self.posture == SLEEP:
|
if self.posture == SLEEP:
|
||||||
# Lying on its back, feet to the right: the standing drawing
|
# Lying on its back, feet to the right: the standing drawing
|
||||||
# turned a quarter (rotate(-90) sends "down" to "right").
|
# turned a quarter (rotate(-90) sends "down" to "right").
|
||||||
@@ -373,7 +383,9 @@ class LintRenderer:
|
|||||||
painter.rotate(-90)
|
painter.rotate(-90)
|
||||||
self._body(painter, r, j, 0.0)
|
self._body(painter, r, j, 0.0)
|
||||||
painter.restore()
|
painter.restore()
|
||||||
self._zzz(painter, head + r * 0.5, ground - r * 3.0, r, j)
|
x = head + r * 0.5
|
||||||
|
self._zzz(painter, 2 * cx - x if mirror else x, ground - r * 3.0,
|
||||||
|
r, j, -1 if mirror else 1)
|
||||||
return
|
return
|
||||||
if self.posture == SIT:
|
if self.posture == SIT:
|
||||||
painter.translate(cx, ground - r * 1.1) # the ball on the floor
|
painter.translate(cx, ground - r * 1.1) # the ball on the floor
|
||||||
@@ -551,13 +563,14 @@ class LintRenderer:
|
|||||||
painter.drawPolyline([j(*hip), j(*knee), j(*foot),
|
painter.drawPolyline([j(*hip), j(*knee), j(*foot),
|
||||||
j(foot[0] + toe, foot[1])])
|
j(foot[0] + toe, foot[1])])
|
||||||
|
|
||||||
def _zzz(self, painter, x, y, r, j):
|
def _zzz(self, painter, x, y, r, j, way=1):
|
||||||
"""Little z's rising, a new one every few frames."""
|
"""Little z's rising (drifting ``way``: 1 right, -1 left), a new one
|
||||||
|
every few frames."""
|
||||||
phase = self.step % 12
|
phase = self.step % 12
|
||||||
for k in range(3):
|
for k in range(3):
|
||||||
age = (phase / 4 + k) % 3 # 0..3, how far it has risen
|
age = (phase / 4 + k) % 3 # 0..3, how far it has risen
|
||||||
size = r * (0.18 + 0.08 * age)
|
size = r * (0.18 + 0.08 * age)
|
||||||
zx = x + age * r * 0.3
|
zx = x + way * age * r * 0.3 - (size if way < 0 else 0)
|
||||||
zy = y - age * r * 0.4
|
zy = y - age * r * 0.4
|
||||||
painter.drawPolyline([j(zx, zy), j(zx + size, zy),
|
painter.drawPolyline([j(zx, zy), j(zx + size, zy),
|
||||||
j(zx, zy + size), j(zx + size, zy + size)])
|
j(zx, zy + size), j(zx + size, zy + size)])
|
||||||
|
|||||||
@@ -33,7 +33,7 @@ STYLE_KEYS = {
|
|||||||
"visualizer_laser_glow", "visualizer_laser_grid",
|
"visualizer_laser_glow", "visualizer_laser_grid",
|
||||||
"visualizer_laser_head", "visualizer_laser_dot",
|
"visualizer_laser_head", "visualizer_laser_dot",
|
||||||
"visualizer_laser_grid_dot"),
|
"visualizer_laser_grid_dot"),
|
||||||
"lint": ("visualizer_lint_head_on",),
|
"lint": ("visualizer_lint_head_on", "visualizer_lint_face_left"),
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -78,7 +78,7 @@ LIMITS = {
|
|||||||
}
|
}
|
||||||
_FLAGS = ("visualizer_radial_normalize", "visualizer_laser_head",
|
_FLAGS = ("visualizer_radial_normalize", "visualizer_laser_head",
|
||||||
"visualizer_laser_glow", "visualizer_laser_grid",
|
"visualizer_laser_glow", "visualizer_laser_grid",
|
||||||
"visualizer_lint_head_on")
|
"visualizer_lint_head_on", "visualizer_lint_face_left")
|
||||||
_INTEGER = ("visualizer_radial_spokes", "visualizer_radial_levels",
|
_INTEGER = ("visualizer_radial_spokes", "visualizer_radial_levels",
|
||||||
"visualizer_bars_count",
|
"visualizer_bars_count",
|
||||||
"visualizer_laser_low_hz", "visualizer_laser_high_hz")
|
"visualizer_laser_low_hz", "visualizer_laser_high_hz")
|
||||||
|
|||||||
@@ -36,6 +36,7 @@ DEFAULTS = {
|
|||||||
"visualizer_radial_dot": 1.0, # dot size, × the automatic size
|
"visualizer_radial_dot": 1.0, # dot size, × the automatic size
|
||||||
"visualizer_radial_normalize": True, # even out bass vs treble
|
"visualizer_radial_normalize": True, # even out bass vs treble
|
||||||
"visualizer_lint_head_on": False, # Lint Oontz: head on, not 3/4 view
|
"visualizer_lint_head_on": False, # Lint Oontz: head on, not 3/4 view
|
||||||
|
"visualizer_lint_face_left": False, # … and in 3/4, looking to the left
|
||||||
# Per-area grayscale overrides (0=black .. 255=white). None = inherit the
|
# Per-area grayscale overrides (0=black .. 255=white). None = inherit the
|
||||||
# current/default look for that surface, so nothing changes until the user
|
# current/default look for that surface, so nothing changes until the user
|
||||||
# drags a slider in Preferences.
|
# drags a slider in Preferences.
|
||||||
|
|||||||
@@ -135,3 +135,47 @@ def test_the_view_is_a_setting(qapp, tmp_path):
|
|||||||
r = vs.make_renderer(vs.STYLE_LINT, vs.settings(prefs))
|
r = vs.make_renderer(vs.STYLE_LINT, vs.settings(prefs))
|
||||||
assert r.head_on
|
assert r.head_on
|
||||||
assert vl.HEAD_ON_KEY in presets.STYLE_KEYS["lint"]
|
assert vl.HEAD_ON_KEY in presets.STYLE_KEYS["lint"]
|
||||||
|
|
||||||
|
|
||||||
|
# ---- Round 124: which way the three-quarter view looks ----
|
||||||
|
|
||||||
|
def _differ(a, b):
|
||||||
|
return sum(abs(a.pixelColor(x, y).red() - b.pixelColor(x, y).red()) > 60
|
||||||
|
for x in range(a.width()) for y in range(a.height()))
|
||||||
|
|
||||||
|
|
||||||
|
def test_facing_left_is_the_mirror_image(qapp):
|
||||||
|
for posture in (vl.STAND, vl.SIT):
|
||||||
|
right = vl.LintRenderer({vl.FACE_LEFT_KEY: False})
|
||||||
|
left = vl.LintRenderer({vl.FACE_LEFT_KEY: True})
|
||||||
|
for r in (right, left):
|
||||||
|
r.posture = posture
|
||||||
|
# Same step, same wobble: one is the other flipped (bar a few
|
||||||
|
# antialiased edge pixels), and nothing like it unflipped.
|
||||||
|
a, b = _draw(left), _draw(right)
|
||||||
|
flipped = _differ(a, b.mirrored(True, False))
|
||||||
|
assert flipped < _differ(a, b) / 10
|
||||||
|
|
||||||
|
|
||||||
|
def test_head_on_ignores_facing(qapp):
|
||||||
|
a = vl.LintRenderer({vl.HEAD_ON_KEY: True, vl.FACE_LEFT_KEY: False})
|
||||||
|
b = vl.LintRenderer({vl.HEAD_ON_KEY: True, vl.FACE_LEFT_KEY: True})
|
||||||
|
for r in (a, b):
|
||||||
|
r.posture = vl.STAND
|
||||||
|
assert _draw(a) == _draw(b)
|
||||||
|
|
||||||
|
|
||||||
|
def test_asleep_facing_left_still_draws(qapp):
|
||||||
|
r = vl.LintRenderer({vl.FACE_LEFT_KEY: True})
|
||||||
|
r.posture = vl.SLEEP
|
||||||
|
img = _draw(r)
|
||||||
|
assert any(img.pixelColor(x, y).blue() - img.pixelColor(x, y).red() > 80
|
||||||
|
for x in range(240) for y in range(240))
|
||||||
|
|
||||||
|
|
||||||
|
def test_facing_is_a_setting(qapp, tmp_path):
|
||||||
|
prefs = Preferences(tmp_path)
|
||||||
|
assert vs.settings(prefs)[vl.FACE_LEFT_KEY] is False # right by default
|
||||||
|
prefs.set(vl.FACE_LEFT_KEY, True)
|
||||||
|
assert vs.make_renderer(vs.STYLE_LINT, vs.settings(prefs)).face_left
|
||||||
|
assert vl.FACE_LEFT_KEY in presets.STYLE_KEYS["lint"]
|
||||||
|
|||||||
Reference in New Issue
Block a user