layout extra_areas
	# C��digos metapost para defini����o de s��mbolos extra
	code metapost

		beginpattern(pattern_mud_crack);
			picture mud_crack_raw;
			mud_crack_raw := image(
				linecap := butt;
				linejoin := mitered;
				pickup pencircle scaled 8bp;
				draw (172.531006,466.222992)--(225.104996,425.453003)--(271.855011,440.605011)
					--(323.921997,390.414001)--(346.839996,423.699005)--(414.757996,363.097992)
					--(390.753998,275.722992)--(414.515991,281.648010)--(438.726990,322.277008);
				pickup pencircle scaled 4bp;
				draw (244.710999,252.141006)--(232.354996,272.496002)--(308.351990,293.101990)
					--(257.156006,310.019989)--(266.289001,357.613007)--(291.085999,380.539001)
					--(303.242004,428.855011)--(282.320007,477.753998)--(393.207001,502.281006)
					--(380.324005,518.754028);
				pickup pencircle scaled 6bp;
				draw (172.531006,466.222992)--(244.710999,518.554993);
				pickup pencircle scaled 8bp;
				draw (173.410004,322.277008)--(205.151993,357.402008)--(244.710999,322.277008)
					--(266.289001,357.613007);
				pickup pencircle scaled 8bp;
				draw (380.324005,252.992004)--(364.523010,292.832001)--(380.324005,322.277008)
					--(346.839996,423.699005)--(417.410004,491.484009)--(393.207001,502.281006);
				pickup pencircle scaled 8bp;
				draw (437.769989,466.222992)--(417.410004,491.484009)--(380.324005,392.070007);
			);
			picture mud_crack;
			mud_crack := mud_crack_raw shifted (-(llcorner mud_crack_raw)-(urcorner mud_crack_raw - llcorner mud_crack_raw)/2) scaled (1.5u / max((xpart urcorner mud_crack_raw) - (xpart llcorner mud_crack_raw), (ypart urcorner mud_crack_raw) - (ypart llcorner mud_crack_raw)));
			draw mud_crack;
		endpattern;

		def a_u_mud_crack (expr Path) =
			T:=identity;
			thclean Path;
			thfill Path withpattern pattern_mud_crack;
		enddef;

		def a_u_stalagmite (expr P) =
			rgbcolor myOrange;
			T := identity;

			myOrange := (1,0.6,0);

			pickup PenA;
			thfill P withcolor myOrange;
		enddef;

		def a_u_stalactite_stalagmite (expr P) =
			rgbcolor myOrange, myLightOrange;

			picture tmpPicFill, tmpPicDraw;
			path bboxP, clipFill, clipDraw;

			T := identity;

			myLightOrange := (1,0.9,0.67);
			myOrange := (1,0.6,0);
			bboxP := bbox P;
			clipFill := ulcorner bboxP -- llcorner bboxP -- lrcorner bboxP -- cycle;
			clipDraw := ulcorner bboxP -- urcorner bboxP -- lrcorner bboxP -- cycle;

			pickup PenA;
			thclean P;

			tmpPicFill := image(
				fill P withcolor myOrange;
				draw P withcolor myOrange;
			);
			clip tmpPicFill to clipFill;
			drawoptions();
			draw tmpPicFill;

			tmpPicDraw := image(
				fill P withcolor myLightOrange;
				draw P withcolor myOrange;
			);
			clip tmpPicDraw to clipDraw;
			drawoptions();
			draw tmpPicDraw;
		enddef;

		def a_u_stalactite (expr P) =
			rgbcolor myOrange, myLightOrange;
			T := identity;

			myLightOrange := (1,0.9,0.67);
			myOrange := (1,0.6,0);

			pickup PenD;
			thfill P withcolor myLightOrange;
			thdraw P withcolor myOrange;
		enddef;

		def a_u_pillar_main (expr P) =
			rgbcolor myOrange;
			pair d[], p[];

			T := identity;

			myOrange := (1,0.6,0);

			pickup PenD;
			thfill P withcolor myOrange;

			cursor := 0;
			totalLength := arclength P;
			elementSize := adjust_step(totalLength, 0.01u); % symbol length nudged to be multiple of path length
			borderWidth := 0.3u;

			pickup PenA;
			forever:
				t1 := arctime (cursor + elementSize / 2) of P;

				p1 := point t1 of P;

				d1 := unitvector(thdir(P,t1)) * borderWidth;

				thdraw p1 -- p1 + (d1 rotated 90) withcolor white;;

				cursor := cursor + elementSize;
				exitif cursor > totalLength - (elementSize / 2);
			endfor;

			pickup PenD;
			thdraw P withcolor myOrange;
		enddef;

		def a_u_pillar (expr P) =
			picture myPillar;

			myPillar := image(a_u_pillar_main(P));

			thdraw myPillar;
		enddef;

		def a_u_pillar_with_curtains (expr P) =
			picture myPillar;
			path myCurtain;

			myPillar := image(a_u_pillar_main(P));

			thdraw myPillar;

			myCurtain := (0,-.4u){dir 180}..(-0.1u,-0.3u)..{dir 0}(0,-0.2u)..(0.1u,-0.1u)..{dir -180}(0,0);
			myCurtain := myCurtain scaled (0.2 / 0.4);
			cursor := 0;
			totalLength := arclength P;
			elementSize := adjust_step(totalLength, 0.5u); % symbol length nudged to be multiple of path length

			pickup PenD;
			forever:
				t1 := arctime (cursor + elementSize / 2) of P;

				thdraw myCurtain rotated (180+angle(thdir(P,t1))) shifted (point t1 of P) withcolor (1,0.6,0);

				cursor := cursor + elementSize;
				exitif cursor > totalLength - (elementSize / 3);
			endfor;
		enddef;

	endcode

	endcode
	
endlayout

text en "area u:mud_crack" "cracked mud"
text pt "area u:mud_crack" "lama rachada"

text en "area u:stalagmite" "stalagmite"
text pt "area u:stalagmite" "estalagmite"

text en "area u:stalactite_stalagmite" "stalactite and stalagmite"
text pt "area u:stalactite_stalagmite" "estalactite e estalagmite"

text en "area u:stalactite" "stalactite"
text pt "area u:stalactite" "estalactite"

text en "area u:pillar" "pillar"
text pt "area u:pillar" "coluna"

text en "area u:pillar_with_curtains" "pillar with curtains"
text pt "area u:pillar_with_curtains" "coluna com reposteiro"
