kopia lustrzana https://github.com/corrscope/corrscope
Improve config organization and defaults (#84)
`Config` defaults are optional attributes. `default_config` defaults are template values.pull/357/head
rodzic
78d4512fb9
commit
6d312f5de4
|
@ -34,15 +34,12 @@ class BenchmarkMode(IntEnum):
|
|||
|
||||
@kw_config(always_dump='render_subfps begin_time end_time subsampling')
|
||||
class Config:
|
||||
""" Default values indicate optional attributes. """
|
||||
master_audio: Optional[str]
|
||||
begin_time: float = 0
|
||||
end_time: Optional[float] = None
|
||||
|
||||
fps: int
|
||||
render_subfps: int = 1
|
||||
# FFmpeg accepts FPS as a fraction only.
|
||||
render_fps = property(lambda self:
|
||||
Fraction(self.fps, self.render_subfps))
|
||||
|
||||
width_ms: int
|
||||
|
||||
|
@ -52,6 +49,11 @@ class Config:
|
|||
render_subsampling: int = None
|
||||
_subsampling: int = 1
|
||||
|
||||
render_subfps: int = 1
|
||||
# FFmpeg accepts FPS as a fraction only.
|
||||
render_fps = property(lambda self:
|
||||
Fraction(self.fps, self.render_subfps))
|
||||
|
||||
trigger_width: int = 1
|
||||
render_width: int = 1
|
||||
|
||||
|
@ -99,8 +101,9 @@ class Config:
|
|||
_FPS = 60 # f_s
|
||||
|
||||
def default_config(**kwargs) -> Config:
|
||||
""" Default template values do NOT indicate optional attributes. """
|
||||
cfg = Config(
|
||||
render_subfps=2,
|
||||
render_subfps=1,
|
||||
master_audio='',
|
||||
fps=_FPS,
|
||||
amplification=1,
|
||||
|
@ -118,7 +121,7 @@ def default_config(**kwargs) -> Config:
|
|||
channels=[],
|
||||
|
||||
layout=LayoutConfig(ncols=2),
|
||||
render=RendererConfig(1280, 800),
|
||||
render=RendererConfig(1280, 720),
|
||||
)
|
||||
return attr.evolve(cfg, **kwargs)
|
||||
|
||||
|
|
|
@ -31,14 +31,14 @@ def default_color():
|
|||
return '#8edeff'
|
||||
|
||||
|
||||
@register_config(always_dump='bg_color init_line_color line_width')
|
||||
@register_config(always_dump='line_width bg_color init_line_color')
|
||||
class RendererConfig:
|
||||
width: int
|
||||
height: int
|
||||
line_width: Optional[float] = None
|
||||
|
||||
bg_color: str = 'black'
|
||||
init_line_color: str = default_color()
|
||||
line_width: Optional[float] = None
|
||||
|
||||
create_window: bool = False
|
||||
|
||||
|
|
Ładowanie…
Reference in New Issue