fix: scale track point radius by output size
This commit is contained in:
@@ -24,6 +24,7 @@ def _list_audio_wavs() -> list[str]:
|
||||
_MIN_RADIUS = 2
|
||||
_MAX_RADIUS = 8
|
||||
_MAX_TRAIL = 50
|
||||
_REF_SHORT_SIDE = 1080
|
||||
|
||||
|
||||
# ---------------------------------------------------------------------------
|
||||
@@ -224,13 +225,16 @@ class DrawRhythmTracks(io.ComfyNode):
|
||||
|
||||
coords = torch.stack([coords_x, coords_y], dim=-1)
|
||||
render_frames = torch.zeros(num_frames, height, width, 3, device=device)
|
||||
radius_scale = min(width, height) / _REF_SHORT_SIDE
|
||||
|
||||
for t in range(num_frames):
|
||||
start = max(0, t - _MAX_TRAIL)
|
||||
for source_frame in range(start, t + 1):
|
||||
age = t - source_frame
|
||||
ratio = 1.0 - age / _MAX_TRAIL
|
||||
radius = _MIN_RADIUS + (_MAX_RADIUS - _MIN_RADIUS) * ratio
|
||||
radius = (
|
||||
_MIN_RADIUS + (_MAX_RADIUS - _MIN_RADIUS) * ratio
|
||||
) * radius_scale
|
||||
color = _trail_color(ratio, device)
|
||||
x, y = coords[source_frame].tolist()
|
||||
_draw_filled_circle(render_frames[t], x, y, radius, color)
|
||||
|
||||
Reference in New Issue
Block a user