Skip to content

File: DepthFlow/Animation.py

DepthFlow.Animation

ClassEnum

Source code in Projects/DepthFlow/DepthFlow/Animation.py
36
37
38
39
40
41
42
43
44
45
class ClassEnum:

    @classmethod
    def members(cls) -> Iterable[type]:
        for name in dir(cls):
            if name.startswith("_"):
                continue
            if (name == "members"):
                continue
            yield getattr(cls, name)

members

members() -> Iterable[type]
Source code in Projects/DepthFlow/DepthFlow/Animation.py
38
39
40
41
42
43
44
45
@classmethod
def members(cls) -> Iterable[type]:
    for name in dir(cls):
        if name.startswith("_"):
            continue
        if (name == "members"):
            continue
        yield getattr(cls, name)

Target

Bases: MultiEnum

Source code in Projects/DepthFlow/DepthFlow/Animation.py
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
class Target(MultiEnum):
    Nothing           = "nothing"
    Height            = "height"
    Steady            = "steady"
    Focus             = "focus"
    Zoom              = "zoom"
    Isometric         = "isometric"
    Dolly             = "dolly"
    Invert            = "invert"
    Mirror            = "mirror"
    CenterX           = "center-x"
    CenterY           = "center-y"
    OriginX           = "origin-x"
    OriginY           = "origin-y"
    OffsetX           = "offset-x"
    OffsetY           = "offset-y"
    VignetteEnable    = "vignette.enable"
    VignetteIntensity = "vignette.intensity"
    VignetteDecay     = "vignette.decay"
    LensEnable        = "lens.enable"
    LensIntensity     = "lens.intensity"
    LensDecay         = "lens.decay"
    LensQuality       = "lens.quality"
    BlurEnable        = "blur.enable"
    BlurStart         = "blur.start"
    BlurEnd           = "blur.end"
    BlurExponent      = "blur.exponent"
    BlurIntensity     = "blur.intensity"
    BlurQuality       = "blur.quality"
    BlurDirections    = "blur.directions"
    InpaintEnable     = "inpaint.enable"
    InpaintBlack      = "inpaint.black"
    InpaintLimit      = "inpaint.limit"
    ColorEnable       = "colors.enable"
    ColorSaturation   = "colors.saturation"
    ColorContrast     = "colors.contrast"
    ColorBrightness   = "colors.brightness"
    ColorGamma        = "colors.gamma"
    ColorGrayscale    = "colors.grayscale"
    ColorSepia        = "colors.sepia"

Nothing

Nothing = 'nothing'

Height

Height = 'height'

Steady

Steady = 'steady'

Focus

Focus = 'focus'

Zoom

Zoom = 'zoom'

Isometric

Isometric = 'isometric'

Dolly

Dolly = 'dolly'

Invert

Invert = 'invert'

Mirror

Mirror = 'mirror'

CenterX

CenterX = 'center-x'

CenterY

CenterY = 'center-y'

OriginX

OriginX = 'origin-x'

OriginY

OriginY = 'origin-y'

OffsetX

OffsetX = 'offset-x'

OffsetY

OffsetY = 'offset-y'

VignetteEnable

VignetteEnable = 'vignette.enable'

VignetteIntensity

VignetteIntensity = 'vignette.intensity'

VignetteDecay

VignetteDecay = 'vignette.decay'

LensEnable

LensEnable = 'lens.enable'

LensIntensity

LensIntensity = 'lens.intensity'

LensDecay

LensDecay = 'lens.decay'

LensQuality

LensQuality = 'lens.quality'

BlurEnable

BlurEnable = 'blur.enable'

BlurStart

BlurStart = 'blur.start'

BlurEnd

BlurEnd = 'blur.end'

BlurExponent

BlurExponent = 'blur.exponent'

BlurIntensity

BlurIntensity = 'blur.intensity'

BlurQuality

BlurQuality = 'blur.quality'

BlurDirections

BlurDirections = 'blur.directions'

InpaintEnable

InpaintEnable = 'inpaint.enable'

InpaintBlack

InpaintBlack = 'inpaint.black'

InpaintLimit

InpaintLimit = 'inpaint.limit'

ColorEnable

ColorEnable = 'colors.enable'

ColorSaturation

ColorSaturation = 'colors.saturation'

ColorContrast

ColorContrast = 'colors.contrast'

ColorBrightness

ColorBrightness = 'colors.brightness'

ColorGamma

ColorGamma = 'colors.gamma'

ColorGrayscale

ColorGrayscale = 'colors.grayscale'

ColorSepia

ColorSepia = 'colors.sepia'

hint

hint: str = '[bold blue](🔵 Option)[/]'

TargetType

TargetType: TypeAlias = Annotated[
    Target,
    Option(
        "--target",
        "-t",
        help=f"{hint} Target animation state variable to modulate",
    ),
]

IntensityType

IntensityType: TypeAlias = Annotated[
    float,
    Option(
        "--intensity",
        "-i",
        min=0,
        max=4,
        help=f"{hint} Global intensity of the animation (scales all amplitudes)",
    ),
]

ReverseType

ReverseType: TypeAlias = Annotated[bool, Option('--reverse', '-r', ' /--forward', ' /-fw', help=f'{hint} Time 'direction' to play the animation, makes the end the start')]

SmoothType

SmoothType: TypeAlias = Annotated[
    bool,
    Option(
        "--smooth",
        "-s",
        " /--linear",
        " /-ns",
        help=f"{hint} Use the smooth variant of the animation (often a Sine wave)",
    ),
]

LoopType

LoopType: TypeAlias = Annotated[
    bool,
    Option(
        "--loop",
        "-l",
        " /--no-loop",
        " /-nl",
        help=f"{hint} Loop the animation indefinitely (often 4x apparent frequency)",
    ),
]

SteadyType

SteadyType: TypeAlias = Annotated[
    float,
    Option(
        "--steady",
        "-S",
        min=-1,
        max=2,
        help=f"{hint} Depth value of no displacements on camera movements",
    ),
]

IsometricType

IsometricType: TypeAlias = Annotated[float, Option('--isometric', '-I', min=0, max=1, help=f'{hint} The 'flatness' of the projection, 0 is perspective, 1 is isometric')]

PhaseType

PhaseType: TypeAlias = Annotated[float, Option('--phase', '-p', min=0, max=1, help=f'{hint} Phase shift of the main animation's wave')]

PhaseXYZType

PhaseXYZType: TypeAlias = Annotated[
    tuple[float, float, float],
    Option(
        "--phase",
        "-p",
        min=0,
        max=1,
        help=f"{hint} Phase shift of the horizontal, vertical and depth waves",
    ),
]

AmplitudeXYZType

AmplitudeXYZType: TypeAlias = Annotated[
    tuple[float, float, float],
    Option(
        "--amplitude",
        "-a",
        min=-2,
        max=2,
        help=f"{hint} Amplitude of the horizontal, vertical and depth waves",
    ),
]

DepthType

DepthType = Annotated[
    float,
    Option(
        "--depth",
        "-d",
        min=-1,
        max=2,
        help=f"{hint} Focal depth of this animation (orbit point, dolly zoom, etc.)",
    ),
]

CumulativeType

CumulativeType = Annotated[bool, Option('--cumulative', '-c', ' /--force', ' /-f', help=f'{hint} Cumulative animation, adds to the previous frame's target value')]

AnimationBase

Bases: BaseModel, ABC

The simplest animation meta-type, applies anything to the scene

Source code in Projects/DepthFlow/DepthFlow/Animation.py
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
class AnimationBase(BaseModel, ABC):
    """The simplest animation meta-type, applies anything to the scene"""

    def get_time(self, scene: DepthScene) -> tuple[float, float]:
        (tau, cycle) = (scene.tau, scene.cycle)

        # Fixme: Is setting phase and reversing non intuitive?
        if getattr(self, "reverse", False):
            cycle = (2*math.pi - cycle)
            tau = (1 - tau)

        return (tau, cycle)

    @abstractmethod
    def apply(self, scene: DepthScene) -> None:
        ...

get_time

get_time(scene: DepthScene) -> tuple[float, float]
Source code in Projects/DepthFlow/DepthFlow/Animation.py
135
136
137
138
139
140
141
142
143
def get_time(self, scene: DepthScene) -> tuple[float, float]:
    (tau, cycle) = (scene.tau, scene.cycle)

    # Fixme: Is setting phase and reversing non intuitive?
    if getattr(self, "reverse", False):
        cycle = (2*math.pi - cycle)
        tau = (1 - tau)

    return (tau, cycle)

apply

apply(scene: DepthScene) -> None
Source code in Projects/DepthFlow/DepthFlow/Animation.py
145
146
147
@abstractmethod
def apply(self, scene: DepthScene) -> None:
    ...

ComponentBase

Bases: AnimationBase

An animation type that targets a specific state variable

Source code in Projects/DepthFlow/DepthFlow/Animation.py
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
class ComponentBase(AnimationBase):
    """An animation type that targets a specific state variable"""
    target:     TargetType     = Field(Target.Nothing)
    cumulative: CumulativeType = Field(False)

    def current(self, scene: DepthScene) -> Optional[Any]:
        return BrokenAttribute.get(
            root=scene.state,
            key=self.target.value
        )

    def apply(self, scene: DepthScene) -> None:
        if (self.target != Target.Nothing):
            BrokenAttribute.set(scene.state, self.target.value, sum((
                (self.compute(scene, *self.get_time(scene))),
                (self.cumulative * (self.current(scene) or 0)),
            )))

    @abstractmethod
    def compute(self, scene: DepthScene, tau: float, cycle: float) -> float:
        ...

target

target: TargetType = Field(Target.Nothing)

cumulative

cumulative: CumulativeType = Field(False)

current

current(scene: DepthScene) -> Optional[Any]
Source code in Projects/DepthFlow/DepthFlow/Animation.py
154
155
156
157
158
def current(self, scene: DepthScene) -> Optional[Any]:
    return BrokenAttribute.get(
        root=scene.state,
        key=self.target.value
    )

apply

apply(scene: DepthScene) -> None
Source code in Projects/DepthFlow/DepthFlow/Animation.py
160
161
162
163
164
165
def apply(self, scene: DepthScene) -> None:
    if (self.target != Target.Nothing):
        BrokenAttribute.set(scene.state, self.target.value, sum((
            (self.compute(scene, *self.get_time(scene))),
            (self.cumulative * (self.current(scene) or 0)),
        )))

compute

compute(
    scene: DepthScene, tau: float, cycle: float
) -> float
Source code in Projects/DepthFlow/DepthFlow/Animation.py
167
168
169
@abstractmethod
def compute(self, scene: DepthScene, tau: float, cycle: float) -> float:
    ...

ReversibleComponentBase

Bases: ComponentBase

Source code in Projects/DepthFlow/DepthFlow/Animation.py
171
172
class ReversibleComponentBase(ComponentBase):
    reverse: ReverseType = Field(False)

reverse

reverse: ReverseType = Field(False)

PresetBase

Bases: AnimationBase

Source code in Projects/DepthFlow/DepthFlow/Animation.py
174
175
176
class PresetBase(AnimationBase):
    intensity: IntensityType = Field(1.0)
    reverse:   ReverseType   = Field(False)

intensity

intensity: IntensityType = Field(1.0)

reverse

reverse: ReverseType = Field(False)

FilterBase

Bases: AnimationBase

Meta-class for post processing effects

Source code in Projects/DepthFlow/DepthFlow/Animation.py
178
179
180
class FilterBase(AnimationBase):
    """Meta-class for post processing effects"""
    ...

Actions

Bases: ClassEnum

Source code in Projects/DepthFlow/DepthFlow/Animation.py
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
class Actions(ClassEnum):

    # ----------------------------------------------|
    # Special components

    class State(PresetBase, DepthState):
        def apply(self, scene: DepthScene) -> None:
            scene.state = self

    class Nothing(AnimationBase):
        type: Annotated[Literal["nothing"], BrokenTyper.exclude()] = "nothing"

        def apply(self, scene: DepthScene) -> None:
            pass

    class Custom(AnimationBase):
        type: Annotated[Literal["custom"], BrokenTyper.exclude()] = "custom"

        code: Annotated[str, Option("--code", "-c")] = Field("")
        """Custom code to run for the animation [yellow](be sure to trust it)[/]"""

        def apply(self, scene: DepthScene, tau: float, cycle: float) -> float:
            if Environment.flag("CUSTOM_CODE", 0):
                return exec(LoadString(self.code))
            raise RuntimeError("Custom code execution is disabled")

    class Reset(AnimationBase):
        type: Annotated[Literal["reset"], BrokenTyper.exclude()] = "reset"

        def apply(self, scene: DepthScene) -> None:
            scene.state = DepthState()

    # ----------------------------------------------|
    # Constant components

    class _ConstantBase(ComponentBase):
        value: Annotated[float, Option("--value", "-v")] = Field(0.0)

    class Set(_ConstantBase):
        """Set a constant value to some component's animation"""
        type: Annotated[Literal["set"], BrokenTyper.exclude()] = "set"

        def compute(self, scene: DepthScene, tau: float, cycle: float) -> float:
            self.cumulative = False
            return self.value

    class Add(_ConstantBase):
        """Add a constant value to some component's animation"""
        type: Annotated[Literal["add"], BrokenTyper.exclude()] = "add"

        def compute(self, scene: DepthScene, tau: float, cycle: float) -> float:
            self.cumulative = True
            return self.value

    # ----------------------------------------------|
    # Basic components

    class Linear(ReversibleComponentBase):
        """Add a Linear interpolation to some component's animation"""
        type: Annotated[Literal["linear"], BrokenTyper.exclude()] = "linear"

        start: Annotated[float, Option("--start", "-t0")] = Field(0.0)
        """Normalized start time"""

        end: Annotated[float, Option("--end", "-t1")] = Field(1.0)
        """Normalized end time"""

        low: Annotated[float, Option("--low", "-v0")] = Field(0.0)
        """Start value"""

        hight: Annotated[float, Option("--high", "-v1")] = Field(1.0)
        """End value"""

        exponent: Annotated[float, Option("-e", "--exponent")] = Field(1.0)
        """Exponent for shaping the interpolation"""

        def compute(self, scene: DepthScene, tau: float, cycle: float) -> float:
            normal = (tau - self.start) / (self.end - self.start)
            shaped = math.pow(max(0, min(1, normal)), self.exponent)
            return self.low + (self.hight - self.low) * shaped

    # ----------------------------------------------|
    # Wave functions

    class _WaveBase(ReversibleComponentBase):
        amplitude: Annotated[float, Option("--amplitude", "-a")] = Field(1.0)
        """Amplitude of the wave"""

        bias: Annotated[float, Option("--bias", "-b")] = Field(0.0)
        """Bias of the wave"""

        cycles: Annotated[float, Option("--cycles", "-c")] = Field(1.0)
        """Number of cycles of the wave"""

        phase: Annotated[float, Option("--phase", "-p")] = Field(0.0)
        """Phase shift of the wave"""

    class Sine(_WaveBase):
        """Add a Sine wave to some component's animation [green](See 'sine --help' for options)[/]"""
        type: Annotated[Literal["sine"], BrokenTyper.exclude()] = "sine"

        def compute(self, scene: DepthScene, tau: float, cycle: float) -> float:
            return self.amplitude * math.sin((cycle * self.cycles) + (self.phase * math.tau)) + self.bias

    class Cosine(_WaveBase):
        """Add a Cosine wave to some component's animation [green](See 'cosine --help' for options)[/]"""
        type: Annotated[Literal["cosine"], BrokenTyper.exclude()] = "cosine"

        def compute(self, scene: DepthScene, tau: float, cycle: float) -> float:
            return self.amplitude * math.cos((cycle * self.cycles) + (self.phase * math.tau)) + self.bias

    class Triangle(_WaveBase):
        """Add a Triangle wave to some component's animation [green](See 'triangle --help' for options)[/]"""
        type: Annotated[Literal["triangle"], BrokenTyper.exclude()] = "triangle"

        def compute(self, scene: DepthScene, tau: float, cycle: float) -> float:
            tau = (tau * self.cycles + self.phase + 0.25) % 1
            return self.amplitude * (1 - 4 * abs(tau - 0.5)) + self.bias

    # ----------------------------------------------|
    # Post processing

    class Vignette(FilterBase, VignetteState):
        """Add a Vignette effect to the video"""
        type: Annotated[Literal["vignette"], BrokenTyper.exclude()] = "vignette"

        def apply(self, scene: DepthScene) -> None:
            scene.state.vignette = self.update(enable=True)

    class Lens(FilterBase, LensState):
        """Add a Lens distortion effect to the video"""
        type: Annotated[Literal["lens"], BrokenTyper.exclude()] = "lens"

        def apply(self, scene: DepthScene) -> None:
            scene.state.lens = self.update(enable=True)

    class Blur(FilterBase, BlurState):
        """Add a Blur effect (depth of field) to the video"""
        type: Annotated[Literal["blur"], BrokenTyper.exclude()] = "blur"

        def apply(self, scene: DepthScene) -> None:
            scene.state.blur = self.update(enable=True)

    class Inpaint(FilterBase, InpaintState):
        """Replace steep regions with green color"""
        type: Annotated[Literal["inpaint"], BrokenTyper.exclude()] = "inpaint"

        def apply(self, scene: DepthScene) -> None:
            scene.state.inpaint = self.update(enable=True)

    class Colors(FilterBase, ColorState):
        """Add coloring effects to the video"""
        type: Annotated[Literal["colors"], BrokenTyper.exclude()] = "colors"

        def apply(self, scene: DepthScene) -> None:
            scene.state.colors = self.update(enable=True)

    # ----------------------------------------------|
    # Presets

    class Vertical(PresetBase):
        """Add a Vertical motion to the camera"""
        type:      Annotated[Literal["vertical"], BrokenTyper.exclude()] = "vertical"
        smooth:    SmoothType    = Field(True)
        loop:      LoopType      = Field(True)
        phase:     PhaseType     = Field(0.0)
        steady:    SteadyType    = Field(0.3)
        isometric: IsometricType = Field(0.6)

        def apply(self, scene: DepthScene) -> None:
            scene.state.isometric = self.isometric
            scene.state.steady    = self.steady

            if self.loop:
                (Actions.Sine if self.smooth else Actions.Triangle)(
                    target    = Target.OffsetY,
                    amplitude = 0.5*self.intensity,
                    phase     = self.phase,
                    cycles    = 1.00,
                ).apply(scene)
            else:
                (Actions.Sine if self.smooth else Actions.Triangle)(
                    target    = Target.OffsetY,
                    amplitude = self.intensity,
                    phase     = -0.25,
                    cycles    = 0.50,
                ).apply(scene)

    class Horizontal(PresetBase):
        """Add a Horizontal motion to the camera"""
        type:      Annotated[Literal["horizontal"], BrokenTyper.exclude()] = "horizontal"
        smooth:    SmoothType    = Field(True)
        loop:      LoopType      = Field(True)
        phase:     PhaseType     = Field(0.0)
        steady:    SteadyType    = Field(0.3)
        isometric: IsometricType = Field(0.6)

        def apply(self, scene: DepthScene) -> None:
            scene.state.isometric = self.isometric
            scene.state.steady    = self.steady

            if self.loop:
                (Actions.Sine if self.smooth else Actions.Triangle)(
                    target    = Target.OffsetX,
                    amplitude = 0.5*self.intensity,
                    phase     = self.phase,
                    cycles    = 1.00,
                ).apply(scene)
            else:
                (Actions.Sine if self.smooth else Actions.Triangle)(
                    target    = Target.OffsetX,
                    amplitude = self.intensity,
                    phase     = -0.25,
                    cycles    = 0.50,
                ).apply(scene)

    class Zoom(PresetBase):
        """Add a Zoom motion to the camera"""
        type:   Annotated[Literal["zoom"], BrokenTyper.exclude()] = "zoom"
        smooth: SmoothType = Field(True)
        loop:   LoopType   = Field(True)
        phase:  PhaseType  = Field(0.0)

        def apply(self, scene: DepthScene) -> None:
            if self.loop:
                (Actions.Sine if self.smooth else Actions.Triangle)(
                    target    = Target.Height,
                    amplitude = 0.50 * (self.intensity/2),
                    bias      = 0.50 * (self.intensity/2),
                    phase     = self.phase,
                    cycles    = 1.00,
                    reverse   = self.reverse,
                ).apply(scene)
            else:
                (Actions.Sine if self.smooth else Actions.Triangle)(
                    target    = Target.Height,
                    amplitude = 0.75 * self.intensity,
                    phase     = 0.00,
                    cycles    = 0.25,
                    reverse   = self.reverse,
                ).apply(scene)

    class Circle(PresetBase):
        """Add a Circular motion to the camera"""
        type:      Annotated[Literal["circle"], BrokenTyper.exclude()] = "circle"
        smooth:    SmoothType       = Field(True)
        phase:     PhaseXYZType     = Field((0.0, 0.0, 0.0))
        amplitude: AmplitudeXYZType = Field((1.0, 1.0, 0.0))
        steady:    SteadyType       = Field(0.3)
        isometric: IsometricType    = Field(0.6)

        def apply(self, scene: DepthScene) -> None:
            scene.state.isometric = self.isometric
            scene.state.steady    = self.steady

            (Actions.Sine if self.smooth else Actions.Triangle)(
                target    = Target.OffsetX,
                amplitude = (0.5*self.intensity*self.amplitude[0]),
                phase     = self.phase[0] + 0.25,
                reverse   = self.reverse,
            ).apply(scene)

            (Actions.Sine if self.smooth else Actions.Triangle)(
                target    = Target.OffsetY,
                amplitude = (0.5*self.intensity*self.amplitude[1]),
                phase     = self.phase[1],
                reverse   = self.reverse,
            ).apply(scene)

    class Dolly(PresetBase):
        """Add a Dolly zoom to the camera"""
        type:   Annotated[Literal["dolly"], BrokenTyper.exclude()] = "dolly"
        smooth: SmoothType  = Field(True)
        loop:   LoopType    = Field(True)
        depth:  DepthType   = Field(0.5)
        phase:  PhaseType   = Field(0.0)

        def apply(self, scene: DepthScene) -> None:
            scene.state.steady = self.depth
            scene.state.focus  = self.depth

            if self.loop:
                phase, cycles = ( 0.75 if self.reverse else 0.25), 1.0
            else:
                phase, cycles = (-0.75 if self.reverse else 0.25), 0.5

            (Actions.Sine if self.smooth else Actions.Triangle)(
                target    = Target.Isometric,
                amplitude = 2*self.intensity,
                phase     = self.phase + phase,
                cycles    = cycles,
                reverse   = self.reverse,
                bias      = 1,
            ).apply(scene)

    class Orbital(PresetBase):
        """Orbit the camera around a fixed point"""
        type:  Annotated[Literal["orbital"], BrokenTyper.exclude()] = "orbital"
        depth: DepthType = Field(0.0)

        def apply(self, scene: DepthScene) -> None:
            scene.state.steady = self.depth
            scene.state.focus  = self.depth

            Actions.Cosine(
                target    = Target.Isometric,
                amplitude = self.intensity,
                bias      = self.intensity,
                reverse   = self.reverse,
            ).apply(scene)

            Actions.Sine(
                target    = Target.OffsetX,
                amplitude = self.intensity,
                reverse   = self.reverse,
            ).apply(scene)

State

Bases: PresetBase, DepthState

Source code in Projects/DepthFlow/DepthFlow/Animation.py
189
190
191
class State(PresetBase, DepthState):
    def apply(self, scene: DepthScene) -> None:
        scene.state = self
apply
apply(scene: DepthScene) -> None
Source code in Projects/DepthFlow/DepthFlow/Animation.py
190
191
def apply(self, scene: DepthScene) -> None:
    scene.state = self

Nothing

Bases: AnimationBase

Source code in Projects/DepthFlow/DepthFlow/Animation.py
193
194
195
196
197
class Nothing(AnimationBase):
    type: Annotated[Literal["nothing"], BrokenTyper.exclude()] = "nothing"

    def apply(self, scene: DepthScene) -> None:
        pass
type
type: Annotated[
    Literal["nothing"], BrokenTyper.exclude()
] = "nothing"
apply
apply(scene: DepthScene) -> None
Source code in Projects/DepthFlow/DepthFlow/Animation.py
196
197
def apply(self, scene: DepthScene) -> None:
    pass

Custom

Bases: AnimationBase

Source code in Projects/DepthFlow/DepthFlow/Animation.py
199
200
201
202
203
204
205
206
207
208
class Custom(AnimationBase):
    type: Annotated[Literal["custom"], BrokenTyper.exclude()] = "custom"

    code: Annotated[str, Option("--code", "-c")] = Field("")
    """Custom code to run for the animation [yellow](be sure to trust it)[/]"""

    def apply(self, scene: DepthScene, tau: float, cycle: float) -> float:
        if Environment.flag("CUSTOM_CODE", 0):
            return exec(LoadString(self.code))
        raise RuntimeError("Custom code execution is disabled")
type
type: Annotated[
    Literal["custom"], BrokenTyper.exclude()
] = "custom"
code
code: Annotated[str, Option('--code', '-c')] = Field('')

Custom code to run for the animation yellow[/]

apply
apply(scene: DepthScene, tau: float, cycle: float) -> float
Source code in Projects/DepthFlow/DepthFlow/Animation.py
205
206
207
208
def apply(self, scene: DepthScene, tau: float, cycle: float) -> float:
    if Environment.flag("CUSTOM_CODE", 0):
        return exec(LoadString(self.code))
    raise RuntimeError("Custom code execution is disabled")

Reset

Bases: AnimationBase

Source code in Projects/DepthFlow/DepthFlow/Animation.py
210
211
212
213
214
class Reset(AnimationBase):
    type: Annotated[Literal["reset"], BrokenTyper.exclude()] = "reset"

    def apply(self, scene: DepthScene) -> None:
        scene.state = DepthState()
type
type: Annotated[Literal["reset"], BrokenTyper.exclude()] = (
    "reset"
)
apply
apply(scene: DepthScene) -> None
Source code in Projects/DepthFlow/DepthFlow/Animation.py
213
214
def apply(self, scene: DepthScene) -> None:
    scene.state = DepthState()

Set

Bases: _ConstantBase

Set a constant value to some component's animation

Source code in Projects/DepthFlow/DepthFlow/Animation.py
222
223
224
225
226
227
228
class Set(_ConstantBase):
    """Set a constant value to some component's animation"""
    type: Annotated[Literal["set"], BrokenTyper.exclude()] = "set"

    def compute(self, scene: DepthScene, tau: float, cycle: float) -> float:
        self.cumulative = False
        return self.value
type
type: Annotated[Literal["set"], BrokenTyper.exclude()] = (
    "set"
)
compute
compute(
    scene: DepthScene, tau: float, cycle: float
) -> float
Source code in Projects/DepthFlow/DepthFlow/Animation.py
226
227
228
def compute(self, scene: DepthScene, tau: float, cycle: float) -> float:
    self.cumulative = False
    return self.value

Add

Bases: _ConstantBase

Add a constant value to some component's animation

Source code in Projects/DepthFlow/DepthFlow/Animation.py
230
231
232
233
234
235
236
class Add(_ConstantBase):
    """Add a constant value to some component's animation"""
    type: Annotated[Literal["add"], BrokenTyper.exclude()] = "add"

    def compute(self, scene: DepthScene, tau: float, cycle: float) -> float:
        self.cumulative = True
        return self.value
type
type: Annotated[Literal["add"], BrokenTyper.exclude()] = (
    "add"
)
compute
compute(
    scene: DepthScene, tau: float, cycle: float
) -> float
Source code in Projects/DepthFlow/DepthFlow/Animation.py
234
235
236
def compute(self, scene: DepthScene, tau: float, cycle: float) -> float:
    self.cumulative = True
    return self.value

Linear

Bases: ReversibleComponentBase

Add a Linear interpolation to some component's animation

Source code in Projects/DepthFlow/DepthFlow/Animation.py
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
class Linear(ReversibleComponentBase):
    """Add a Linear interpolation to some component's animation"""
    type: Annotated[Literal["linear"], BrokenTyper.exclude()] = "linear"

    start: Annotated[float, Option("--start", "-t0")] = Field(0.0)
    """Normalized start time"""

    end: Annotated[float, Option("--end", "-t1")] = Field(1.0)
    """Normalized end time"""

    low: Annotated[float, Option("--low", "-v0")] = Field(0.0)
    """Start value"""

    hight: Annotated[float, Option("--high", "-v1")] = Field(1.0)
    """End value"""

    exponent: Annotated[float, Option("-e", "--exponent")] = Field(1.0)
    """Exponent for shaping the interpolation"""

    def compute(self, scene: DepthScene, tau: float, cycle: float) -> float:
        normal = (tau - self.start) / (self.end - self.start)
        shaped = math.pow(max(0, min(1, normal)), self.exponent)
        return self.low + (self.hight - self.low) * shaped
type
type: Annotated[
    Literal["linear"], BrokenTyper.exclude()
] = "linear"
start
start: Annotated[float, Option("--start", "-t0")] = Field(
    0.0
)

Normalized start time

end
end: Annotated[float, Option('--end', '-t1')] = Field(1.0)

Normalized end time

low
low: Annotated[float, Option('--low', '-v0')] = Field(0.0)

Start value

hight
hight: Annotated[float, Option("--high", "-v1")] = Field(
    1.0
)

End value

exponent
exponent: Annotated[float, Option("-e", "--exponent")] = (
    Field(1.0)
)

Exponent for shaping the interpolation

compute
compute(
    scene: DepthScene, tau: float, cycle: float
) -> float
Source code in Projects/DepthFlow/DepthFlow/Animation.py
260
261
262
263
def compute(self, scene: DepthScene, tau: float, cycle: float) -> float:
    normal = (tau - self.start) / (self.end - self.start)
    shaped = math.pow(max(0, min(1, normal)), self.exponent)
    return self.low + (self.hight - self.low) * shaped

Sine

Bases: _WaveBase

Add a Sine wave to some component's animation green[/]

Source code in Projects/DepthFlow/DepthFlow/Animation.py
281
282
283
284
285
286
class Sine(_WaveBase):
    """Add a Sine wave to some component's animation [green](See 'sine --help' for options)[/]"""
    type: Annotated[Literal["sine"], BrokenTyper.exclude()] = "sine"

    def compute(self, scene: DepthScene, tau: float, cycle: float) -> float:
        return self.amplitude * math.sin((cycle * self.cycles) + (self.phase * math.tau)) + self.bias
type
type: Annotated[Literal["sine"], BrokenTyper.exclude()] = (
    "sine"
)
compute
compute(
    scene: DepthScene, tau: float, cycle: float
) -> float
Source code in Projects/DepthFlow/DepthFlow/Animation.py
285
286
def compute(self, scene: DepthScene, tau: float, cycle: float) -> float:
    return self.amplitude * math.sin((cycle * self.cycles) + (self.phase * math.tau)) + self.bias

Cosine

Bases: _WaveBase

Add a Cosine wave to some component's animation green[/]

Source code in Projects/DepthFlow/DepthFlow/Animation.py
288
289
290
291
292
293
class Cosine(_WaveBase):
    """Add a Cosine wave to some component's animation [green](See 'cosine --help' for options)[/]"""
    type: Annotated[Literal["cosine"], BrokenTyper.exclude()] = "cosine"

    def compute(self, scene: DepthScene, tau: float, cycle: float) -> float:
        return self.amplitude * math.cos((cycle * self.cycles) + (self.phase * math.tau)) + self.bias
type
type: Annotated[
    Literal["cosine"], BrokenTyper.exclude()
] = "cosine"
compute
compute(
    scene: DepthScene, tau: float, cycle: float
) -> float
Source code in Projects/DepthFlow/DepthFlow/Animation.py
292
293
def compute(self, scene: DepthScene, tau: float, cycle: float) -> float:
    return self.amplitude * math.cos((cycle * self.cycles) + (self.phase * math.tau)) + self.bias

Triangle

Bases: _WaveBase

Add a Triangle wave to some component's animation green[/]

Source code in Projects/DepthFlow/DepthFlow/Animation.py
295
296
297
298
299
300
301
class Triangle(_WaveBase):
    """Add a Triangle wave to some component's animation [green](See 'triangle --help' for options)[/]"""
    type: Annotated[Literal["triangle"], BrokenTyper.exclude()] = "triangle"

    def compute(self, scene: DepthScene, tau: float, cycle: float) -> float:
        tau = (tau * self.cycles + self.phase + 0.25) % 1
        return self.amplitude * (1 - 4 * abs(tau - 0.5)) + self.bias
type
type: Annotated[
    Literal["triangle"], BrokenTyper.exclude()
] = "triangle"
compute
compute(
    scene: DepthScene, tau: float, cycle: float
) -> float
Source code in Projects/DepthFlow/DepthFlow/Animation.py
299
300
301
def compute(self, scene: DepthScene, tau: float, cycle: float) -> float:
    tau = (tau * self.cycles + self.phase + 0.25) % 1
    return self.amplitude * (1 - 4 * abs(tau - 0.5)) + self.bias

Vignette

Bases: FilterBase, VignetteState

Add a Vignette effect to the video

Source code in Projects/DepthFlow/DepthFlow/Animation.py
306
307
308
309
310
311
class Vignette(FilterBase, VignetteState):
    """Add a Vignette effect to the video"""
    type: Annotated[Literal["vignette"], BrokenTyper.exclude()] = "vignette"

    def apply(self, scene: DepthScene) -> None:
        scene.state.vignette = self.update(enable=True)
type
type: Annotated[
    Literal["vignette"], BrokenTyper.exclude()
] = "vignette"
apply
apply(scene: DepthScene) -> None
Source code in Projects/DepthFlow/DepthFlow/Animation.py
310
311
def apply(self, scene: DepthScene) -> None:
    scene.state.vignette = self.update(enable=True)

Lens

Bases: FilterBase, LensState

Add a Lens distortion effect to the video

Source code in Projects/DepthFlow/DepthFlow/Animation.py
313
314
315
316
317
318
class Lens(FilterBase, LensState):
    """Add a Lens distortion effect to the video"""
    type: Annotated[Literal["lens"], BrokenTyper.exclude()] = "lens"

    def apply(self, scene: DepthScene) -> None:
        scene.state.lens = self.update(enable=True)
type
type: Annotated[Literal["lens"], BrokenTyper.exclude()] = (
    "lens"
)
apply
apply(scene: DepthScene) -> None
Source code in Projects/DepthFlow/DepthFlow/Animation.py
317
318
def apply(self, scene: DepthScene) -> None:
    scene.state.lens = self.update(enable=True)

Blur

Bases: FilterBase, BlurState

Add a Blur effect (depth of field) to the video

Source code in Projects/DepthFlow/DepthFlow/Animation.py
320
321
322
323
324
325
class Blur(FilterBase, BlurState):
    """Add a Blur effect (depth of field) to the video"""
    type: Annotated[Literal["blur"], BrokenTyper.exclude()] = "blur"

    def apply(self, scene: DepthScene) -> None:
        scene.state.blur = self.update(enable=True)
type
type: Annotated[Literal["blur"], BrokenTyper.exclude()] = (
    "blur"
)
apply
apply(scene: DepthScene) -> None
Source code in Projects/DepthFlow/DepthFlow/Animation.py
324
325
def apply(self, scene: DepthScene) -> None:
    scene.state.blur = self.update(enable=True)

Inpaint

Bases: FilterBase, InpaintState

Replace steep regions with green color

Source code in Projects/DepthFlow/DepthFlow/Animation.py
327
328
329
330
331
332
class Inpaint(FilterBase, InpaintState):
    """Replace steep regions with green color"""
    type: Annotated[Literal["inpaint"], BrokenTyper.exclude()] = "inpaint"

    def apply(self, scene: DepthScene) -> None:
        scene.state.inpaint = self.update(enable=True)
type
type: Annotated[
    Literal["inpaint"], BrokenTyper.exclude()
] = "inpaint"
apply
apply(scene: DepthScene) -> None
Source code in Projects/DepthFlow/DepthFlow/Animation.py
331
332
def apply(self, scene: DepthScene) -> None:
    scene.state.inpaint = self.update(enable=True)

Colors

Bases: FilterBase, ColorState

Add coloring effects to the video

Source code in Projects/DepthFlow/DepthFlow/Animation.py
334
335
336
337
338
339
class Colors(FilterBase, ColorState):
    """Add coloring effects to the video"""
    type: Annotated[Literal["colors"], BrokenTyper.exclude()] = "colors"

    def apply(self, scene: DepthScene) -> None:
        scene.state.colors = self.update(enable=True)
type
type: Annotated[
    Literal["colors"], BrokenTyper.exclude()
] = "colors"
apply
apply(scene: DepthScene) -> None
Source code in Projects/DepthFlow/DepthFlow/Animation.py
338
339
def apply(self, scene: DepthScene) -> None:
    scene.state.colors = self.update(enable=True)

Vertical

Bases: PresetBase

Add a Vertical motion to the camera

Source code in Projects/DepthFlow/DepthFlow/Animation.py
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
class Vertical(PresetBase):
    """Add a Vertical motion to the camera"""
    type:      Annotated[Literal["vertical"], BrokenTyper.exclude()] = "vertical"
    smooth:    SmoothType    = Field(True)
    loop:      LoopType      = Field(True)
    phase:     PhaseType     = Field(0.0)
    steady:    SteadyType    = Field(0.3)
    isometric: IsometricType = Field(0.6)

    def apply(self, scene: DepthScene) -> None:
        scene.state.isometric = self.isometric
        scene.state.steady    = self.steady

        if self.loop:
            (Actions.Sine if self.smooth else Actions.Triangle)(
                target    = Target.OffsetY,
                amplitude = 0.5*self.intensity,
                phase     = self.phase,
                cycles    = 1.00,
            ).apply(scene)
        else:
            (Actions.Sine if self.smooth else Actions.Triangle)(
                target    = Target.OffsetY,
                amplitude = self.intensity,
                phase     = -0.25,
                cycles    = 0.50,
            ).apply(scene)
type
type: Annotated[
    Literal["vertical"], BrokenTyper.exclude()
] = "vertical"
smooth
smooth: SmoothType = Field(True)
loop
loop: LoopType = Field(True)
phase
phase: PhaseType = Field(0.0)
steady
steady: SteadyType = Field(0.3)
isometric
isometric: IsometricType = Field(0.6)
apply
apply(scene: DepthScene) -> None
Source code in Projects/DepthFlow/DepthFlow/Animation.py
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
def apply(self, scene: DepthScene) -> None:
    scene.state.isometric = self.isometric
    scene.state.steady    = self.steady

    if self.loop:
        (Actions.Sine if self.smooth else Actions.Triangle)(
            target    = Target.OffsetY,
            amplitude = 0.5*self.intensity,
            phase     = self.phase,
            cycles    = 1.00,
        ).apply(scene)
    else:
        (Actions.Sine if self.smooth else Actions.Triangle)(
            target    = Target.OffsetY,
            amplitude = self.intensity,
            phase     = -0.25,
            cycles    = 0.50,
        ).apply(scene)

Horizontal

Bases: PresetBase

Add a Horizontal motion to the camera

Source code in Projects/DepthFlow/DepthFlow/Animation.py
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
class Horizontal(PresetBase):
    """Add a Horizontal motion to the camera"""
    type:      Annotated[Literal["horizontal"], BrokenTyper.exclude()] = "horizontal"
    smooth:    SmoothType    = Field(True)
    loop:      LoopType      = Field(True)
    phase:     PhaseType     = Field(0.0)
    steady:    SteadyType    = Field(0.3)
    isometric: IsometricType = Field(0.6)

    def apply(self, scene: DepthScene) -> None:
        scene.state.isometric = self.isometric
        scene.state.steady    = self.steady

        if self.loop:
            (Actions.Sine if self.smooth else Actions.Triangle)(
                target    = Target.OffsetX,
                amplitude = 0.5*self.intensity,
                phase     = self.phase,
                cycles    = 1.00,
            ).apply(scene)
        else:
            (Actions.Sine if self.smooth else Actions.Triangle)(
                target    = Target.OffsetX,
                amplitude = self.intensity,
                phase     = -0.25,
                cycles    = 0.50,
            ).apply(scene)
type
type: Annotated[
    Literal["horizontal"], BrokenTyper.exclude()
] = "horizontal"
smooth
smooth: SmoothType = Field(True)
loop
loop: LoopType = Field(True)
phase
phase: PhaseType = Field(0.0)
steady
steady: SteadyType = Field(0.3)
isometric
isometric: IsometricType = Field(0.6)
apply
apply(scene: DepthScene) -> None
Source code in Projects/DepthFlow/DepthFlow/Animation.py
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
def apply(self, scene: DepthScene) -> None:
    scene.state.isometric = self.isometric
    scene.state.steady    = self.steady

    if self.loop:
        (Actions.Sine if self.smooth else Actions.Triangle)(
            target    = Target.OffsetX,
            amplitude = 0.5*self.intensity,
            phase     = self.phase,
            cycles    = 1.00,
        ).apply(scene)
    else:
        (Actions.Sine if self.smooth else Actions.Triangle)(
            target    = Target.OffsetX,
            amplitude = self.intensity,
            phase     = -0.25,
            cycles    = 0.50,
        ).apply(scene)

Zoom

Bases: PresetBase

Add a Zoom motion to the camera

Source code in Projects/DepthFlow/DepthFlow/Animation.py
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
class Zoom(PresetBase):
    """Add a Zoom motion to the camera"""
    type:   Annotated[Literal["zoom"], BrokenTyper.exclude()] = "zoom"
    smooth: SmoothType = Field(True)
    loop:   LoopType   = Field(True)
    phase:  PhaseType  = Field(0.0)

    def apply(self, scene: DepthScene) -> None:
        if self.loop:
            (Actions.Sine if self.smooth else Actions.Triangle)(
                target    = Target.Height,
                amplitude = 0.50 * (self.intensity/2),
                bias      = 0.50 * (self.intensity/2),
                phase     = self.phase,
                cycles    = 1.00,
                reverse   = self.reverse,
            ).apply(scene)
        else:
            (Actions.Sine if self.smooth else Actions.Triangle)(
                target    = Target.Height,
                amplitude = 0.75 * self.intensity,
                phase     = 0.00,
                cycles    = 0.25,
                reverse   = self.reverse,
            ).apply(scene)
type
type: Annotated[Literal["zoom"], BrokenTyper.exclude()] = (
    "zoom"
)
smooth
smooth: SmoothType = Field(True)
loop
loop: LoopType = Field(True)
phase
phase: PhaseType = Field(0.0)
apply
apply(scene: DepthScene) -> None
Source code in Projects/DepthFlow/DepthFlow/Animation.py
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
def apply(self, scene: DepthScene) -> None:
    if self.loop:
        (Actions.Sine if self.smooth else Actions.Triangle)(
            target    = Target.Height,
            amplitude = 0.50 * (self.intensity/2),
            bias      = 0.50 * (self.intensity/2),
            phase     = self.phase,
            cycles    = 1.00,
            reverse   = self.reverse,
        ).apply(scene)
    else:
        (Actions.Sine if self.smooth else Actions.Triangle)(
            target    = Target.Height,
            amplitude = 0.75 * self.intensity,
            phase     = 0.00,
            cycles    = 0.25,
            reverse   = self.reverse,
        ).apply(scene)

Circle

Bases: PresetBase

Add a Circular motion to the camera

Source code in Projects/DepthFlow/DepthFlow/Animation.py
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
class Circle(PresetBase):
    """Add a Circular motion to the camera"""
    type:      Annotated[Literal["circle"], BrokenTyper.exclude()] = "circle"
    smooth:    SmoothType       = Field(True)
    phase:     PhaseXYZType     = Field((0.0, 0.0, 0.0))
    amplitude: AmplitudeXYZType = Field((1.0, 1.0, 0.0))
    steady:    SteadyType       = Field(0.3)
    isometric: IsometricType    = Field(0.6)

    def apply(self, scene: DepthScene) -> None:
        scene.state.isometric = self.isometric
        scene.state.steady    = self.steady

        (Actions.Sine if self.smooth else Actions.Triangle)(
            target    = Target.OffsetX,
            amplitude = (0.5*self.intensity*self.amplitude[0]),
            phase     = self.phase[0] + 0.25,
            reverse   = self.reverse,
        ).apply(scene)

        (Actions.Sine if self.smooth else Actions.Triangle)(
            target    = Target.OffsetY,
            amplitude = (0.5*self.intensity*self.amplitude[1]),
            phase     = self.phase[1],
            reverse   = self.reverse,
        ).apply(scene)
type
type: Annotated[
    Literal["circle"], BrokenTyper.exclude()
] = "circle"
smooth
smooth: SmoothType = Field(True)
phase
phase: PhaseXYZType = Field((0.0, 0.0, 0.0))
amplitude
amplitude: AmplitudeXYZType = Field((1.0, 1.0, 0.0))
steady
steady: SteadyType = Field(0.3)
isometric
isometric: IsometricType = Field(0.6)
apply
apply(scene: DepthScene) -> None
Source code in Projects/DepthFlow/DepthFlow/Animation.py
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
def apply(self, scene: DepthScene) -> None:
    scene.state.isometric = self.isometric
    scene.state.steady    = self.steady

    (Actions.Sine if self.smooth else Actions.Triangle)(
        target    = Target.OffsetX,
        amplitude = (0.5*self.intensity*self.amplitude[0]),
        phase     = self.phase[0] + 0.25,
        reverse   = self.reverse,
    ).apply(scene)

    (Actions.Sine if self.smooth else Actions.Triangle)(
        target    = Target.OffsetY,
        amplitude = (0.5*self.intensity*self.amplitude[1]),
        phase     = self.phase[1],
        reverse   = self.reverse,
    ).apply(scene)

Dolly

Bases: PresetBase

Add a Dolly zoom to the camera

Source code in Projects/DepthFlow/DepthFlow/Animation.py
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
class Dolly(PresetBase):
    """Add a Dolly zoom to the camera"""
    type:   Annotated[Literal["dolly"], BrokenTyper.exclude()] = "dolly"
    smooth: SmoothType  = Field(True)
    loop:   LoopType    = Field(True)
    depth:  DepthType   = Field(0.5)
    phase:  PhaseType   = Field(0.0)

    def apply(self, scene: DepthScene) -> None:
        scene.state.steady = self.depth
        scene.state.focus  = self.depth

        if self.loop:
            phase, cycles = ( 0.75 if self.reverse else 0.25), 1.0
        else:
            phase, cycles = (-0.75 if self.reverse else 0.25), 0.5

        (Actions.Sine if self.smooth else Actions.Triangle)(
            target    = Target.Isometric,
            amplitude = 2*self.intensity,
            phase     = self.phase + phase,
            cycles    = cycles,
            reverse   = self.reverse,
            bias      = 1,
        ).apply(scene)
type
type: Annotated[Literal["dolly"], BrokenTyper.exclude()] = (
    "dolly"
)
smooth
smooth: SmoothType = Field(True)
loop
loop: LoopType = Field(True)
depth
depth: DepthType = Field(0.5)
phase
phase: PhaseType = Field(0.0)
apply
apply(scene: DepthScene) -> None
Source code in Projects/DepthFlow/DepthFlow/Animation.py
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
def apply(self, scene: DepthScene) -> None:
    scene.state.steady = self.depth
    scene.state.focus  = self.depth

    if self.loop:
        phase, cycles = ( 0.75 if self.reverse else 0.25), 1.0
    else:
        phase, cycles = (-0.75 if self.reverse else 0.25), 0.5

    (Actions.Sine if self.smooth else Actions.Triangle)(
        target    = Target.Isometric,
        amplitude = 2*self.intensity,
        phase     = self.phase + phase,
        cycles    = cycles,
        reverse   = self.reverse,
        bias      = 1,
    ).apply(scene)

Orbital

Bases: PresetBase

Orbit the camera around a fixed point

Source code in Projects/DepthFlow/DepthFlow/Animation.py
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
class Orbital(PresetBase):
    """Orbit the camera around a fixed point"""
    type:  Annotated[Literal["orbital"], BrokenTyper.exclude()] = "orbital"
    depth: DepthType = Field(0.0)

    def apply(self, scene: DepthScene) -> None:
        scene.state.steady = self.depth
        scene.state.focus  = self.depth

        Actions.Cosine(
            target    = Target.Isometric,
            amplitude = self.intensity,
            bias      = self.intensity,
            reverse   = self.reverse,
        ).apply(scene)

        Actions.Sine(
            target    = Target.OffsetX,
            amplitude = self.intensity,
            reverse   = self.reverse,
        ).apply(scene)
type
type: Annotated[
    Literal["orbital"], BrokenTyper.exclude()
] = "orbital"
depth
depth: DepthType = Field(0.0)
apply
apply(scene: DepthScene) -> None
Source code in Projects/DepthFlow/DepthFlow/Animation.py
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
def apply(self, scene: DepthScene) -> None:
    scene.state.steady = self.depth
    scene.state.focus  = self.depth

    Actions.Cosine(
        target    = Target.Isometric,
        amplitude = self.intensity,
        bias      = self.intensity,
        reverse   = self.reverse,
    ).apply(scene)

    Actions.Sine(
        target    = Target.OffsetX,
        amplitude = self.intensity,
        reverse   = self.reverse,
    ).apply(scene)

DepthAnimation

Bases: BrokenModel

Source code in Projects/DepthFlow/DepthFlow/Animation.py
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
class DepthAnimation(BrokenModel):
    steps: list[AnimationType] = Field(default_factory=list)

    def add(self, animation: AnimationBase) -> AnimationBase:
        self.steps.append(animation := copy.deepcopy(animation))
        return animation

    def clear(self) -> None:
        self.steps.clear()

    def apply(self, scene: DepthScene) -> None:
        for animation in self.steps:
            animation.apply(scene)

    def __bool__(self) -> bool:
        return bool(self.steps)

steps

steps: list[AnimationType] = Field(default_factory=list)

add

add(animation: AnimationBase) -> AnimationBase
Source code in Projects/DepthFlow/DepthFlow/Animation.py
537
538
539
def add(self, animation: AnimationBase) -> AnimationBase:
    self.steps.append(animation := copy.deepcopy(animation))
    return animation

clear

clear() -> None
Source code in Projects/DepthFlow/DepthFlow/Animation.py
541
542
def clear(self) -> None:
    self.steps.clear()

apply

apply(scene: DepthScene) -> None
Source code in Projects/DepthFlow/DepthFlow/Animation.py
544
545
546
def apply(self, scene: DepthScene) -> None:
    for animation in self.steps:
        animation.apply(scene)

__bool__

__bool__() -> bool
Source code in Projects/DepthFlow/DepthFlow/Animation.py
548
549
def __bool__(self) -> bool:
    return bool(self.steps)