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
277
278
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
288
289
290
291
292
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
207
208
209
210
def as_var(self) -> ComputedVar:
    if isinstance(self, ComputedVar):
        return self
    return ComputedVar([self])

assert_in_context

assert_in_context() -> Literal[True]
Source code
198
199
200
201
202
203
204
205
def assert_in_context(self) -> Literal[True]:
    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
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
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
195
196
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
207
208
209
210
def as_var(self) -> ComputedVar:
    if isinstance(self, ComputedVar):
        return self
    return ComputedVar([self])

assert_in_context

assert_in_context() -> Literal[True]
Source code
198
199
200
201
202
203
204
205
def assert_in_context(self) -> Literal[True]:
    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
259
260
261
262
263
264
265
266
267
268
@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
248
249
def to_str(self, **kwargs: Any) -> str:
    return str(self.resolve(**kwargs))

ComputedVar

ComputedVar(operations: Iterable[BaseOperator | ExprVar])

Bases: ExprVar

Methods:

Attributes:

Source code
227
228
229
230
231
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
207
208
209
210
def as_var(self) -> ComputedVar:
    if isinstance(self, ComputedVar):
        return self
    return ComputedVar([self])

assert_in_context

assert_in_context() -> Literal[True]
Source code
198
199
200
201
202
203
204
205
def assert_in_context(self) -> Literal[True]:
    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
233
234
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
207
208
209
210
def as_var(self) -> ComputedVar:
    if isinstance(self, ComputedVar):
        return self
    return ComputedVar([self])

assert_in_context

assert_in_context() -> Literal[True]
Source code
198
199
200
201
202
203
204
205
def assert_in_context(self) -> Literal[True]:
    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
195
196
def to_str(self, **kwargs: Any) -> str:
    return str(self)

LiteralVar

LiteralVar(value: int | float | str)

Bases: ExprVar

Methods:

Attributes:

Source code
216
217
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
207
208
209
210
def as_var(self) -> ComputedVar:
    if isinstance(self, ComputedVar):
        return self
    return ComputedVar([self])

assert_in_context

assert_in_context() -> Literal[True]
Source code
198
199
200
201
202
203
204
205
def assert_in_context(self) -> Literal[True]:
    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
195
196
def to_str(self, **kwargs: Any) -> str:
    return str(self)