app/mpg/1987/src/std primitives

Raw file
Back to index

PROC std circle (INT CONST xp,yp,r,from,to): 
   moveto (xp,yp);
   REAL VAR ang :: real (from MOD 360),
            rad :: real(r),
            max :: endwinkel,
            cx  :: real (xp),
            cy  :: real (yp),
            ax0 :: cx,
            ay0 :: cy,
            ax1, ay1;

   BOOL VAR fullcircle :: ang = 0.0 AND max = 360.0;
   IF fullcircle
      THEN move to (int (cx + rad * cosd (ang)+0.5), 
                    int (cy + rad * -sind (ang)+0.5));
           ang INCR 1.0
   FI;
   WHILE ang <= max REP 
     ax1 := cx + rad * cosd (ang);
     ay1 := cy + rad * -sind (ang); 
     draw arc;
     ang INCR 1.0 
   PER; 
   IF  NOT fullcircle
      THEN  ax0 := cx;
            ay0 := cy;
            draw arc;
            draw to (xp,yp)
      ELSE  move to (xp,yp)
   FI. 

   draw arc: 
      IF clipped line (ax0,ay0,ax1,ay1) 
         THEN draw to (int (ax1+0.5), int (ay1+0.5)) 
      FI; 
      ax0 := ax1; 
      ay0 := ay1. 
 
   endwinkel: 
      IF (to MOD 360) = 0 
         THEN 360.0 
         ELSE real (to MOD 360) 
      FI 
END PROC std circle; 
 
PROC std box (INT CONST x0, y0, x1, y1, pattern): 
      REAL VAR xx0 :: real (x0), 
               yy0 :: real (y0), 
               xx1 :: real (x0), 
               yy1 :: real (y1); 
      IF clipped line (xx0,yy0,xx1,yy1)
         THEN moveto (int (xx0), int (yy0)); 
              drawto (int (xx1), int (yy1)) 
      FI; 
      xx0 := real (x0); 
      yy0 := real (y1); 
      xx1 := real (x1); 
      yy1 := real (y1); 
      IF clipped line (xx0,yy0,xx1,yy1) 
         THEN moveto (int (xx0), int (yy0)); 
              drawto (int (xx1), int (yy1)) 
      FI; 
      xx0 := real (x1); 
      yy0 := real (y1); 
      xx1 := real (x1); 
      yy1 := real (y0); 
      IF clipped line (xx0,yy0,xx1,yy1) 
         THEN moveto (int (xx0), int (yy0)); 
              drawto (int (xx1), int (yy1)) 
      FI; 
      xx0 := real (x1); 
      yy0 := real (y0); 
      xx1 := real (x0); 
      yy1 := real (y0); 
      IF clipped line (xx0,yy0,xx1,yy1) 
         THEN moveto (int (xx0), int (yy0)); 
              drawto (int (xx1), int (yy1)) 
      FI
END PROC std box;