Created
March 9, 2017 15:48
-
-
Save marcpeabody/8c7a9ad233a22aec523859a1fcd6da9e to your computer and use it in GitHub Desktop.
imagemagick scripts for generating gifs that resemble drawing circles or ovals
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function adjust1() { | |
ran=$(od -An -N4 -i < /dev/urandom) | |
echo `adjust $1 1` | |
} | |
function adjust2() { | |
ran=$(od -An -N4 -i < /dev/urandom) | |
echo `adjust $1 2` | |
} | |
function adjust() { | |
ran=$(od -An -N4 -i < /dev/urandom) | |
echo $(($1 + $(($ran%$(($2+1)))))) | |
} | |
function circles() { | |
for i in 1 2 3 4 5 | |
do | |
arc1=$(adjust1 26),$(adjust1 26) | |
arc2=$(adjust1 26),$(adjust1 26) | |
arc3=$(adjust1 26),$(adjust1 26) | |
arc4=$(adjust1 26),$(adjust1 26) | |
point0=$(adjust 13 4),$(adjust2 6) | |
point1=$(adjust 26 2),$(adjust2 6) | |
point2=$(adjust2 50),$(adjust2 26) | |
point3=$(adjust2 26),$(adjust2 50) | |
point4=$(adjust2 2),$(adjust2 26) | |
point5=$(adjust 28 10),$(adjust2 2) | |
convert -size 54x54 xc:none -fill none -stroke black +antialias -gravity North -strokewidth 2\ | |
-draw "path 'M ${point0} L ${point1} '" \ | |
path_circlex0.gif | |
convert -size 54x54 xc:none -fill none -stroke black +antialias -gravity North -strokewidth 2\ | |
-draw "path 'M ${point0} L ${point1} '" \ | |
-draw "path 'M ${point1} A ${arc1} 0 0,1 ${point2} '" \ | |
path_circlex1.gif | |
convert -size 54x54 xc:none -fill none -stroke black +antialias -gravity North -strokewidth 2\ | |
-draw "path 'M ${point0} L ${point1} '" \ | |
-draw "path 'M ${point1} A ${arc1} 0 0,1 ${point2} '" \ | |
-draw "path 'M ${point2} A ${arc2} 0 0,1 ${point3} '" \ | |
path_circlex2.gif | |
convert -size 54x54 xc:none -fill none -stroke black +antialias -gravity North -strokewidth 2\ | |
-draw "path 'M ${point0} L ${point1} '" \ | |
-draw "path 'M ${point1} A ${arc1} 0 0,1 ${point2} '" \ | |
-draw "path 'M ${point2} A ${arc2} 0 0,1 ${point3} '" \ | |
-draw "path 'M ${point3} A ${arc3} 0 0,1 ${point4} '" \ | |
path_circlex3.gif | |
convert -size 54x54 xc:none -fill none -stroke black +antialias -gravity North -strokewidth 2\ | |
-draw "path 'M ${point0} L ${point1} '" \ | |
-draw "path 'M ${point1} A ${arc1} 0 0,1 ${point2} '" \ | |
-draw "path 'M ${point2} A ${arc2} 0 0,1 ${point3} '" \ | |
-draw "path 'M ${point3} A ${arc3} 0 0,1 ${point4} '" \ | |
-draw "path 'M ${point4} A ${arc4} 0 0,1 ${point5} '" \ | |
path_circlex4.gif | |
convert path_circlex0.gif path_circlex1.gif path_circlex2.gif path_circlex3.gif path_circlex4.gif "path_circle${i}.gif" | |
rm path_circlex* | |
done | |
} | |
function ovalsX() { | |
for i in 1 2 3 4 5 | |
do | |
size=108x54 | |
arc1=$(adjust1 54),$(adjust1 24) | |
arc2=$(adjust1 54),$(adjust1 28) | |
arc3=$(adjust1 54),$(adjust1 24) | |
arc4=$(adjust1 54),$(adjust1 28) | |
point0=$(adjust 36 4),$(adjust1 6) | |
point1=$(adjust2 54),$(adjust2 6) | |
point2=$(adjust2 104),$(adjust2 26) | |
point3=$(adjust2 54),$(adjust2 51) | |
point4=$(adjust2 4),$(adjust2 26) | |
point5=$(adjust 57 10),$(adjust2 4) | |
convert -size ${size} xc:none -fill none -stroke black +antialias -gravity North -strokewidth 2\ | |
-draw "path 'M ${point0} L ${point1} '" \ | |
path_ovalsx0.gif | |
convert -size ${size} xc:none -fill none -stroke black +antialias -gravity North -strokewidth 2\ | |
-draw "path 'M ${point0} L ${point1} '" \ | |
-draw "path 'M ${point1} A ${arc1} 0 0,1 ${point2} '" \ | |
path_ovalsx1.gif | |
convert -size ${size} xc:none -fill none -stroke black +antialias -gravity North -strokewidth 2\ | |
-draw "path 'M ${point0} L ${point1} '" \ | |
-draw "path 'M ${point1} A ${arc1} 0 0,1 ${point2} '" \ | |
-draw "path 'M ${point2} A ${arc2} 0 0,1 ${point3} '" \ | |
path_ovalsx2.gif | |
convert -size ${size} xc:none -fill none -stroke black +antialias -gravity North -strokewidth 2\ | |
-draw "path 'M ${point0} L ${point1} '" \ | |
-draw "path 'M ${point1} A ${arc1} 0 0,1 ${point2} '" \ | |
-draw "path 'M ${point2} A ${arc2} 0 0,1 ${point3} '" \ | |
-draw "path 'M ${point3} A ${arc3} 0 0,1 ${point4} '" \ | |
path_ovalsx3.gif | |
convert -size ${size} xc:none -fill none -stroke black +antialias -gravity North -strokewidth 2\ | |
-draw "path 'M ${point0} L ${point1} '" \ | |
-draw "path 'M ${point1} A ${arc1} 0 0,1 ${point2} '" \ | |
-draw "path 'M ${point2} A ${arc2} 0 0,1 ${point3} '" \ | |
-draw "path 'M ${point3} A ${arc3} 0 0,1 ${point4} '" \ | |
-draw "path 'M ${point4} A ${arc4} 0 0,1 ${point5} '" \ | |
path_ovalsx4.gif | |
convert path_ovalsx0.gif path_ovalsx1.gif path_ovalsx2.gif path_ovalsx3.gif path_ovalsx4.gif "path_oval${i}.gif" | |
rm path_ovalsx* | |
done | |
} | |
function testOval() { | |
convert -size 300x100 xc:none -fill yellow -stroke black +antialias -gravity North -strokewidth 2\ | |
-draw "path 'M 150,4 A $1 $2 0,1 280,50 '" \ | |
-draw "path 'M 280,50 A $1 $2 0,1 150,98 '" \ | |
test_oval_arc.gif | |
} | |
function ovals() { #108x54 | |
for i in 1 2 3 4 5 | |
do | |
size=80x42 | |
arc1=$(adjust1 44),$(adjust1 17) | |
arc2=$(adjust1 44),$(adjust1 17) | |
arc3=$(adjust1 44),$(adjust1 17) | |
arc4=$(adjust1 44),$(adjust1 17) | |
point0=$(adjust 32 4),$(adjust1 6) | |
point1=$(adjust2 40),$(adjust2 6) | |
point2=$(adjust2 76),$(adjust2 22) | |
point3=$(adjust2 40),$(adjust2 38) | |
point4=$(adjust2 4),$(adjust2 20) | |
point5=$(adjust 42 10),$(adjust2 4) | |
convert -size ${size} xc:none -fill none -stroke black +antialias -gravity North -strokewidth 2\ | |
-draw "path 'M ${point0} L ${point1} '" \ | |
path_ovalsx0.gif | |
convert -size ${size} xc:none -fill none -stroke black +antialias -gravity North -strokewidth 2\ | |
-draw "path 'M ${point0} L ${point1} '" \ | |
-draw "path 'M ${point1} A ${arc1} 0 0,1 ${point2} '" \ | |
path_ovalsx1.gif | |
convert -size ${size} xc:none -fill none -stroke black +antialias -gravity North -strokewidth 2\ | |
-draw "path 'M ${point0} L ${point1} '" \ | |
-draw "path 'M ${point1} A ${arc1} 0 0,1 ${point2} '" \ | |
-draw "path 'M ${point2} A ${arc2} 0 0,1 ${point3} '" \ | |
path_ovalsx2.gif | |
convert -size ${size} xc:none -fill none -stroke black +antialias -gravity North -strokewidth 2\ | |
-draw "path 'M ${point0} L ${point1} '" \ | |
-draw "path 'M ${point1} A ${arc1} 0 0,1 ${point2} '" \ | |
-draw "path 'M ${point2} A ${arc2} 0 0,1 ${point3} '" \ | |
-draw "path 'M ${point3} A ${arc3} 0 0,1 ${point4} '" \ | |
path_ovalsx3.gif | |
convert -size ${size} xc:none -fill none -stroke black +antialias -gravity North -strokewidth 2\ | |
-draw "path 'M ${point0} L ${point1} '" \ | |
-draw "path 'M ${point1} A ${arc1} 0 0,1 ${point2} '" \ | |
-draw "path 'M ${point2} A ${arc2} 0 0,1 ${point3} '" \ | |
-draw "path 'M ${point3} A ${arc3} 0 0,1 ${point4} '" \ | |
-draw "path 'M ${point4} A ${arc4} 0 0,1 ${point5} '" \ | |
path_ovalsx4.gif | |
convert path_ovalsx0.gif path_ovalsx1.gif path_ovalsx2.gif path_ovalsx3.gif path_ovalsx4.gif "path_oval${i}.gif" | |
rm path_ovalsx* | |
done | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment