%
% Copyright (C) 2008-2001 by Azzeddine LAZREK. All rights reserved.
%
% base.mf
% This file belongs to the CurExt, NasX and AntiSym packages.
%


%
def font_setup =
 define_pixels(u,pp,taille,pas,dimen);
 for i = 0 step 1 until 255 : define_pixels(tuk[i]); endfor
 for i = 0 step 1 until 255 : define_pixels(tup[i]); endfor
%define_blacker_pixels(px,py);
%define_whole_pixels(u,w,h,d);
%define_whole_vertical_pixels(u,w,h,d);
%define_good_x_pixels(u,w,h,d);
%define_good_y_pixels(u,w,h,d);
%define_corrected_pixels(u,w,h,d);
%define_horizontal_corrected_pixels(u,w,h,d);
%pa := pen_angle; pl := px++py; da := pa - angle(px,py);
%pickup pensquare xscaled px yscaled py rotated pa;
%pickup pencircle xscaled px yscaled py rotated pa;
 pickup pensquare scaled .2u#;
 amsquare_pen := savepen;
 pickup pencircle scaled 1u#;
 amcircle_pen := savepen;
 pickup penrazor scaled .2u#;
 amrazor_pen := savepen;
enddef;

%
def ambeginchar(expr code,uw,uh,ud) =
 beginchar(code,uw*u#,uh*u#,ud*u#);
% imagerules;
 change_width;
 pickup amcircle_pen;
% pickup amsquare_pen;
% pickup amrazor_pen;
% if .5w <> good.x .5w: change_width; fi;
enddef;

%
def grille =
 pickup pencircle scaled 2u#;
 z98 = (0u,4u);
 z18 = (1u,4u);
 z28 = (2u,4u);
 z38 = (3u,4u);
 z48 = (4u,4u);
 z93 = (0u,3u);
 z92 = (0u,2u);
 z91 = (0u,1u);
 z90 = (0u,0u);
 z95 = (0u,-1u);
 z96 = (0u,-2u);
 drawdot z98;
 drawdot z18;
 drawdot z28;
 drawdot z38;
 drawdot z48;
 drawdot z93;
 drawdot z92;
 drawdot z91;
 drawdot z90;
 drawdot z95;
 drawdot z96;
 z16 = (1u,-2u);
 z26 = (2u,-2u);
 z36 = (3u,-2u);
 z46 = (4u,-2u);
 z83 = (4u,3u);
 z82 = (4u,2u);
 z81 = (4u,1u);
 z80 = (4u,0u);
 z85 = (4u,-1u);
 drawdot z16;
 drawdot z26;
 drawdot z36;
 drawdot z46;
 drawdot z83;
 drawdot z82;
 drawdot z81;
 drawdot z80;
 drawdot z85;
 penlabels(l,m,r,ll,rr,range 0 thru 99);
 makegrid(0u,0.25u,0.5u,0.75u,1u,1.25u,1.5u,1.75u,2u,2.25u,2.5u,2.75u,3u,3.25u,3.5u,3.75u,4u)
 (-2u,-1.75u,-1.5u,-1.25u,-1u,-0.75u,-0.5u,-0.25u,0u,0.25u,0.5u,0.75u,1u,1.25u,1.5u,1.75u,2u,2.25u,2.5u,2.75u,3u,3.25u,3.5u,3.75u,4u);
enddef;

%
def amendchar =
% grille;
% screenstrokes
 if negatif = true: trait_negatif; fi;
% trace_contour;
% trace_motif;
 endchar;
enddef;

def trait_negatif =
 pickup amsquare_pen;
 filldraw (0,0)--(w,0)--(w,h)--(0,h)--cycle;
 cull currentpicture keeping (1,1);
enddef;

def super_half (suffix i,j,k) =
 draw z.i{0,y.j-y.i} ... (.8[x.j,x.i],.8[y.i,y.j]){z.j-z.i} ...
 z.j{x.k-x.i,0} ... (.8[x.j,x.k],.8[y.k,y.j]){z.k-z.j} ...
 z.k{0,y.k-y.j};
enddef;

def dessin =
% draw
 filldraw
enddef;

def trace_contour =
 cull currentpicture keeping (1,infinity);
 image := currentpicture;
 addto currentpicture also image
 + image shifted 2left
 + image shifted 2right
 + image shifted 2up
 + image shifted 2down;
 cull currentpicture keeping (1,4);
enddef;

def def_motif =
 pickup pensquare scaled taille;
 for i = 0 step pas until dimen :
 draw (i,0)--(i,dimen);
 draw (0,i)--(dimen,i);
 endfor;
 motif := currentpicture;
 cull motif keeping (1,1);
enddef;

def trace_motif =
 cullit;
 addto currentpicture also motif;
 cull currentpicture keeping (2,2);
enddef;
