animation/cmy/combine.sh

41 lines
1.2 KiB
Bash

#!/bin/bash
FILEPATH=`realpath "${1}"`
DIR=`dirname "${FILEPATH}"`
FILENAME=`basename "${FILEPATH}"`
NAME=`echo "${FILENAME}" | cut -d'.' -f1`
EXTENSION="png"
CHANNELS=("c" "m" "y")
OUTPUT="${DIR}/${NAME}_cmy.${EXTENSION}"
CYAN="${DIR}/${NAME}_c.${EXTENSION}.rendered.${EXTENSION}"
MAGENTA="${DIR}/${NAME}_m.${EXTENSION}.rendered.${EXTENSION}"
YELLOW="${DIR}/${NAME}_y.${EXTENSION}.rendered.${EXTENSION}"
WIDTH=404
HEIGHT=374
convert -size "${WIDTH}x${HEIGHT}" xc:rgb\(0,255,255\) cyan.png
convert -size "${WIDTH}x${HEIGHT}" xc:rgb\(255,0,255\) magenta.png
convert -size "${WIDTH}x${HEIGHT}" xc:rgb\(255,255,0\) yellow.png
composite -colorspace RGB -compose screen "${CYAN}" cyan.png cyan_comp.png
composite -colorspace RGB -compose screen "${MAGENTA}" magenta.png magenta_comp.png
composite -colorspace RGB -compose screen "${YELLOW}" yellow.png yellow_comp.png
composite -colorspace RGB -compose multiply yellow_comp.png cyan_comp.png 1.png
composite -colorspace RGB -compose multiply 1.png magenta_comp.png "${OUTPUT}"
rm cyan.png
rm magenta.png
rm yellow.png
#rm cyan_comp.png
#rm magenta_comp.png
#rm yellow_comp.png
#rm 1.png
mogrify -negate "${OUTPUT}"
open "${OUTPUT}"