Skip to content

Commit 690f442

Browse files
committed
working on documentation and exporting and printing
1 parent 8771d24 commit 690f442

24 files changed

Lines changed: 7143 additions & 2216 deletions

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ media/
3434
*.png
3535
*.pi
3636
*.pv
37+
*.txt
3738
install/
3839
out/
3940
bin/

README.md

Lines changed: 42 additions & 237 deletions
Original file line numberDiff line numberDiff line change
@@ -21,271 +21,76 @@ Welcome! Pythonic is a modern C++20 library that brings the expressive power and
2121
- Seamless integration with modern C++ projects
2222
- Great for teaching, competitive programming, and research
2323

24-
## User Guides & Documentation
25-
26-
- For a complete step-by-step guide on cloning, building, installing, and using this library in your own project, see the detailed [Getting Started Guide](docs/examples/README.md).
27-
- **Note:** If you don't want to install, you can simply add the `include/pythonic` directory to your project's include path and use `target_include_directories` in your CMakeLists.txt.
28-
- For a detailed user guide, [check out the documentation](docs/index.md).
29-
30-
## Optional: Graph Viewer Dependencies
31-
32-
The library includes an **optional** interactive graph visualization feature. To enable it, you need to install the following dependencies:
33-
34-
### Ubuntu/Debian:
35-
36-
```bash
37-
sudo apt-get update
38-
sudo apt-get install libglfw3-dev libgl1-mesa-dev
39-
git clone https://github.com/ocornut/imgui.git external/imgui
40-
```
41-
42-
### macOS:
43-
44-
```bash
45-
brew install glfw
46-
git clone https://github.com/ocornut/imgui.git external/imgui
47-
```
48-
49-
### Windows (vcpkg):
50-
51-
```bash
52-
vcpkg install glfw3:x64-windows
53-
git clone https://github.com/ocornut/imgui.git external/imgui
54-
```
55-
56-
Then build with:
57-
58-
```bash
59-
cmake -B build -DPYTHONIC_ENABLE_GRAPH_VIEWER=ON
60-
cmake --build build
61-
```
62-
63-
Use in code:
24+
## Quick Example
6425

6526
```cpp
6627
#include <pythonic/pythonic.hpp>
6728
using namespace pythonic::vars;
68-
69-
var g = graph(5);
70-
g.add_edge(0, 1);
71-
g.add_edge(1, 2);
72-
g.show(); // Opens interactive viewer!
73-
```
74-
75-
## Optional: Media Rendering Dependencies
76-
77-
For terminal media rendering (images and videos), you need:
78-
79-
- **ImageMagick** - For image format conversion
80-
- **FFmpeg** - For video decoding
81-
82-
### Ubuntu/Debian:
83-
84-
```bash
85-
sudo apt-get install imagemagick ffmpeg
86-
```
87-
88-
### macOS:
89-
90-
```bash
91-
brew install imagemagick ffmpeg
92-
```
93-
94-
### Usage:
95-
96-
```cpp
97-
#include <pythonic/pythonic.hpp>
98-
using namespace Pythonic;
99-
100-
// Print image in braille (black & white, high resolution)
101-
print("photo.png", Type::image);
102-
103-
// Print image in true color (block characters)
104-
print("photo.png", Type::image, Mode::colored);
105-
106-
// Print image in colored braille (combines color + high resolution)
107-
print("photo.png", Type::image, Mode::colored_dot);
108-
109-
// Play video in true color
110-
print("video.mp4", Type::video, Mode::colored);
111-
```
112-
113-
### Rendering Modes
114-
115-
Pythonic supports four rendering modes for images and videos:
116-
117-
| Mode | Description | Resolution | Colors |
118-
| ------------------- | --------------------------- | ---------------------- | ------------------------------ |
119-
| `Mode::bw_dot` | Braille patterns (default) | 8x terminal resolution | B&W |
120-
| `Mode::bw` | Block characters (▀▄█) | 2x terminal resolution | B&W |
121-
| `Mode::colored` | Block characters with color | 2x terminal resolution | True color |
122-
| `Mode::colored_dot` | Braille with color | 8x terminal resolution | True color (averaged per cell) |
123-
124-
## Optional: Audio Playback for Videos
125-
126-
To play videos with synchronized audio, you need SDL2 or PortAudio:
127-
128-
### Ubuntu/Debian:
129-
130-
```bash
131-
# SDL2 (recommended)
132-
sudo apt-get install libsdl2-dev
133-
134-
# Or PortAudio
135-
sudo apt-get install portaudio19-dev libportaudio2
136-
```
137-
138-
### macOS:
139-
140-
```bash
141-
# SDL2 (recommended)
142-
brew install sdl2
143-
144-
# Or PortAudio
145-
brew install portaudio
146-
```
147-
148-
### Windows (vcpkg):
149-
150-
```bash
151-
# SDL2 (recommended)
152-
vcpkg install sdl2:x64-windows
153-
154-
# Or PortAudio
155-
vcpkg install portaudio:x64-windows
156-
```
157-
158-
Then build with audio support:
159-
160-
```bash
161-
# With SDL2
162-
cmake -B build -DPYTHONIC_ENABLE_SDL2_AUDIO=ON
163-
cmake --build build
164-
165-
# Or with PortAudio
166-
cmake -B build -DPYTHONIC_ENABLE_PORTAUDIO=ON
167-
cmake --build build
168-
```
169-
170-
Use in code:
171-
172-
```cpp
173-
#include <pythonic/pythonic.hpp>
17429
using namespace Pythonic;
17530

176-
// Play video with audio
177-
print("video.mp4", Type::video, Mode::bw_dot, Parser::default_parser, Audio::on);
178-
179-
// Play video with audio in true color
180-
print("video.mp4", Type::video, Mode::colored, Parser::default_parser, Audio::on);
181-
```
182-
183-
> **Note:** If audio libraries are not available, `Audio::on` will automatically fall back to silent video playback.
31+
int main() {
32+
// Python-style dynamic variables
33+
var x = 42;
34+
var name = "Alice";
35+
var data = list({1, 2, 3, 4, 5});
18436

185-
## Optional: GPU-Accelerated Video Rendering
37+
print("Hello,", name, "! Sum:", sum(data));
18638

187-
For smoother colored video playback, you can enable OpenCL GPU acceleration:
39+
// Terminal plotting
40+
pythonic::plot::plot([](double x) { return sin(x); }, -3.14, 3.14);
18841

189-
### Ubuntu/Debian:
42+
// Print images/videos in terminal
43+
print("photo.png"); // Displays image as braille art
44+
print("video.mp4"); // Plays video in terminal
19045

191-
```bash
192-
sudo apt-get install ocl-icd-opencl-dev opencl-clhpp-headers
193-
```
194-
195-
### macOS:
196-
197-
OpenCL is included with macOS - no additional installation needed.
198-
199-
### Windows (vcpkg):
200-
201-
```bash
202-
vcpkg install opencl:x64-windows
46+
return 0;
47+
}
20348
```
20449
205-
Then build with OpenCL support:
50+
## User Guides & Documentation
20651
207-
```bash
208-
cmake -B build -DPYTHONIC_ENABLE_OPENCL=ON
209-
cmake --build build
210-
```
52+
- **[Getting Started Guide](docs/examples/README.md)** — Complete step-by-step guide on cloning, building, installing, and using this library (includes all optional dependencies)
53+
- **[API Documentation](docs/index.md)** — Detailed user guide for all features
21154
212-
> **Note:** OpenCL support is optional. If not available, video rendering will use CPU with optimized buffering.
55+
## Optional Features
21356
214-
## Optional: OpenCV for Webcam and Advanced Processing
57+
The library includes several optional features that can be enabled during build:
21558
216-
For webcam capture and advanced image/video processing, you can enable OpenCV support:
59+
| Feature | Description | CMake Flag | Dependencies |
60+
| ------------------ | ------------------------------------------ | ----------------------------------- | ------------------- |
61+
| **Graph Viewer** | Interactive graph visualization with ImGui | `-DPYTHONIC_ENABLE_GRAPH_VIEWER=ON` | GLFW, OpenGL, ImGui |
62+
| **Audio Playback** | Synchronized audio for video playback | `-DPYTHONIC_ENABLE_SDL2_AUDIO=ON` | SDL2 or PortAudio |
63+
| **GPU Rendering** | GPU-accelerated video rendering | `-DPYTHONIC_ENABLE_OPENCL=ON` | OpenCL |
64+
| **OpenCV Support** | Webcam capture & advanced processing | `-DPYTHONIC_ENABLE_OPENCV=ON` | OpenCV |
21765
218-
### Ubuntu/Debian:
66+
> **Note:** All features are optional. The core library works without any of these dependencies. See the [Getting Started Guide](docs/examples/README.md) for detailed installation instructions for each feature.
21967
220-
```bash
221-
sudo apt-get install libopencv-dev
222-
```
223-
224-
### macOS:
68+
## Basic Installation
22569
22670
```bash
227-
brew install opencv
228-
```
71+
# Clone the repository
72+
git clone https://github.com/Creamy-pie-96/Pythonic.git
73+
cd Pythonic
22974
230-
### Windows (vcpkg):
75+
# Build and install (core features only)
76+
mkdir build && cd build
77+
cmake .. -DCMAKE_INSTALL_PREFIX=../install
78+
cmake --build . --target install
23179
232-
```bash
233-
vcpkg install opencv:x64-windows
80+
# Use in your project's CMakeLists.txt
81+
find_package(pythonic REQUIRED)
82+
target_link_libraries(your_target pythonic::pythonic)
23483
```
23584

236-
Then build with OpenCV support:
237-
238-
```bash
239-
cmake -B build -DPYTHONIC_ENABLE_OPENCV=ON
240-
cmake --build build
241-
```
85+
For detailed installation with optional features, see the [Getting Started Guide](docs/examples/README.md).
24286

243-
Use in code:
87+
## Contributing
24488

245-
```cpp
246-
#include <pythonic/pythonic.hpp>
247-
using namespace Pythonic;
89+
See [CONTRIBUTING.md](docs/contributing.md) for guidelines on how to contribute to this project.
24890

249-
// Capture from webcam (requires OpenCV)
250-
print("0", Type::webcam); // Use device 0
251-
print("/dev/video0", Type::webcam); // Linux device path
91+
## License
25292

253-
// Use OpenCV backend for image/video processing
254-
print("photo.png", Type::image, Mode::colored, Parser::opencv);
255-
print("video.mp4", Type::video, Mode::colored_dot, Parser::opencv);
256-
```
257-
258-
### Parser Backends
259-
260-
| Parser | Description | Supports |
261-
| ------------------------ | -------------------------------------------------- | -------------------- |
262-
| `Parser::default_parser` | FFmpeg for video, ImageMagick for images (default) | All media formats |
263-
| `Parser::opencv` | OpenCV for everything | Media files + webcam |
264-
265-
> **Note:** Webcam capture always requires OpenCV. If OpenCV is not available, an exception is thrown for webcam sources.
266-
267-
## Proprietary Media Format (.pi, .pv)
268-
269-
Pythonic includes a media encryption system for protecting images and videos:
270-
271-
```cpp
272-
#include <pythonic/pythonicMedia.hpp>
273-
using namespace pythonic::media;
274-
275-
// Convert image to encrypted Pythonic format
276-
convert("photo.jpg"); // Creates photo.pi
277-
278-
// Convert video to encrypted Pythonic format
279-
convert("video.mp4"); // Creates video.pv
280-
281-
// Revert back to original format
282-
revert("photo.pi"); // Creates photo_restored.jpg
283-
revert("video.pv"); // Creates video_restored.mp4
284-
285-
// Print encrypted files directly (auto-detected)
286-
print("photo.pi"); // Works like original image
287-
print("video.pv"); // Works like original video
288-
```
93+
This project is licensed under the MIT License - see the LICENSE file for details.
28994

29095
## Disclaimer:
29196

0 commit comments

Comments
 (0)