Skip to content

Commit e2d6f77

Browse files
committed
update: documents for package
1 parent 3768180 commit e2d6f77

2 files changed

Lines changed: 477 additions & 18 deletions

File tree

README.md

Lines changed: 117 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -85,25 +85,40 @@ use runarium::generators::route_video::progressive_route_with_config;
8585

8686
fn main() -> Result<()> {
8787
// Configure route scale and position
88-
let route_scale = RouteScale::new(0.2, 0.1, 0.1);
88+
let route_scale = RouteScale::new(
89+
0.2, // scale
90+
0.1, // offset_x_percent
91+
0.1 // offset_y_percent
92+
);
8993

9094
// Configure colors (BGRA format)
9195
let colors = RouteColor::new(
92-
[0.0, 0.0, 255.0, 0.0], // Red route line
93-
[0.0, 255.0, 0.0, 0.0], // Green position marker
94-
[255.0, 255.0, 255.0, 0.0], // White text
95-
[0.0, 165.0, 255.0, 0.0], // Orange lap bars
96+
[0.0, 0.0, 255.0, 0.0], // route_line_color (Red)
97+
[0.0, 255.0, 0.0, 0.0], // current_position_color (Green)
98+
[255.0, 255.0, 255.0, 0.0], // text_color (White)
99+
[0.0, 165.0, 255.0, 0.0] // lap_bars_color (Orange)
96100
);
97101

98102
// Configure pace/distance display
99103
let pace_dist = PaceDistConfig::new(
100-
0.6, 2, Font::Simplex, None, true, true
104+
0.6, // pace_font_scale
105+
2, // pace_thickness
106+
Font::Simplex,// font_face
107+
None, // position (auto)
108+
true, // show_pace
109+
true // show_distance
101110
);
102111

103112
// Configure lap data panel
104113
let lap_data = LapDataConfig::new(
105-
(0.5, 0.09), 0.5, 1, Font::Simplex,
106-
Color::White, true, true, true
114+
(0.5, 0.09), // position (x, y)
115+
0.5, // lap_font_scale
116+
1, // lap_thickness
117+
Font::Simplex,// font_face
118+
Color::White, // text_color
119+
true, // show_heart_rate
120+
true, // show_stride_length
121+
true // show_pace_bars
107122
);
108123

109124
// Set file paths
@@ -115,8 +130,14 @@ fn main() -> Result<()> {
115130

116131
// Create and run configuration
117132
let config = RouteVideoConfig::new(
118-
route_scale, colors, pace_dist, lap_data,
119-
file_config, true, true, true
133+
route_scale, // route scale settings
134+
colors, // color configuration
135+
pace_dist, // pace/distance config
136+
lap_data, // lap data panel config
137+
file_config, // file paths
138+
true, // show_bottom_bar
139+
true, // show_route
140+
true // show_lap_data
120141
);
121142

122143
progressive_route_with_config(config)?;
@@ -133,12 +154,17 @@ use runarium::configs::video_config::{FileConfig, RouteColor, RouteScale};
133154
use runarium::generators::route_image::image_route_with_config;
134155

135156
fn main() -> Result<()> {
136-
let route_scale = RouteScale::new(0.2, 0.1, 0.1);
157+
let route_scale = RouteScale::new(
158+
0.2, // scale
159+
0.1, // offset_x_percent
160+
0.1 // offset_y_percent
161+
);
162+
137163
let colors = RouteColor::new(
138-
[0.0, 0.0, 255.0, 0.0],
139-
[0.0, 255.0, 0.0, 0.0],
140-
[255.0, 255.0, 255.0, 0.0],
141-
[0.0, 165.0, 255.0, 0.0],
164+
[0.0, 0.0, 255.0, 0.0], // route_line_color (Red)
165+
[0.0, 255.0, 0.0, 0.0], // current_position_color (Green)
166+
[255.0, 255.0, 255.0, 0.0], // text_color (White)
167+
[0.0, 165.0, 255.0, 0.0] // lap_bars_color (Orange)
142168
);
143169

144170
let file_config = FileConfig::new(
@@ -148,7 +174,10 @@ fn main() -> Result<()> {
148174
);
149175

150176
let config = RouteImageConfig::new(
151-
route_scale, colors, file_config, 2
177+
route_scale, // route scale settings
178+
colors, // color configuration
179+
file_config, // file paths
180+
2 // line_thickness
152181
);
153182

154183
image_route_with_config(config)?;
@@ -194,6 +223,70 @@ Font::Triplex, Font::ComplexSmall, Font::ScriptSimplex,
194223
Font::ScriptComplex, Font::Italic
195224
```
196225

226+
## HTTP Server
227+
228+
Runarium includes an HTTP server for generating videos and images via REST API.
229+
230+
### Running the Server
231+
232+
```bash
233+
# Local development
234+
cargo run --example server --release
235+
236+
# Using Docker
237+
make docker-build
238+
make docker-up
239+
240+
# Using Makefile
241+
make server
242+
```
243+
244+
### API Endpoints
245+
246+
- `POST /generate-video` - Generate animated route video
247+
- `POST /generate-image` - Generate static route image
248+
- `GET /download-video/:video_id` - Download generated video (one-time)
249+
- `GET /download-image/:image_id` - Download generated image (one-time)
250+
- `GET /health` - Health check
251+
252+
### Quick Test
253+
254+
```bash
255+
# Test video generation
256+
make api-test-video
257+
258+
# Test video with custom config
259+
make api-test-video-config
260+
261+
# Test image generation
262+
make api-test-image
263+
264+
# Test image with custom config
265+
make api-test-image-config
266+
```
267+
268+
### Example cURL Request
269+
270+
```bash
271+
# Generate video with custom configuration
272+
curl -X POST http://localhost:3000/generate-video \
273+
-F "fit_file=@source/example.fit" \
274+
-F "background=@source/example.jpg" \
275+
-F 'config={
276+
"scale": 0.3,
277+
"offset_x_percent": 0.15,
278+
"offset_y_percent": 0.15,
279+
"route_line_color": [255.0, 0.0, 0.0, 0.0],
280+
"show_lap_data": true,
281+
"show_pace": true
282+
}'
283+
284+
# Download the video (replace VIDEO_ID with response id)
285+
curl -o output.mp4 http://localhost:3000/download-video/VIDEO_ID
286+
```
287+
288+
See [SERVER.md](SERVER.md) for complete API documentation.
289+
197290
## Examples
198291

199292
Run the included examples:
@@ -304,8 +397,12 @@ runarium/
304397
│ └── read_file.rs # FIT file reading
305398
├── examples/
306399
│ ├── video_config.rs # Video generation example
307-
│ └── image_config.rs # Image generation example
308-
└── CONFIGURATION.md # Detailed configuration guide
400+
│ ├── image_config.rs # Image generation example
401+
│ └── server.rs # HTTP API server
402+
├── CONFIGURATION.md # Detailed configuration guide
403+
├── SERVER.md # HTTP server documentation
404+
├── Dockerfile # Docker container setup
405+
└── docker-compose.yml # Docker orchestration
309406
```
310407

311408
## Troubleshooting
@@ -389,6 +486,8 @@ Built with:
389486
- [x] Customizable color schemes
390487
- [x] Configuration-based API
391488
- [x] Font customization
489+
- [x] HTTP REST API server
490+
- [x] Docker deployment support
392491
- [ ] Support for multiple file formats (GPX, TCX)
393492
- [ ] Command-line interface
394493
- [ ] Preset configuration templates

0 commit comments

Comments
 (0)