moviepy-layout 0.1.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2025 Kmm Hanan
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,239 @@
1
+ Metadata-Version: 2.4
2
+ Name: moviepy-layout
3
+ Version: 0.1.0
4
+ Summary: Composable layout primitives for MoviePy, with RGBA gradients and asset modes
5
+ Home-page: https://github.com/kmmhanan/moviepy-layout
6
+ Author: Kmm Hanan
7
+ Author-email: hanan@kmmhanan.com
8
+ Classifier: Programming Language :: Python :: 3
9
+ Classifier: License :: OSI Approved :: MIT License
10
+ Classifier: Topic :: Multimedia :: Video
11
+ Requires-Python: >=3.8
12
+ Description-Content-Type: text/markdown
13
+ License-File: LICENSE
14
+ Requires-Dist: moviepy==1.0.3
15
+ Requires-Dist: numpy==2.3.2
16
+ Requires-Dist: Pillow==9.5.0
17
+ Requires-Dist: scipy==1.16.1
18
+ Dynamic: author
19
+ Dynamic: author-email
20
+ Dynamic: classifier
21
+ Dynamic: description
22
+ Dynamic: description-content-type
23
+ Dynamic: home-page
24
+ Dynamic: license-file
25
+ Dynamic: requires-dist
26
+ Dynamic: requires-python
27
+ Dynamic: summary
28
+
29
+ # moviepy-layout
30
+
31
+ Composable layout primitives for [MoviePy](https://zulko.github.io/moviepy/), inspired by **Flutter** and **CSS**.
32
+
33
+ ## ✨ Features
34
+
35
+ - 🎨 **Gradient backgrounds** with directional control
36
+ - 🖼️ **Asset resizing** (`cover`, `contain`, `fit`, `fill`)
37
+ - 📦 **Box & Container layouts** with padding, margin, background color/gradient
38
+ - 📐 **Flex layouts** (`row`, `column`) with alignment & gaps
39
+ - 📚 **Stack layouts** for overlaying clips by z-index
40
+ - 🔤 **Text utilities** with alignment, wrapping, gradients, shadows
41
+ - 🎭 **Effects** like shadow, blur, inner shadow
42
+ - 🎨 **Color conversion** utilities (`hex ↔ rgba`)
43
+
44
+ ---
45
+
46
+ ## 📦 Installation
47
+
48
+ ```bash
49
+ pip install moviepy-layout
50
+ ```
51
+
52
+ ---
53
+
54
+ ## 🚀 Usage Example
55
+
56
+ ```python
57
+ from moviepy.editor import ImageClip
58
+ from moviepy-layout import Layout, Gradient
59
+
60
+ # Create a gradient background
61
+ gradient = Gradient(
62
+ direction="top_to_bottom",
63
+ stops=[
64
+ ((255, 0, 0, 255), 0.0),
65
+ ((0, 0, 255, 255), 1.0),
66
+ ]
67
+ )
68
+
69
+ bg = ImageClip(gradient.render((1280, 720)), ismask=False)
70
+
71
+ # Resize with cover mode
72
+ clip = Layout.asset(bg, width=720, height=1280, mode="cover")
73
+ clip.preview()
74
+ ```
75
+
76
+ ---
77
+
78
+ ## 🛠️ API Reference
79
+
80
+ ### 🎨 Gradient
81
+
82
+ ```python
83
+ Gradient(
84
+ direction="top_to_bottom", # gradient direction
85
+ stops=[((r,g,b,a), position), ...] # color stops
86
+ ).render((width, height))
87
+ ```
88
+
89
+ Supported directions:
90
+ - `top_to_bottom`
91
+ - `bottom_to_top`
92
+ - `left_to_right`
93
+ - `right_to_left`
94
+ - `top_left_to_bottom_right`
95
+ - `bottom_right_to_top_left`
96
+ - `top_right_to_bottom_left`
97
+ - `bottom_left_to_top_right`
98
+
99
+ ---
100
+
101
+ ### 🎬 Layout Utilities
102
+
103
+ #### `Layout.asset(...)`
104
+ Resize a clip with a given mode.
105
+
106
+ - `cover`: fills container, crops excess
107
+ - `contain`: fits inside container, maintains aspect ratio
108
+ - `fit`: resizes to match one dimension
109
+ - `fill`: stretches to fill container
110
+
111
+ #### `Layout.box(...)`
112
+ Create a box with optional child.
113
+
114
+ ```python
115
+ Layout.box(
116
+ width=500,
117
+ height=500,
118
+ child=my_clip,
119
+ padding=(10, 20, 10, 20),
120
+ margin=(5, 5, 5, 5),
121
+ bg_color=(255, 255, 255),
122
+ duration=5.0,
123
+ screen_size=(1080, 1920)
124
+ )
125
+ ```
126
+
127
+ #### `Layout.container(...)`
128
+ A more advanced box with alignment, gradient, radius, and border options.
129
+
130
+ ```python
131
+ Layout.container(
132
+ child=my_clip,
133
+ padding=20, # or (top, right, bottom, left)
134
+ margin=10,
135
+ vertical_alignment="center", # "top" | "center" | "bottom"
136
+ horizontal_alignment="center", # "left" | "center" | "right"
137
+ gradient=my_gradient, # optional Gradient instance
138
+ bg_color=(255, 255, 255, 255),
139
+ radius=10, # rounded corners
140
+ border={"color": (0, 0, 0, 255), "width": 2},
141
+ size=(500, 500),
142
+ duration=5.0
143
+ )
144
+ ```
145
+
146
+ #### `Layout.flex(...)`
147
+ Arrange multiple clips in a row or column.
148
+
149
+ ```python
150
+ Layout.flex(
151
+ children=[clip1, clip2, clip3],
152
+ direction="row", # "row" | "column"
153
+ vertical_alignment="center", # for "column" direction
154
+ horizontal_alignment="center", # for "row" direction
155
+ gap=20, # space between children
156
+ width="fit", # "full" | "fit"
157
+ height="fit", # "full" | "fit"
158
+ screen_size=(1080, 1920),
159
+ duration=5.0
160
+ )
161
+ ```
162
+
163
+ #### `Layout.stack(...)`
164
+ Overlay clips with z-order.
165
+
166
+ ```python
167
+ Layout.stack(
168
+ children=[(background_clip, 0), (overlay_clip, 1), (text_clip, 2)],
169
+ size=(1080, 1920),
170
+ duration=5.0
171
+ )
172
+ ```
173
+
174
+ #### `Layout.text(...)`
175
+ Create styled text clips with gradient, shadows, alignment, wrapping.
176
+
177
+ ```python
178
+ Layout.text(
179
+ text="Hello World",
180
+ font_size=64,
181
+ font="Arial",
182
+ width=500, # optional, for wrapping
183
+ gradient_hex="#ff0000ff,#0000ffff", # optional gradient fill
184
+ font_color=(255, 255, 255, 255),
185
+ text_align="center", # "left" | "center" | "right"
186
+ text_wrap=True,
187
+ shadow={
188
+ "color": (0, 0, 0, 128),
189
+ "offset": (4, 4),
190
+ "blur": 5
191
+ },
192
+ duration=5.0
193
+ )
194
+ ```
195
+
196
+ #### `Layout.effect(...)`
197
+ Apply visual effects (`shadow`, `blur`, `inner_shadow`) to clips.
198
+
199
+ - Shadow
200
+
201
+ ```python
202
+ Layout.effect(my_clip, effect="shadow", effect_params={"color": (0, 0, 0, 128), "offset": (10, 10)})
203
+ ```
204
+
205
+ - Blur
206
+
207
+ ```python
208
+ Layout.effect(my_clip, effect="blur", effect_params={"radius": 5})
209
+ ```
210
+
211
+ - Inner Shadow
212
+
213
+ ```python
214
+ Layout.effect(my_clip, effect="inner_shadow", effect_params={"color": (0, 0, 0, 128), "offset": (5, 5), "blur": 10})
215
+ ```
216
+
217
+ ---
218
+
219
+ ### 🎨 Color Utilities
220
+
221
+ ```python
222
+ Layout.rgba_to_hex((255, 0, 0, 255)) # "#ff0000ff"
223
+ Layout.hex_to_rgba("#ff0000ff") # (255, 0, 0, 255)
224
+ ```
225
+
226
+ ---
227
+
228
+ ## 📖 Example Project Ideas
229
+
230
+ - Instagram story generators
231
+ - Slideshow editors
232
+ - Dynamic caption overlays
233
+ - UI-style compositions with MoviePy
234
+
235
+ ---
236
+
237
+ ## 📜 License
238
+
239
+ MIT License © 2025 Kmm Hanan
@@ -0,0 +1,211 @@
1
+ # moviepy-layout
2
+
3
+ Composable layout primitives for [MoviePy](https://zulko.github.io/moviepy/), inspired by **Flutter** and **CSS**.
4
+
5
+ ## ✨ Features
6
+
7
+ - 🎨 **Gradient backgrounds** with directional control
8
+ - 🖼️ **Asset resizing** (`cover`, `contain`, `fit`, `fill`)
9
+ - 📦 **Box & Container layouts** with padding, margin, background color/gradient
10
+ - 📐 **Flex layouts** (`row`, `column`) with alignment & gaps
11
+ - 📚 **Stack layouts** for overlaying clips by z-index
12
+ - 🔤 **Text utilities** with alignment, wrapping, gradients, shadows
13
+ - 🎭 **Effects** like shadow, blur, inner shadow
14
+ - 🎨 **Color conversion** utilities (`hex ↔ rgba`)
15
+
16
+ ---
17
+
18
+ ## 📦 Installation
19
+
20
+ ```bash
21
+ pip install moviepy-layout
22
+ ```
23
+
24
+ ---
25
+
26
+ ## 🚀 Usage Example
27
+
28
+ ```python
29
+ from moviepy.editor import ImageClip
30
+ from moviepy-layout import Layout, Gradient
31
+
32
+ # Create a gradient background
33
+ gradient = Gradient(
34
+ direction="top_to_bottom",
35
+ stops=[
36
+ ((255, 0, 0, 255), 0.0),
37
+ ((0, 0, 255, 255), 1.0),
38
+ ]
39
+ )
40
+
41
+ bg = ImageClip(gradient.render((1280, 720)), ismask=False)
42
+
43
+ # Resize with cover mode
44
+ clip = Layout.asset(bg, width=720, height=1280, mode="cover")
45
+ clip.preview()
46
+ ```
47
+
48
+ ---
49
+
50
+ ## 🛠️ API Reference
51
+
52
+ ### 🎨 Gradient
53
+
54
+ ```python
55
+ Gradient(
56
+ direction="top_to_bottom", # gradient direction
57
+ stops=[((r,g,b,a), position), ...] # color stops
58
+ ).render((width, height))
59
+ ```
60
+
61
+ Supported directions:
62
+ - `top_to_bottom`
63
+ - `bottom_to_top`
64
+ - `left_to_right`
65
+ - `right_to_left`
66
+ - `top_left_to_bottom_right`
67
+ - `bottom_right_to_top_left`
68
+ - `top_right_to_bottom_left`
69
+ - `bottom_left_to_top_right`
70
+
71
+ ---
72
+
73
+ ### 🎬 Layout Utilities
74
+
75
+ #### `Layout.asset(...)`
76
+ Resize a clip with a given mode.
77
+
78
+ - `cover`: fills container, crops excess
79
+ - `contain`: fits inside container, maintains aspect ratio
80
+ - `fit`: resizes to match one dimension
81
+ - `fill`: stretches to fill container
82
+
83
+ #### `Layout.box(...)`
84
+ Create a box with optional child.
85
+
86
+ ```python
87
+ Layout.box(
88
+ width=500,
89
+ height=500,
90
+ child=my_clip,
91
+ padding=(10, 20, 10, 20),
92
+ margin=(5, 5, 5, 5),
93
+ bg_color=(255, 255, 255),
94
+ duration=5.0,
95
+ screen_size=(1080, 1920)
96
+ )
97
+ ```
98
+
99
+ #### `Layout.container(...)`
100
+ A more advanced box with alignment, gradient, radius, and border options.
101
+
102
+ ```python
103
+ Layout.container(
104
+ child=my_clip,
105
+ padding=20, # or (top, right, bottom, left)
106
+ margin=10,
107
+ vertical_alignment="center", # "top" | "center" | "bottom"
108
+ horizontal_alignment="center", # "left" | "center" | "right"
109
+ gradient=my_gradient, # optional Gradient instance
110
+ bg_color=(255, 255, 255, 255),
111
+ radius=10, # rounded corners
112
+ border={"color": (0, 0, 0, 255), "width": 2},
113
+ size=(500, 500),
114
+ duration=5.0
115
+ )
116
+ ```
117
+
118
+ #### `Layout.flex(...)`
119
+ Arrange multiple clips in a row or column.
120
+
121
+ ```python
122
+ Layout.flex(
123
+ children=[clip1, clip2, clip3],
124
+ direction="row", # "row" | "column"
125
+ vertical_alignment="center", # for "column" direction
126
+ horizontal_alignment="center", # for "row" direction
127
+ gap=20, # space between children
128
+ width="fit", # "full" | "fit"
129
+ height="fit", # "full" | "fit"
130
+ screen_size=(1080, 1920),
131
+ duration=5.0
132
+ )
133
+ ```
134
+
135
+ #### `Layout.stack(...)`
136
+ Overlay clips with z-order.
137
+
138
+ ```python
139
+ Layout.stack(
140
+ children=[(background_clip, 0), (overlay_clip, 1), (text_clip, 2)],
141
+ size=(1080, 1920),
142
+ duration=5.0
143
+ )
144
+ ```
145
+
146
+ #### `Layout.text(...)`
147
+ Create styled text clips with gradient, shadows, alignment, wrapping.
148
+
149
+ ```python
150
+ Layout.text(
151
+ text="Hello World",
152
+ font_size=64,
153
+ font="Arial",
154
+ width=500, # optional, for wrapping
155
+ gradient_hex="#ff0000ff,#0000ffff", # optional gradient fill
156
+ font_color=(255, 255, 255, 255),
157
+ text_align="center", # "left" | "center" | "right"
158
+ text_wrap=True,
159
+ shadow={
160
+ "color": (0, 0, 0, 128),
161
+ "offset": (4, 4),
162
+ "blur": 5
163
+ },
164
+ duration=5.0
165
+ )
166
+ ```
167
+
168
+ #### `Layout.effect(...)`
169
+ Apply visual effects (`shadow`, `blur`, `inner_shadow`) to clips.
170
+
171
+ - Shadow
172
+
173
+ ```python
174
+ Layout.effect(my_clip, effect="shadow", effect_params={"color": (0, 0, 0, 128), "offset": (10, 10)})
175
+ ```
176
+
177
+ - Blur
178
+
179
+ ```python
180
+ Layout.effect(my_clip, effect="blur", effect_params={"radius": 5})
181
+ ```
182
+
183
+ - Inner Shadow
184
+
185
+ ```python
186
+ Layout.effect(my_clip, effect="inner_shadow", effect_params={"color": (0, 0, 0, 128), "offset": (5, 5), "blur": 10})
187
+ ```
188
+
189
+ ---
190
+
191
+ ### 🎨 Color Utilities
192
+
193
+ ```python
194
+ Layout.rgba_to_hex((255, 0, 0, 255)) # "#ff0000ff"
195
+ Layout.hex_to_rgba("#ff0000ff") # (255, 0, 0, 255)
196
+ ```
197
+
198
+ ---
199
+
200
+ ## 📖 Example Project Ideas
201
+
202
+ - Instagram story generators
203
+ - Slideshow editors
204
+ - Dynamic caption overlays
205
+ - UI-style compositions with MoviePy
206
+
207
+ ---
208
+
209
+ ## 📜 License
210
+
211
+ MIT License © 2025 Kmm Hanan
@@ -0,0 +1 @@
1
+ from .layout import Layout, Gradient