55import copy
66from typing import Any , Self , overload
77
8- from frontend .transformation ._Transformation import Transformation
9- from frontend .Constant import uint
8+ from frontend .transformation .Transformation import Transformation
109from frontend .Global import *
1110
1211
@@ -29,7 +28,7 @@ def shape() -> Input: ...
2928
3029 def __new__ (cls , * args , ** kwargs ) -> Self :
3130 instance = super ().__new__ (cls )
32- instance .index = len (Global .variable )
31+ instance .index = len (Global .requiredInputs )
3332 return instance
3433
3534 @abstractmethod
@@ -39,63 +38,36 @@ def add(self) -> None:
3938 """
4039 Appends the `frames` of `self` to the `timeline`.
4140 """
42- Global .stack .append (("Add" , self .index , []))
41+ Global .transformationStack .append (("Add" , self .index , []))
4342
4443 def apply (self , * ts : Transformation ) -> Input :
4544 """
4645 Applies the `Transformations` `ts` to all the `frames` of `self`.
4746 """
4847 for t in ts :
49- Global .stack .append (("Apply" , self .index , [t .__class__ .__name__ , t .attributes ()]))
50- return self
51-
52- def repeat (self , n : uint ) -> Input :
53- """
54- Creates a `new` `Input` made of `n` times `self`.
55- """
56- Global .stack .append (("Repeat" , self .index , [n ]))
48+ Global .transformationStack .append (("Apply" , self .index , [t .__class__ .__name__ , t .attributes ()]))
5749 return self
5850
5951 def copy (self ) -> Input :
6052 """
6153 Creates a `copy` of `self`.
6254 """
6355 cp = copy .deepcopy (self )
64- cp .index = len (Global .variable )
65- Global .variable .append (Global .variable [self .index ])
66- Global .stack .append (("Copy" , self .index , []))
56+ cp .index = len (Global .requiredInputs )
57+ Global .requiredInputs .append (("Copy" , [self .index ]))
6758 return cp
6859
69- def concat (self , i : Input ) -> Input :
70- """
71- Concatenates `i` after `self`.
72- """
73- Global .stack .append (("Concat" , self .index , [i .index ]))
74- return self
75-
76- def merge (self , i : Input ) -> Input :
77- """
78- Merges with `i`.
79-
80- Each `Input` will have the same ratio on the result.
81- """
82- Global .stack .append (("Merge" , self .index , [i .index ]))
83- return self
84-
85- def overlay (self , i : Input ) -> Input :
86- """
87- Overlays `i` on top of `self`.
88-
89- `i` has a ratio priority over `self`.
90- """
91- Global .stack .append (("Overlay" , self .index , [i .index ]))
92- return self
93-
9460 def __getitem__ (self , i : int | slice [int , int , None ]) -> Slice :
9561 """
9662 Creates a `reference` of the `frames` `s`.
9763
9864 Usefull if you want to apply a `Transformation` to a part of a video.
65+
66+ Examples
67+ --------
68+ >>> v = video("test.mp4")
69+ >>> v[0:20].fade() # Fade-in during the first 20 frames.
70+ >>> v.add()
9971 """
10072 if isinstance (i , int ):
10173 s = slice (i , i )
@@ -108,8 +80,7 @@ def __getitem__(self, i: int | slice[int, int, None]) -> Slice:
10880 s = slice (start , stop )
10981
11082 temp = Slice (self , s )
111- Global .variable .append (("Slice" , [self .index , s .start , s .stop ]))
112- Global .stack .append (("Slice" , self .index , [s .start , s .stop ]))
83+ Global .requiredInputs .append (("Slice" , [self .index , s .start , s .stop ]))
11384 return temp
11485
11586
0 commit comments