/*

  "Into the deep"

https://www.contextfreeart.org/gallery/view.php?id=4198

by EkB Jun 2020

(CC BY-NC-SA 4.0)

*/

CF::Background = [h 220 b -.9 sat .8] CF::BorderFixed = 30

startshape seaH

shape seaH{

seahorse[r -90 b .8 x .2]
seahorse[flip 135 x -5 y -1 b .4 s .7]
seahorse[r -90  x -1.6 y -2.2  b .2 s .4]
seahorse[flip 135 x -3.7 y -2.5 b .11 s .2]
seahorse[r -90  x -2.5 y -3  b .1 s .06]

}

shape seahorse{

head [s .75 x -.43 y -.83 r 100]
headFin[]
eye [s .2 x -.55 y -.95]
neck  []
body[]
bodyFin[]
tail[]

}

shape head{

loop l = 40 [s 1 x -.05 y -.05] arc[s (0.9/900 * l*(l -60)+1) ]

}

shape eye{

loop m = 3 [s .8 b .5] CIRCLE[]

}

shape headFin{

fin[s .04 r 135 x -.6 y -.45 z  -2 a -.8]

}

shape neck{

neck_p1[r 5]
neck_p2[ ]

}

shape neck_p1{

loop i = 8 [ r 5 a -.2] SQUARE[s 1 .03 x -1 ]

}

shape neck_p2{

loop i = 19 [ r -5] SQUARE[s 1 .03 x -1]

}

shape body{

loop k =40 [x .1 y (-.07*cos(5*k+4)) s 1 ]SQUARE[ s .03 (1-1/500 *k*(k-40)) x .1 y 1]

}

shape bodyFin{

fin[s .06 r 110 x 4 y 1.35 z  -2 a -.95]

}

shape tail{

loop j =160 [x .12 y .4 s .98 r -4 ]SQUARE[ s .03 1 x 4.1 y 1.3]

}

shape fin{

loop i = 9 [ r 4] rayfin[s .8 ]
loop i = 8 [ r -4] rayfin[s .8 r -4]
mfin[  s 44 x -24 y -22]

}

shape rayfin{

SQUARE[ x 9.5]
rayfin[s .98 x .5]

}

path mfin{

MOVETO(0.5 + 0.2*cos(32), 0.5 + 0.2*sin(32))
LINETO(0.5 + 0.5*cos(32), 0.5 + 0.5*sin(32))
ARCTO(0.5 + 0.5*cos(32), 0.5 - 0.5*sin(32),0.5, CF::ArcCW)
LINETO(0.5 + 0.2*cos(32), 0.5 - 0.2*sin(32))
ARCTO(0.5 + 0.2*cos(32), 0.5 + 0.2*sin(32),0.3)
CLOSEPOLY()

}

path arc {

MOVETO(1,0)
ARCTO(0,1,2)
STROKE(.04)[s 1]

}