-- TAPenImpl.mesa
-- Rick Beach, June 27, 1982 12:29 pm

DIRECTORY
 NodeStyle USING [Ref],
 TAPen,
 TAPrivate,
 TAStyle;

TAPenImpl: PROGRAM
 IMPORTS TAPrivate, TAStyle
 EXPORTS TAPen = {
 OPEN TAPen;

EstablishPen: PUBLIC PROCEDURE[nodeStyle: NodeStyle.Ref] = {
 SELECT TAStyle.GetPenStyle[nodeStyle] FROM
  Round => {
   TAPrivate.PushReal[TAStyle.GetLineWeight[nodeStyle]];
   TAPrivate.RoundPen[]};
  Square => {
   TAPrivate.PushReal[TAStyle.GetLineWeight[nodeStyle]];
   TAPrivate.PushReal[TAStyle.GetLineWeight[nodeStyle]];
   TAPrivate.PushReal[TAStyle.GetPenSlant[nodeStyle]];
   TAPrivate.RectangularPen[]};
  Rectangular => {
   lineWeight: REAL ← TAStyle.GetLineWeight[nodeStyle];
   penWidth: REAL ← TAStyle.GetPenWidth[nodeStyle];
   penHeight: REAL ← TAStyle.GetPenHeight[nodeStyle];
   a: REAL ← penWidth/MAX[penWidth, penHeight]*lineWeight;
   b: REAL ← penHeight/MAX[penWidth, penHeight]*lineWeight;
   TAPrivate.PushReal[a];
   TAPrivate.PushReal[b];
   TAPrivate.PushReal[TAStyle.GetPenSlant[nodeStyle]];
   TAPrivate.RectangularPen[]};
  Italic => {
   TAPrivate.PushReal[TAStyle.GetLineWeight[nodeStyle]];
   TAPrivate.PushReal[TAStyle.GetPenSlant[nodeStyle]];
   TAPrivate.ItalicPen[]};
  Elliptical => {
   lineWeight: REAL ← TAStyle.GetLineWeight[nodeStyle];
   penWidth: REAL ← TAStyle.GetPenWidth[nodeStyle];
   penHeight: REAL ← TAStyle.GetPenHeight[nodeStyle];
   a: REAL ← penWidth/MAX[penWidth, penHeight]*lineWeight;
   b: REAL ← penHeight/MAX[penWidth, penHeight]*lineWeight;
   TAPrivate.PushReal[a];
   TAPrivate.PushReal[b];
   TAPrivate.PushReal[TAStyle.GetPenSlant[nodeStyle]];
   TAPrivate.EllipticalPen[]};
  ENDCASE => ERROR;
 };

}.