Add line generation code

This commit is contained in:
The Magician 2024-03-15 14:56:50 +00:00
parent 26d0e38bec
commit db78301f80
1 changed files with 31 additions and 1 deletions

32
griddle
View File

@ -13,6 +13,34 @@ get_image_dimension() {
printf "%s" "$height"
}
generate_lines() {
columns="$1"
rows="$2"
width="$3"
height="$4"
#colwidth=$((width / columns))
#for i in $(seq 0 $columns); do
#current_colwidth=$((colwidth * i))
#printf "line 0, %d %d, %d " $current_colwidth $height $current_colwidth
#done
rowheight=$((height / rows))
for i in $(seq 0 $rows); do
current_rowheight=$((rowheight * i))
printf "line 0, %d %d, %d " $current_rowheight $width $current_rowheight
done
}
create_image() {
inputfile="$1"
lines="$2"
outputfile="$3"
convert -draw "$lines" "$inputfile" "$outputfile"
}
main() {
if test "$#" -ne 4; then
printf "Usage: griddle <inputfile> <columns> <rows> <outputfile>\n"
@ -43,7 +71,9 @@ main() {
width="$(get_image_dimension $inputfile $WIDTH)"
height="$(get_image_dimension $inputfile $HEIGHT)"
echo "$inputfile" "columns: $columns" "rows: $rows" "$outputfile" "Dimensions: $width x $height"
lines="$(generate_lines $columns $rows $width $height)"
create_image "$inputfile" "$lines" "$outputfile"
}
main "$@"