From a4679a5a14e57cd49be5649d07df98180758fccb Mon Sep 17 00:00:00 2001 From: Brion Vibber Date: Sun, 4 Dec 2022 15:18:51 -0800 Subject: [PATCH] cleanup --- .gitignore | 5 +++++ Makefile | 6 ++++-- dither-image.js | 5 +++-- gif.sh | 12 ++++++++++++ 4 files changed, 24 insertions(+), 4 deletions(-) create mode 100755 gif.sh diff --git a/.gitignore b/.gitignore index 1f60d20..4988efd 100644 --- a/.gitignore +++ b/.gitignore @@ -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 diff --git a/Makefile b/Makefile index 576d4f3..3789a89 100644 --- a/Makefile +++ b/Makefile @@ -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 diff --git a/dither-image.js b/dither-image.js index 141fa12..86a4be0 100644 --- a/dither-image.js +++ b/dither-image.js @@ -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()); diff --git a/gif.sh b/gif.sh new file mode 100755 index 0000000..6cf2305 --- /dev/null +++ b/gif.sh @@ -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"