summaryrefslogtreecommitdiff
path: root/app/mpg/1987/src/std primitives
blob: dca20bd91d95515a27bb6e324be7a6065430e81d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
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;