-- JaMFontDesignImpl.mesa
-- Mesa 6 version
-- Last changed by John Warnock September 17, 1980 2:33 PM

DIRECTORY
JaMGraphicsDefs,
BuildSpline,
BuildLine,
Graphics,
Vector USING [Vec],
Cubic USING [Coeffs],
JaMFnsDefs USING [GetReal,Register];

JaMFontDesignImpl: PROGRAM
IMPORTS JaMFnsDefs,JaMGraphicsDefs,Graphics,BuildSpline,BuildLine =
{OPEN JaMFnsDefs,Graphics,BuildSpline,BuildLine;

Vec: TYPE = Vector.Vec;
Coeffs: TYPE = Cubic.Coeffs;

dc: DisplayContext←NIL;


Point: TYPE = Graphics.Vec;

GetPoint: PROCEDURE[p: POINTER TO Point] = {
p.y ← GetReal[];
p.x ← GetReal[];
};



JStartSpline: PROCEDURE =
{dc:DisplayContext←JaMGraphicsDefs.GetDC[];
StartSpline[];};

JEnterSPoint: PROCEDURE = {
p:Vec;
GetPoint[@p];
EnterKnot[p.x,p.y];
};


JEnterSPointSlope: PROCEDURE = {
p,s: Point;
GetPoint[@s];
GetPoint[@p];
EnterKnotSlope[p.x,p.y,s.x,s.y];
};



JEnterSplineArea: PROCEDURE = {
ec:PROCEDURE[cb:Coeffs]=
{IF first THEN {first←FALSE; EnterPoint[dc,cb.c0];};
EnterCubic[dc,@cb]};
first:BOOLEAN←TRUE;
dc:DisplayContext←JaMGraphicsDefs.GetDC[];
BuildSpline[ec];
};

JEnterCyclicSplineArea: PROCEDURE = {
ec:PROCEDURE[cb:Coeffs]=
{EnterCubic[dc,@cb]};
dc:DisplayContext←JaMGraphicsDefs.GetDC[];
BuildCyclicSpline[ec];
};

JStartLine:PROCEDURE={
dc:DisplayContext←JaMGraphicsDefs.GetDC[];
StartLine[];
};

JEnterLinePoint:PROCEDURE={
p:Vec;
GetPoint[@p];
EnterLineKnot[p.x,p.y];
};

JEnterLinePointSlope:PROCEDURE={
p,s: Point;
GetPoint[@s];
GetPoint[@p];
EnterLineKnotSlope[p.x,p.y,s.x,s.y];
};

JEnterLineArea:PROCEDURE={
ec:PROCEDURE[cb:Coeffs]=
{IF first THEN {first←FALSE; EnterPoint[dc,cb.c0];};
EnterCubic[dc,@cb]};
first:BOOLEAN←TRUE;
dc:DisplayContext←JaMGraphicsDefs.GetDC[];
width:REAL←GetReal[];
BuildLine[width,ec];
};



Register[".startspline"L,JStartSpline];
Register[".enterspoint"L,JEnterSPoint];
Register[".enterspointslope"L,JEnterSPointSlope];
Register[".entersplinearea"L,JEnterSplineArea];
Register[".entercsplinearea"L,JEnterCyclicSplineArea];
Register[".startline"L,JStartLine];
Register[".enterlinepoint"L,JEnterLinePoint];
Register[".enterlinepointslope"L,JEnterLinePointSlope];
Register[".enterlinearea"L,JEnterLineArea];
}.