Skip to content

variables

Classes:

Attributes:

ExprOtherT module-attribute

ExprOtherT: TypeAlias = ExprVar | LiteralVar | int | float

resolverT module-attribute

resolverT: TypeAlias = Callable[..., LiteralVar]

ClipPropsVar

ClipPropsVar(clip_var: ClipVar)

Attributes:

Source code
266
267
def __init__(self, clip_var: ClipVar) -> None:
    self.clip_var = clip_var

PlaneStatsAverage instance-attribute

PlaneStatsAverage: ComputedVar

PlaneStatsMax instance-attribute

PlaneStatsMax: ComputedVar

PlaneStatsMin instance-attribute

PlaneStatsMin: ComputedVar

clip_var instance-attribute

clip_var = clip_var

ClipVar

ClipVar(char: str, clip: VideoNode, parent_expr: inline_expr)

Bases: ExprVar

Methods:

Attributes:

Source code
277
278
279
280
281
def __init__(self, char: str, clip: vs.VideoNode, parent_expr: inline_expr) -> None:
    self.char = char
    self.clip = clip
    self.parent_expr = parent_expr
    self.props = ClipPropsVar(self)

char instance-attribute

char = char

clip instance-attribute

clip = clip

depth property

depth: LiteralVar

height property

height: LiteralVar

height_chroma property

height_chroma: LiteralVar

height_luma property

height_luma: LiteralVar

lowest property

lowest: LiteralVar

lowest_chroma property

lowest_chroma: LiteralVar

neutral property

neutral: LiteralVar

neutral_chroma property

neutral_chroma: LiteralVar

parent_expr instance-attribute

parent_expr: inline_expr = parent_expr

peak property

peak: LiteralVar

peak_chroma property

peak_chroma: LiteralVar

props instance-attribute

props = ClipPropsVar(self)

width property

width: LiteralVar

width_chroma property

width_chroma: LiteralVar

width_luma property

width_luma: LiteralVar

as_var

as_var() -> ComputedVar
Source code
194
195
196
197
def as_var(self) -> ComputedVar:
    if isinstance(self, ComputedVar):
        return self
    return ComputedVar([self])

assert_in_context

assert_in_context() -> Literal[True] | NoReturn
Source code
185
186
187
188
189
190
191
192
def assert_in_context(self) -> Literal[True] | NoReturn:
    if not self.parent_expr:
        return True

    if not self.parent_expr._in_context:
        raise ValueError('You can only access this variable in context!')

    return True

scale

scale(
    value: float,
    input_depth: int = 8,
    range_in: ColorRangeT | None = None,
    range_out: ColorRangeT | None = None,
    scale_offsets: bool = True,
    family: ColorFamily | None = None,
) -> ComplexVar
Source code
357
358
359
360
361
362
363
364
365
366
367
368
def scale(
    self, value: float, input_depth: int = 8, range_in: ColorRangeT | None = None,
    range_out: ColorRangeT | None = None, scale_offsets: bool = True, family: vs.ColorFamily | None = None,
) -> ComplexVar:
    @ComplexVar.resolver
    def _resolve(plane: int = 0, **kwargs: Any) -> Any:
        return scale_value(
            value, input_depth, get_depth(self.clip),
            range_in, range_out, scale_offsets, plane in {1, 2}, family
        )

    return ComplexVar(f'{self.char}.scale({value})', _resolve)

to_str

to_str(**kwargs: Any) -> str
Source code
182
183
def to_str(self, **kwargs: Any) -> str:
    return str(self)

ComplexVar dataclass

ComplexVar(value: int | float | str, resolve: resolverT)

Bases: LiteralVar

Methods:

Attributes:

parent_expr instance-attribute

parent_expr: None

resolve instance-attribute

resolve: resolverT

value instance-attribute

value: int | float | str

as_var

as_var() -> ComputedVar
Source code
194
195
196
197
def as_var(self) -> ComputedVar:
    if isinstance(self, ComputedVar):
        return self
    return ComputedVar([self])

assert_in_context

assert_in_context() -> Literal[True] | NoReturn
Source code
185
186
187
188
189
190
191
192
def assert_in_context(self) -> Literal[True] | NoReturn:
    if not self.parent_expr:
        return True

    if not self.parent_expr._in_context:
        raise ValueError('You can only access this variable in context!')

    return True

resolver staticmethod

resolver() -> Callable[[Callable[..., Any]], resolverT]
resolver(function: Callable[..., Any] | None = None) -> resolverT
resolver(
    function: Callable[..., Any] | None = None,
) -> Callable[[Callable[..., Any]], resolverT] | resolverT
Source code
248
249
250
251
252
253
254
255
256
257
@staticmethod
def resolver(function: Callable[..., Any] | None = None) -> Callable[[Callable[..., Any]], resolverT] | resolverT:
    if function is None:
        return cast(Callable[[Callable[..., Any]], resolverT], ComplexVar.resolver)

    @wraps(function)
    def _wrapper(*args: Any, **kwargs: Any) -> Any:
        return LiteralVar(function(*args, **kwargs))

    return cast(resolverT, _wrapper)

to_str

to_str(**kwargs: Any) -> str
Source code
235
236
def to_str(self, **kwargs: Any) -> str:
    return str(self.resolve(**kwargs))

ComputedVar

ComputedVar(operations: Iterable[BaseOperator | ExprVar])

Bases: ExprVar

Methods:

Attributes:

Source code
214
215
216
217
218
def __init__(self, operations: Iterable[BaseOperator | ExprVar]) -> None:
    self.operations = list(operations)
    self.parent_expr = next(
        (x.parent_expr if isinstance(x, (ComputedVar, ClipVar)) else None for x in self.operations), None
    )

operations instance-attribute

operations = list(operations)

parent_expr instance-attribute

parent_expr = next(
    parent_expr if isinstance(x, (ComputedVar, ClipVar)) else None
    for x in operations, None
)

as_var

as_var() -> ComputedVar
Source code
194
195
196
197
def as_var(self) -> ComputedVar:
    if isinstance(self, ComputedVar):
        return self
    return ComputedVar([self])

assert_in_context

assert_in_context() -> Literal[True] | NoReturn
Source code
185
186
187
188
189
190
191
192
def assert_in_context(self) -> Literal[True] | NoReturn:
    if not self.parent_expr:
        return True

    if not self.parent_expr._in_context:
        raise ValueError('You can only access this variable in context!')

    return True

to_str

to_str(**kwargs: Any) -> str
Source code
220
221
def to_str(self, **kwargs: Any) -> str:
    return ' '.join([x.to_str(**kwargs) for x in self.operations])

ExprVar

Bases: int

Methods:

Attributes:

parent_expr instance-attribute

parent_expr: inline_expr | None

as_var

as_var() -> ComputedVar
Source code
194
195
196
197
def as_var(self) -> ComputedVar:
    if isinstance(self, ComputedVar):
        return self
    return ComputedVar([self])

assert_in_context

assert_in_context() -> Literal[True] | NoReturn
Source code
185
186
187
188
189
190
191
192
def assert_in_context(self) -> Literal[True] | NoReturn:
    if not self.parent_expr:
        return True

    if not self.parent_expr._in_context:
        raise ValueError('You can only access this variable in context!')

    return True

to_str

to_str(**kwargs: Any) -> str
Source code
182
183
def to_str(self, **kwargs: Any) -> str:
    return str(self)

LiteralVar

LiteralVar(value: int | float | str)

Bases: ExprVar

Methods:

Attributes:

Source code
203
204
def __init__(self, value: int | float | str):
    self.value = value

parent_expr instance-attribute

parent_expr: None

value instance-attribute

value = value

as_var

as_var() -> ComputedVar
Source code
194
195
196
197
def as_var(self) -> ComputedVar:
    if isinstance(self, ComputedVar):
        return self
    return ComputedVar([self])

assert_in_context

assert_in_context() -> Literal[True] | NoReturn
Source code
185
186
187
188
189
190
191
192
def assert_in_context(self) -> Literal[True] | NoReturn:
    if not self.parent_expr:
        return True

    if not self.parent_expr._in_context:
        raise ValueError('You can only access this variable in context!')

    return True

to_str

to_str(**kwargs: Any) -> str
Source code
182
183
def to_str(self, **kwargs: Any) -> str:
    return str(self)