Skip to content

Commit 8058d19

Browse files
committed
docs: clarify slices
1 parent 535316e commit 8058d19

File tree

5 files changed

+25
-12
lines changed

5 files changed

+25
-12
lines changed

frontend/Serialize.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ def serializeScene(filepath: str) -> str:
3838
__name__ = "Scene"
3939
exec(content, globals())
4040

41-
# Access Globals: `variable` and `stack`
41+
# Access Globals: `requiredInputs` and `actionStack`
4242
g = Global()
4343

4444
# Serialize the instructions to JSON

frontend/input/Input.py

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -17,14 +17,18 @@ class Input(ABC):
1717
1818
You cannot create an `Input` from the base class.
1919
20+
Basic `Inputs`:
2021
.. code-block:: python
2122
def image(filepath: str) -> Input: ...
2223
def video(filepath: str) -> Input: ...
2324
def text(string: str) -> Input: ...
24-
def shape() -> Input: ...
25+
def circle(radius: int) -> Input: ...
2526
"""
2627

2728
index: int
29+
"""
30+
Index of the `Input`.
31+
"""
2832

2933
def __new__(cls, *args, **kwargs) -> Self:
3034
instance = super().__new__(cls)
@@ -75,23 +79,25 @@ def copy(self) -> Input:
7579
)
7680
return cp
7781

78-
def __getitem__(self, i: int | slice[int, int, None]) -> Slice:
82+
def __getitem__(self, i: int | slice[int | None, int | None, None]) -> Slice:
7983
"""
80-
Creates a `reference` of the `frames` `s`.
84+
Creates a `reference` of the `frames` `i`.
8185
8286
Usefull if you want to apply a `Transformation` to a part of a video.
8387
84-
Examples
85-
--------
88+
---
89+
### Example
8690
>>> v = video("test.mp4")
87-
>>> v[0:20].fade() # Fade-in during the first 20 frames.
88-
>>> v.add()
91+
>>> v[0:20].fade() # fade in during the first 20 frames.
92+
>>> v.add() # adds it to the timeline
93+
8994
"""
9095
if isinstance(i, int):
9196
s = slice(i, i)
9297
else:
93-
s = i
98+
s = slice(i.start or 0, i.stop or -1)
9499

100+
# `Slice` of `Slice`
95101
if isinstance(self, Slice):
96102
start = -1 if s.start == -1 or self.s.start == -1 else self.s.start + s.start
97103
stop = -1 if s.stop == -1 else self.s.start + s.stop

frontend/transformation/color/Fade.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@ def __init__(self, sides: list[side] = ALL, startOpacity: uint = 0, endOpacity:
1111
`Fade` from `side`.
1212
1313
Modify `opacity` for a `Fade in` or a `Fade out`.
14+
15+
Default: `Fade in`.
1416
"""
1517
self.sides = sides
1618
self.startOpacity = startOpacity

include/vm/Register.hpp

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -41,16 +41,18 @@ class Register
4141
///< Variables representing the Inputs currently used in the program
4242
std::vector<std::shared_ptr<IInput>> _inputs{};
4343

44-
///< Instructions to create new Inputs: [[instructionName, [instructionArgs]]]
44+
///< Instructions to create new Inputs: [[instructionName, {instructionArgs}]]
4545
json::array_t _instructions{};
4646

4747
///< Each instruction
4848
const std::map<std::string, std::function<void(const json::object_t &)>> _inputFactory{
4949
{"Image", [this](const json::object_t &args) { _inputs.push_back(std::make_shared<Image>(args.at("filepath"))); }},
5050
{"Video", [this](const json::object_t &args) { _inputs.push_back(std::make_shared<Video>(args.at("filepath"))); }},
5151
{"Copy", [this](const json::object_t &args) { _inputs.push_back(std::shared_ptr<IInput>(_inputs[args.at("input")]->copy())); }},
52-
// TODO: Shapes
52+
/// TODO: Shapes (Circle, Square)
53+
/// TODO: Text (List of char)
54+
/// TODO: Formula (not important)
5355
};
5456

55-
// TODO: env to keep track of already loaded images. prevent reload everytime
57+
/// TODO: env to keep track of already loaded images. prevent reload everytime
5658
};

src/vm/Register.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,9 @@
1212
void Register::updateInstructions(json::array_t&& newInstructions)
1313
{
1414
_instructions = std::forward<json::array_t>(newInstructions);
15+
16+
/// TODO: cache
17+
_inputs.clear();
1518
}
1619

1720
void Register::runNextInstruction()

0 commit comments

Comments
 (0)