This commit is contained in:
Brooke Vibber 2022-12-04 15:18:51 -08:00
parent e460fcefb0
commit a4679a5a14
4 changed files with 24 additions and 4 deletions

5
.gitignore vendored
View file

@ -6,3 +6,8 @@ node_modules
canvas*.png
sample*.s
sample*.s.png
sample*.s.*.png
sample*.s.gif
sample*.s.mp4
chickens.wav
chickens.s

View file

@ -7,6 +7,7 @@ all : sample0.xex sample1.xex sample2.xex sample3.xex sample4.xex sample5.xex sa
%.s : %.jpg dither-image.js
node dither-image.js $< $@
./gif.sh $@
chickens.s : chickens.wav pack-wav.js
node pack-wav.js $< $@
@ -24,8 +25,9 @@ clean :
rm -f sample[0-6].o
rm -f sample[0-6].xex
rm -f sample[0-6].s.png
rm -f sample[0-6].s.0.png
rm -f sample[0-6].s.1.png
rm -f sample[0-6].s.[0-9].png
rm -f sample[0-6].s.palette.png
rm -f sample[0-6].s.gif
rm -f chickens.s
rm -f chickens.o

View file

@ -454,9 +454,10 @@ function decimate(input, palette, n, inputError) {
let double = nextError.divide(shares / 2);
error.cur[x + 1]?.inc(double);
error.cur[x + 2]?.inc(single);
error.next[x - 1]?.inc(double);
error.next[x - 1]?.inc(single);
error.next[x]?.inc(double);
error.next[x + 1]?.inc(single);
error.next[x + 1]?.inc(double);
// 442 is the 3d distance across the rgb cube
//fitness[x] = 442 - (nextError.magnitude());

12
gif.sh Executable file
View file

@ -0,0 +1,12 @@
fps=60000/1001
ffmpeg \
-r $fps -i "$1.%01d.png" \
-vf palettegen \
-y "$1.palette.png" \
&& \
ffmpeg \
-r $fps -i "$1.%01d.png" \
-i "$1.palette.png" \
-lavfi paletteuse \
-y "$1.gif"