Add line generation code
This commit is contained in:
parent
26d0e38bec
commit
db78301f80
32
griddle
32
griddle
|
@ -13,6 +13,34 @@ get_image_dimension() {
|
||||||
printf "%s" "$height"
|
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() {
|
main() {
|
||||||
if test "$#" -ne 4; then
|
if test "$#" -ne 4; then
|
||||||
printf "Usage: griddle <inputfile> <columns> <rows> <outputfile>\n"
|
printf "Usage: griddle <inputfile> <columns> <rows> <outputfile>\n"
|
||||||
|
@ -43,7 +71,9 @@ main() {
|
||||||
width="$(get_image_dimension $inputfile $WIDTH)"
|
width="$(get_image_dimension $inputfile $WIDTH)"
|
||||||
height="$(get_image_dimension $inputfile $HEIGHT)"
|
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 "$@"
|
main "$@"
|
||||||
|
|
Loading…
Reference in New Issue