#!/bin/bash # Constants # SEED=20230920 SEED=0 # INPUT_FILE="${DIR}/arrangement_$SEED.txt" DIR=/teamspace/studios/this_studio/out_sortcolors INPUT_FILE="${DIR}/arrangement_grid.txt" # OUTPUT_IMAGE="${DIR}/circle_composite_$SEED.png" TYPE=circle OUTPUT_IMAGE="${DIR}/${TYPE}_composite_grid.png" DPI=150 CANVAS_SIZE=$((72*$DPI)) # 72 inches CIRCLE_IMAGE="${DIR}/hsv/sorted_colors_circle.png" KIND=umap identify $CIRCLE_IMAGE # PREP echo "Building ops" # Build the composite operations string composite_ops="" idx=1 while IFS=, read -r x y; do # Translate so that (0,0) becomes the center of the canvas fx=$(echo "$x*$DPI + $CANVAS_SIZE/2" | bc -l) fy=$(echo "$CANVAS_SIZE/2 - $y*$DPI" | bc -l) # Convert the final float values to integers ix=$(printf "%.0f" "$fx") iy=$(printf "%.0f" "$fy") if [[ idx -eq 42 ]]; then CIRCLE_IMAGE="${DIR}/hsv/sorted_colors_${TYPE}.png" else idx_str=$(printf "%04d" "$idx") CIRCLE_IMAGE="${DIR}/${KIND}/${idx_str}_sorted_colors_${TYPE}.png" # CIRCLE_IMAGE="${DIR}/hsv_sorted_colors_${TYPE}.png" fi # Add to the composite operations string composite_ops="$composite_ops \( $CIRCLE_IMAGE \) -resize 50% -compose Over -geometry +$ix+$iy -composite" idx=$((idx+1)) done < $INPUT_FILE # COMPOSITE echo "Compositing" # Use convert with the built composite operations string eval "convert -units PixelsPerInch \ -size ${CANVAS_SIZE}x${CANVAS_SIZE} xc:white \ $composite_ops \ -density $DPI \ $OUTPUT_IMAGE" echo "Saved $OUTPUT_IMAGE" # DEBUG # eval "convert -units PixelsPerInch \ # $OUTPUT_IMAGE \ # \( ${DIR}/arrangement_$SEED.png -evaluate Multiply 0.5 \) \ # -gravity center -composite \ # -density $DPI \ # /tmp/debug.png" # open /tmp/debug.png