Skip to content

Commit bc2cac5

Browse files
Merge pull request #1 from Robot-Wranglers/mainline
clean; refactor; docs/demos; support and document different kinds of …
2 parents ceba5ba + 6c1cc89 commit bc2cac5

22 files changed

Lines changed: 334 additions & 111 deletions

.github/workflows/docker-build.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,4 +14,4 @@ jobs:
1414
steps:
1515
- uses: actions/checkout@v3
1616
- name: Build
17-
run: make clean buiild test
17+
run: make clean build test

Makefile

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,23 @@ init:
2323
build: docker.build
2424
clean: docker.clean py-clean
2525

26-
docs:
26+
docs: docs.vhs docs.jinja #docs.rotations
27+
docs.jinja:
2728
${pynchon.run} jinja render README.md.j2
28-
PS1="$$ " sh -c "${pynchon.run} vhs apply"
29-
29+
python demo.py img/icon.png --stream > img/demo.gif
30+
docs.vhs:; PS1="$$ " sh -c "${pynchon.run} vhs apply"
31+
docs.rotations:
32+
python demo.py img/graph.png --bg lightblue --rotation x --stream > img/rx.gif
33+
python demo.py img/graph.png --bg lightblue --rotation y --stream > img/ry.gif
34+
python demo.py img/graph.png --bg lightblue --rotation s --stream > img/rs.gif
35+
python demo.py img/graph.png --bg lightblue --rotation j --stream > img/rj.gif
36+
python demo.py img/graph.png --bg lightblue --rotation w --stream > img/rw.gif
37+
python demo.py img/graph.png --bg lightblue --rotation f --stream > img/rf.gif
38+
python demo.py img/graph.png --bg lightblue --rotation exit-ul --stream > img/rul.gif
39+
python demo.py img/graph.png --bg lightblue --rotation exit-ur --stream > img/rur.gif
40+
python demo.py img/graph.png --bg lightblue --rotation exit-lr --stream > img/rlr.gif
41+
python demo.py img/graph.png --bg lightblue --rotation exit-ll --stream > img/rll.gif
42+
3043

3144
docker.clean:
3245
docker rmi $(DOCKER_IMAGE_NAME) >/dev/null || true

README.md

Lines changed: 84 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -51,39 +51,110 @@ pip install -r requirements.txt
5151
Usage: demo.py [OPTIONS] IMG_PATH
5252

5353
Options:
54-
--range TEXT Range to rotate through
55-
--stream / --no-stream Stream output in raw format (for use with pipes).
56-
Implies --animate
57-
--display / --no-display Display output with chafa
58-
--view / --no-view View a file with chafa (don't generate anything)
59-
--output-dir TEXT Output directory for frames
60-
--output-file TEXT Output file for animated gif
61-
--img-shape TEXT Ideal image shape in WxH format (optional)
62-
--help Show this message and exit.
54+
--bg TEXT Background color to pass to chafa
55+
--display Display output with chafa
56+
--invert Pass --invert to chafa
57+
--img-shape TEXT Ideal image shape in WxH format (optional)
58+
--duration TEXT Duration argument to pass to chafa
59+
--output-dir TEXT Output directory for frames
60+
--output-file TEXT Output file for animated gif
61+
--range TEXT Range to rotate through
62+
--stream / --no-stream Stream output in raw format (for use with pipes).
63+
Implies --animate
64+
--verbose Whether or not ffmpeg-stderr is displayed
65+
--view View a file with chafa (generates nothing)
66+
--rotation TEXT One of { x | y | yz }
67+
--speed TEXT Speed factor to pass to ffmpeg (default=.08)
68+
--stretch Whether to pass --stretch to chafa
69+
--help Show this message and exit.
6370

6471
```
6572
73+
You can also set `LOGLEVEL=debug` for more info.
74+
6675
-------------------------------------
6776
6877
## Usage from Docker
6978
70-
**A few examples of usage from docker:**
79+
A few examples of usage from docker:
80+
81+
**Saving an animated gif to a file:**
7182
7283
```bash
73-
# Saves the animated gif to a file.
7484
$ docker run -it --rm -v `pwd`:/workspace -w /workspace robotwranglers/imgrot img/icon.png --range 360 --img-shape 200x200 --stream > demo.gif
7585
```
7686
7787
<p align=center>
7888
<img width=25% align=center src=img/demo.gif>
7989
</p>
8090
91+
**Rendering a gif, then displaying it in a terminal-friendly way with chafa:**
92+
8193
```bash
82-
# Renders a gif from a static image, then displays it in a terminal-friendly way with chafa
83-
$ docker run -it --rm -v `pwd`:/workspace -w /workspace robotwranglers/imgrot img/icon.png --range 360 --img-shape 200x200 --display
94+
$ docker run -it --rm -v `pwd`:/workspace -w /workspace robotwranglers/imgrot img/icon.png --display --stretch --bg lightblue
8495
```
8596
8697
<p align=center>
8798
<img width=50% align=center src=img/demo.chafa.gif>
8899
</p>
89100
101+
Note that this tries to respect transparency in the original image, but for more contrast you can effectively add highlights by passing '--bg' arguments that go through to chafa.
102+
103+
------------------------------
104+
105+
**Changing axis of rotation**
106+
107+
The rotation can be controlled to create a bunch of different effects:
108+
109+
```bash
110+
$ docker run -it --rm -v `pwd`:/workspace \
111+
-w /workspace robotwranglers/imgrot \
112+
img/icon.png \
113+
--display --stretch \
114+
--bg darkgreen \
115+
--rotation <some-rotation here>
116+
```
117+
118+
<p align=center>
119+
<table>
120+
<tr>
121+
<th>x</th>
122+
<th>y</th>
123+
<th>s,swivel</th>
124+
</tr>
125+
<tr>
126+
<td>
127+
<img src=img/rx.gif></td>
128+
<td>
129+
<img src=img/ry.gif>
130+
</td>
131+
<td><img src=img/rs.gif></td>
132+
</tr>
133+
<tr>
134+
<th>j,jitter</th>
135+
<th>w,wobble</th>
136+
<th>f,flip</th>
137+
</tr>
138+
<tr>
139+
<td>
140+
<img src=img/rj.gif></td>
141+
<td>
142+
<img src=img/rw.gif>
143+
</td>
144+
<td><img src=img/rf.gif></td>
145+
</tr>
146+
<tr>
147+
<th>exit-ul</th>
148+
<th>exit-ur</th>
149+
<th>exit-lr</th>
150+
</tr>
151+
<tr>
152+
<td>
153+
<img src=img/rul.gif></td>
154+
<td>
155+
<img src=img/rur.gif>
156+
</td>
157+
<td><img src=img/rlr.gif></td>
158+
</tr>
159+
</table>
160+
</p>

README.md.j2

Lines changed: 68 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -51,27 +51,91 @@ pip install -r requirements.txt
5151
{{bash('python demo.py --help')}}
5252
```
5353

54+
You can also set `LOGLEVEL=debug` for more info.
55+
5456
-------------------------------------
5557

5658
## Usage from Docker
5759

58-
**A few examples of usage from docker:**
60+
A few examples of usage from docker:
61+
62+
**Saving an animated gif to a file:**
5963

6064
```bash
61-
# Saves the animated gif to a file.
6265
$ docker run -it --rm -v `pwd`:/workspace -w /workspace robotwranglers/imgrot img/icon.png --range 360 --img-shape 200x200 --stream > demo.gif
6366
```
6467

6568
<p align=center>
6669
<img width=25% align=center src=img/demo.gif>
6770
</p>
6871

72+
**Rendering a gif, then displaying it in a terminal-friendly way with chafa:**
73+
6974
```bash
70-
# Renders a gif from a static image, then displays it in a terminal-friendly way with chafa
71-
$ docker run -it --rm -v `pwd`:/workspace -w /workspace robotwranglers/imgrot img/icon.png --range 360 --img-shape 200x200 --display
75+
$ docker run -it --rm -v `pwd`:/workspace -w /workspace robotwranglers/imgrot img/icon.png --display --stretch --bg lightblue
7276
```
7377

7478
<p align=center>
7579
<img width=50% align=center src=img/demo.chafa.gif>
7680
</p>
7781

82+
Note that this tries to respect transparency in the original image, but for more contrast you can effectively add highlights by passing '--bg' arguments that go through to chafa.
83+
84+
------------------------------
85+
86+
**Changing axis of rotation**
87+
88+
The rotation can be controlled to create a bunch of different effects:
89+
90+
```bash
91+
$ docker run -it --rm -v `pwd`:/workspace \
92+
-w /workspace robotwranglers/imgrot \
93+
img/icon.png \
94+
--display --stretch \
95+
--bg darkgreen \
96+
--rotation <some-rotation here>
97+
```
98+
99+
<p align=center>
100+
<table>
101+
<tr>
102+
<th>x</th>
103+
<th>y</th>
104+
<th>s,swivel</th>
105+
</tr>
106+
<tr>
107+
<td>
108+
<img src=img/rx.gif></td>
109+
<td>
110+
<img src=img/ry.gif>
111+
</td>
112+
<td><img src=img/rs.gif></td>
113+
</tr>
114+
<tr>
115+
<th>j,jitter</th>
116+
<th>w,wobble</th>
117+
<th>f,flip</th>
118+
</tr>
119+
<tr>
120+
<td>
121+
<img src=img/rj.gif></td>
122+
<td>
123+
<img src=img/rw.gif>
124+
</td>
125+
<td><img src=img/rf.gif></td>
126+
</tr>
127+
<tr>
128+
<th>exit-ul</th>
129+
<th>exit-ur</th>
130+
<th>exit-lr</th>
131+
</tr>
132+
<tr>
133+
<td>
134+
<img src=img/rul.gif></td>
135+
<td>
136+
<img src=img/rur.gif>
137+
</td>
138+
<td><img src=img/rlr.gif></td>
139+
</tr>
140+
</table>
141+
</p>

0 commit comments

Comments
 (0)