aesthetics-of-the-commons
clone your own copy | download snapshot

Snapshots | iceberg

No images in this repository’s iceberg at this time

Inside this repository

def.mp
text/x-python

Download raw (2.7 KB)

input ../global;

height = 35;
baseline := 0;
xHeight := 14;
ascHeight := 21;
descHeight := -7;
capHeight := 21;
overAsc := ascHeight + 2;


srf_R = srf_W / 2;
srf_L = - (srf_W / 2);

ox = ux;
oy = uy;

% OverShots Values
% under Baseline
os_bsln = - .3uy;
os_x = .3uy;

def beginchar(expr keycode, width)=
	beginfig(keycode);
		pickup pencircle scaled .2;

		draw (0 * ux, (descHeight - 2) * uy) -- 
			(width * ux, (descHeight - 2) * uy) --
			(width * ux, (ascHeight + 2) * uy) -- 
			(0 * ux, (ascHeight + 2) * uy) -- 
			cycle scaled 0 withcolor red;



		if grid = 1:
			defaultscale := .2;
			for i=0 upto width:
				draw (i*ux, overAsc*uy) -- (i*ux, descHeight*uy) withcolor .3white;
			endfor;
			for i=-9 upto (overAsc):
				draw (width*ux, i*uy) -- (0*ux, i*uy) withcolor .3white;
			endfor;
		fi;
		pickup pencircle scaled 1;

		if hints = 1:
			draw (0 * ux, (xHeight * uy) + os_x) -- (width * ux, (xHeight * uy) + os_x)  withcolor green;
			draw (0 * ux, xHeight * uy) -- (width * ux, xHeight * uy)  withcolor (green + blue);
			draw (0 * ux, capHeight * uy) -- (width * ux, capHeight * uy)  withcolor (green + blue);
			draw (0 * ux, ascHeight * uy) -- (width * ux, ascHeight * uy)  withcolor (green + blue);
			draw (0 * ux, descHeight * uy) -- (width * ux, descHeight * uy)  withcolor (green + blue);
			draw (0 * ux, baseline * uy) -- (width * ux, baseline * uy)  withcolor green;
		fi;
		% linejoin := beveled;
		% linecap := rounded;
		pickup pencircle xscaled sx yscaled sy rotated rot;


	enddef;

	def endchar(expr lenDots)=
	if dot_label = 1:
		defaultscale := 1;
		for i=1 upto lenDots:
			dotlabels.urt([i]) withcolor magenta;
		endfor;
	fi;
endfig;
enddef;

def serifOff(expr x_start, x_end)(suffix posi)=
	draw (x_start, posi srf_H) --
		(x_start + srf_L, posi 0 ) -- 
		(x_end + srf_R , posi 0 ) -- 
		(x_end, posi srf_H);
enddef;

def \. =
	..
enddef;

% serif()
def serif(suffix i,j,k,l, position, model) =

	path p, q, r;
	if position = 0:
		p := (0, srf_H) -- (100ux, srf_H);
		% draw p withcolor red;
	elseif position = 1:
		p := (0, (xHeight*uy - srf_H)) -- (100ux, (xHeight*uy) - srf_H);
		% draw p  withcolor red;
	elseif position = 2:
		p := (0, (ascHeight*uy - srf_H)) -- (100ux, (ascHeight*uy) - srf_H);

	elseif position = 3:  
		p := (0, (descHeight*uy + srf_H)) -- (100ux, (descHeight*uy) + srf_H);
	fi;


	q := z.i -- z.j;
	r := z.k -- z.l;
	pair Pstart, Pstop;
	Pstart := p intersectionpoint q;
	Pstop := p intersectionpoint r;

	if model = 1:

		draw Pstart -- 
			if position = 0:
				(x.j - srf_L, y.j) --  z.l;
	else:
		(x.j + srf_L, y.j) --  z.l;
	fi;

else:
	draw Pstart --
		(x.j + srf_L, y.j  ){left} --
		(x.l + srf_R , y.j){right} --
		Pstop;
fi;


enddef;