Skip to content

Commit 5f4b798

Browse files
committed
fixed the video export and rendering and some issues with the progress bar
1 parent de39333 commit 5f4b798

4 files changed

Lines changed: 6023 additions & 3069 deletions

File tree

docs/Export/export.md

Lines changed: 78 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,56 @@ bool emit(input_path, output_name, RenderConfig = {}, ExportConfig = {})
4949

5050
---
5151

52+
## Text-to-Braille Art Export
53+
54+
Export text strings as braille art using `TextArt` tag:
55+
56+
```cpp
57+
bool emit(TextArt, text, output_name, TextConfig = {})
58+
```
59+
60+
| Parameter | Type | Default | Description |
61+
| ------------- | ------------- | -------------- | --------------------------------- |
62+
| `TextArt` | tag | Required | Tag indicating text-to-braille |
63+
| `text` | `std::string` | Required | Text to render |
64+
| `output_name` | `std::string` | Required | Output filename (.txt auto-added) |
65+
| `TextConfig` | config object | `TextConfig()` | Text rendering options |
66+
67+
### TextConfig
68+
69+
| Field | Type | Default | Description |
70+
| ----------- | --------- | -------------- | ------------------------ |
71+
| `mode` | `Mode` | `Mode::bw_dot` | Rendering mode |
72+
| `fg_r` | `uint8_t` | `255` | Foreground red (0-255) |
73+
| `fg_g` | `uint8_t` | `255` | Foreground green (0-255) |
74+
| `fg_b` | `uint8_t` | `255` | Foreground blue (0-255) |
75+
| `max_width` | `int` | `0` | Max width (0=auto) |
76+
77+
### Examples
78+
79+
```cpp
80+
// Export text as braille art
81+
emit(TextArt, "Hello World!", "hello"); // → hello.txt
82+
83+
// Colored text
84+
emit(TextArt, "COLORED!", "color_text",
85+
TextConfig{.mode = Mode::colored});
86+
87+
// Custom color (red)
88+
emit(TextArt, "RED TEXT", "red_text",
89+
TextConfig{
90+
.mode = Mode::colored,
91+
.fg_r = 255,
92+
.fg_g = 0,
93+
.fg_b = 0
94+
});
95+
96+
// Multi-line text
97+
emit(TextArt, "Line 1\nLine 2\nLine 3", "multiline");
98+
```
99+
100+
---
101+
52102
## RenderConfig
53103

54104
Controls how media is rendered to ASCII/Braille art.
@@ -98,24 +148,39 @@ Controls pixel-level rendering for PNG/video output.
98148

99149
## Mode Enum
100150

101-
| Mode | Description | Resolution | Colors |
102-
| --------------------- | ---------------------------- | ----------- | --------- |
103-
| `Mode::bw_dot` | Braille patterns (default) | 8× terminal | B&W |
104-
| `Mode::bw` | Half-block characters | 2× terminal | B&W |
105-
| `Mode::colored` | Half-block with color | 2× terminal | 24-bit |
106-
| `Mode::colored_dot` | Braille with color | 8× terminal | 24-bit |
107-
| `Mode::grayscale_dot` | Grayscale braille | 8× terminal | Grayscale |
108-
| `Mode::flood_dot` | Flood-filled colored braille | 8× terminal | 24-bit |
151+
| Mode | Description | Resolution | Colors |
152+
| ------------------------- | ----------------------------------- | ----------- | --------- |
153+
| `Mode::bw_dot` | Braille patterns (default) | 8× terminal | B&W |
154+
| `Mode::bw` | Half-block characters | 2× terminal | B&W |
155+
| `Mode::colored` | Half-block with color | 2× terminal | 24-bit |
156+
| `Mode::colored_dot` | Braille with color | 8× terminal | 24-bit |
157+
| `Mode::grayscale_dot` | Grayscale braille | 8× terminal | Grayscale |
158+
| `Mode::bw_dithered` | B&W braille with dithering | 8× terminal | B&W |
159+
| `Mode::flood_dot` | Flood-filled braille (grayscale) | 8× terminal | Grayscale |
160+
| `Mode::flood_dot_colored` | Flood-filled braille with color | 8× terminal | 24-bit |
161+
| `Mode::colored_dithered` | Colored braille with ordered dither | 8× terminal | 24-bit |
109162

110163
---
111164

112165
## Dithering Enum
113166

114-
| Dithering | Description | Quality |
115-
| -------------------- | ------------------------------- | ------- |
116-
| `Dithering::none` | No dithering (default) | Fast |
117-
| `Dithering::ordered` | Ordered/Bayer dithering | Good |
118-
| `Dithering::floyd` | Floyd-Steinberg error diffusion | Best |
167+
Controls dithering algorithm for `Mode::bw_dithered` and `Mode::colored_dithered`:
168+
169+
| Dithering | Description | Quality | Best For |
170+
| ---------------------------- | --------------------------------- | ------- | ------------ |
171+
| `Dithering::none` | Simple threshold (no dithering) | Fast | Binary |
172+
| `Dithering::ordered` | Ordered/Bayer dithering (default) | Good | Video |
173+
| `Dithering::floyd_steinberg` | Floyd-Steinberg error diffusion | Best | Still images |
174+
175+
**Usage example:**
176+
177+
```cpp
178+
// Export with Floyd-Steinberg dithering for best quality
179+
emit("photo.png", "output", RenderConfig()
180+
.set_mode(Mode::colored_dithered)
181+
.set_dithering(Dithering::floyd_steinberg)
182+
.set_format(Format::image));
183+
```
119184
120185
---
121186

docs/Print/print.md

Lines changed: 117 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -20,12 +20,12 @@ print("Hello", "World", 42); // Output: Hello World 42
2020
var data = dict({{"name", "Alice"}, {"age", 30}});
2121
pprint(data); // Formatted output with indentation
2222

23-
// Render media file with Draw tag
24-
print(Draw, "photo.png"); // Renders image as braille
25-
print(Draw, "video.mp4"); // Plays video in terminal
23+
// Render media file with Media tag
24+
print(Media, "photo.png"); // Renders image as braille
25+
print(Media, "video.mp4"); // Plays video in terminal
2626

2727
// Render with RenderConfig
28-
print(Draw, "photo.png", RenderConfig().set_mode(Mode::colored).set_max_width(120));
28+
print(Media, "photo.png", RenderConfig().set_mode(Mode::colored).set_max_width(120));
2929
```
3030
3131
---
@@ -48,27 +48,27 @@ pprint(nested); // Formatted output
4848

4949
---
5050

51-
## Media Printing (Draw Tag)
51+
## Media Printing (Media Tag)
5252

53-
Use `Draw` tag to explicitly render media files:
53+
Use `Media` tag to explicitly render media files:
5454

55-
| Function | Description |
56-
| ------------------------------- | ---------------------------------- |
57-
| `print(Draw, filepath)` | Render media with default settings |
58-
| `print(Draw, filepath, config)` | Render media with RenderConfig |
55+
| Function | Description |
56+
| -------------------------------- | ---------------------------------- |
57+
| `print(Media, filepath)` | Render media with default settings |
58+
| `print(Media, filepath, config)` | Render media with RenderConfig |
5959

6060
```cpp
6161
// Render image
62-
print(Draw, "photo.png");
62+
print(Media, "photo.png");
6363

6464
// Render video with audio
65-
print(Draw, "video.mp4", RenderConfig().with_audio());
65+
print(Media, "video.mp4", RenderConfig().with_audio());
6666

6767
// Render with colored mode
68-
print(Draw, "image.jpg", RenderConfig().set_mode(Mode::colored));
68+
print(Media, "image.jpg", RenderConfig().set_mode(Mode::colored));
6969

7070
// Render with all options
71-
print(Draw, "video.mp4", RenderConfig()
71+
print(Media, "video.mp4", RenderConfig()
7272
.set_mode(Mode::colored_dot)
7373
.set_max_width(120)
7474
.with_audio()
@@ -77,6 +77,68 @@ print(Draw, "video.mp4", RenderConfig()
7777
7878
---
7979
80+
## Text-to-Braille Art (TextArt Tag)
81+
82+
Use `TextArt` tag to render text as braille art:
83+
84+
| Function | Description |
85+
| ------------------------------ | --------------------------------- |
86+
| `print(TextArt, text)` | Render text with default settings |
87+
| `print(TextArt, text, config)` | Render text with TextConfig |
88+
89+
### TextConfig
90+
91+
Configuration for text-to-braille rendering:
92+
93+
| Field | Type | Default | Description |
94+
| ----------- | --------- | -------------- | ------------------------ |
95+
| `mode` | `Mode` | `Mode::bw_dot` | Rendering mode |
96+
| `fg_r` | `uint8_t` | `255` | Foreground red (0-255) |
97+
| `fg_g` | `uint8_t` | `255` | Foreground green (0-255) |
98+
| `fg_b` | `uint8_t` | `255` | Foreground blue (0-255) |
99+
| `max_width` | `int` | `0` | Max width (0=auto) |
100+
101+
### Examples
102+
103+
```cpp
104+
// Basic text rendering
105+
print(TextArt, "Hello World!");
106+
107+
// Multi-line text
108+
print(TextArt, "Line 1\nLine 2\nLine 3");
109+
110+
// Colored text (white)
111+
print(TextArt, "COLORED!", TextConfig{.mode = Mode::colored});
112+
113+
// Custom color - red
114+
print(TextArt, "RED TEXT", TextConfig{
115+
.mode = Mode::colored,
116+
.fg_r = 255,
117+
.fg_g = 0,
118+
.fg_b = 0
119+
});
120+
121+
// Cyan text
122+
print(TextArt, "CYAN!", TextConfig{
123+
.mode = Mode::colored,
124+
.fg_r = 0,
125+
.fg_g = 255,
126+
.fg_b = 255
127+
});
128+
```
129+
130+
### Supported Characters
131+
132+
The built-in 3×5 pixel font supports:
133+
134+
- Uppercase letters: A-Z
135+
- Lowercase letters: a-z
136+
- Numbers: 0-9
137+
- Symbols: `! " ' ( ) + , - . / : ; < = > ? @`
138+
- Space character
139+
140+
---
141+
80142
## RenderConfig
81143

82144
Configuration class for media rendering with builder pattern.
@@ -101,14 +163,17 @@ Configuration class for media rendering with builder pattern.
101163

102164
## Mode Enum
103165

104-
| Mode | Description | Resolution | Colors |
105-
| --------------------- | --------------------- | ----------- | --------- |
106-
| `Mode::bw_dot` | Braille patterns | 8× terminal | B&W |
107-
| `Mode::bw` | Half-block characters | 2× terminal | B&W |
108-
| `Mode::colored` | Half-block with color | 2× terminal | 24-bit |
109-
| `Mode::colored_dot` | Braille with color | 8× terminal | 24-bit |
110-
| `Mode::grayscale_dot` | Grayscale braille | 8× terminal | Grayscale |
111-
| `Mode::flood_dot` | Flood-filled braille | 8× terminal | 24-bit |
166+
| Mode | Description | Resolution | Colors |
167+
| ------------------------- | ----------------------------------- | ----------- | --------- |
168+
| `Mode::bw_dot` | Braille patterns | 8× terminal | B&W |
169+
| `Mode::bw` | Half-block characters | 2× terminal | B&W |
170+
| `Mode::colored` | Half-block with color | 2× terminal | 24-bit |
171+
| `Mode::colored_dot` | Braille with color | 8× terminal | 24-bit |
172+
| `Mode::grayscale_dot` | Grayscale braille | 8× terminal | Grayscale |
173+
| `Mode::bw_dithered` | B&W braille with dithering | 8× terminal | B&W |
174+
| `Mode::flood_dot` | Flood-filled braille (grayscale) | 8× terminal | Grayscale |
175+
| `Mode::flood_dot_colored` | Flood-filled braille with color | 8× terminal | 24-bit |
176+
| `Mode::colored_dithered` | Colored braille with ordered dither | 8× terminal | 24-bit |
112177

113178
---
114179

@@ -127,11 +192,27 @@ Configuration class for media rendering with builder pattern.
127192

128193
## Dithering Enum
129194

130-
| Dithering | Description |
131-
| -------------------- | ------------------------------- |
132-
| `Dithering::none` | No dithering (default) |
133-
| `Dithering::ordered` | Ordered/Bayer dithering |
134-
| `Dithering::floyd` | Floyd-Steinberg error diffusion |
195+
Controls dithering algorithm for `Mode::bw_dithered` and `Mode::colored_dithered`:
196+
197+
| Dithering | Description | Best For |
198+
| ---------------------------- | --------------------------------- | ------------------ |
199+
| `Dithering::none` | Simple threshold (no dithering) | Fast binary output |
200+
| `Dithering::ordered` | Ordered/Bayer dithering (default) | Video, animation |
201+
| `Dithering::floyd_steinberg` | Floyd-Steinberg error diffusion | Still images |
202+
203+
**Usage example:**
204+
205+
```cpp
206+
// Use Floyd-Steinberg for best still image quality
207+
print(Media, "photo.png", RenderConfig()
208+
.set_mode(Mode::bw_dithered)
209+
.set_dithering(Dithering::floyd_steinberg));
210+
211+
// Use ordered dithering for video (faster, more stable)
212+
print(Media, "video.mp4", RenderConfig()
213+
.set_mode(Mode::colored_dithered)
214+
.set_dithering(Dithering::ordered));
215+
```
135216
136217
---
137218
@@ -141,13 +222,13 @@ Configuration class for media rendering with builder pattern.
141222
142223
```cpp
143224
// Basic image render
144-
print(Draw, "photo.png");
225+
print(Media, "photo.png");
145226
146227
// Colored rendering
147-
print(Draw, "photo.png", RenderConfig().set_mode(Mode::colored));
228+
print(Media, "photo.png", RenderConfig().set_mode(Mode::colored));
148229
149230
// High-quality with dithering
150-
print(Draw, "photo.jpg", RenderConfig()
231+
print(Media, "photo.jpg", RenderConfig()
151232
.set_mode(Mode::grayscale_dot)
152233
.set_dithering(Dithering::floyd)
153234
.set_max_width(160));
@@ -157,21 +238,21 @@ print(Draw, "photo.jpg", RenderConfig()
157238

158239
```cpp
159240
// Basic video
160-
print(Draw, "video.mp4");
241+
print(Media, "video.mp4");
161242

162243
// Video with audio
163-
print(Draw, "video.mp4", RenderConfig().with_audio());
244+
print(Media, "video.mp4", RenderConfig().with_audio());
164245

165246
// Interactive with controls
166-
print(Draw, "movie.mp4", RenderConfig()
247+
print(Media, "movie.mp4", RenderConfig()
167248
.set_mode(Mode::colored)
168249
.with_audio()
169250
.interactive()
170251
.set_pause_key('p')
171252
.set_stop_key('s'));
172253

173254
// Play video segment (1:00 to 2:00)
174-
print(Draw, "movie.mp4", RenderConfig()
255+
print(Media, "movie.mp4", RenderConfig()
175256
.set_start_time(60)
176257
.set_end_time(120));
177258
```
@@ -180,10 +261,10 @@ print(Draw, "movie.mp4", RenderConfig()
180261
181262
```cpp
182263
// Default webcam
183-
print(Draw, "0", RenderConfig().set_type(Type::webcam));
264+
print(Media, "0", RenderConfig().set_type(Type::webcam));
184265
185266
// Colored webcam
186-
print(Draw, "0", RenderConfig()
267+
print(Media, "0", RenderConfig()
187268
.set_type(Type::webcam)
188269
.set_mode(Mode::colored)
189270
.set_max_width(120));

0 commit comments

Comments
 (0)