home *** CD-ROM | disk | FTP | other *** search
/ Turbo Toolbox / Turbo_Toolbox.iso / 1987 / 03 / fkplot.pas < prev    next >
Encoding:
Pascal/Delphi Source File  |  1987-02-03  |  2.1 KB  |  73 lines

  1. {---------------------------------------------------------------------------}
  2. PROGRAM Funktionsplotter;
  3.  
  4. TYPE str100 = STRING[100];
  5.      Str    = STRING[255];
  6.  
  7. VAR q2                        : Str;
  8.     xmin, ymin, xmax, ymax,                          { Grenzen der Funktion }
  9.     xax, yax, xsc, ysc        : REAL;               { Achsen und Skalierung }
  10.     xp, yp                    : INTEGER;            { Bildschirmkoordinaten }
  11.     s                         : INTEGER;             { Anzahl Stuetzstellen }
  12.  
  13. {$I draw.inc}
  14. {$I fkplot2.pas}
  15. {$I fkplot3.pas}
  16. {$I fkplot1.pas}
  17. {$I fkplot4.pas}
  18.  
  19. {---------------------------------------------------------------------------}
  20.  
  21. PROCEDURE DrawAxis;
  22.  
  23. VAR x, y, dist: REAL;
  24.     xaxp, yaxp: INTEGER;
  25.  
  26. BEGIN
  27.   WorldToScreen(xax, yax, xaxp, yaxp);
  28.   Draw(ScreenLeft, yaxp, ScreenXMax, yaxp);
  29.   Draw(xaxp, ScreenBott, xaxp, ScreenYMax);
  30.  
  31.   dist := xsc*(ScreenXmax-ScreenLeft)/(xmax-xmin);   { Skalierung vornehmen }
  32.   x := ScreenLeft;  y := yaxp;
  33.   REPEAT
  34.     Draw(Round(x), Round(y-Unit), Round(x), Round(y+Unit));
  35.     x := x+dist;
  36.   UNTIL x > ScreenXMax;
  37.   dist := ysc*(ScreenYMax-ScreenBott)/(ymax-ymin);
  38.   y := ScreenBott;  x := xaxp;
  39.   REPEAT
  40.     Draw(Round(x-Unit), Round(y), Round(x+Unit), Round(y));
  41.     y := y+dist;
  42.   UNTIL y > ScreenYMax;
  43. END;
  44.  
  45. {---------------------------------------------------------------------------}
  46.  
  47. PROCEDURE PlotFunction;
  48.  
  49. VAR x, y1, y2, d: REAL;
  50.  
  51. BEGIN
  52.   x := xmin;
  53.   d := (xmax-xmin)/s;
  54.   WHILE x+d <= xmax DO
  55.   BEGIN
  56.     y1 := Berechnung(q2, x);
  57.     y2 := Berechnung(q2, x+d);
  58.     DrawLine(x, y1, x+d, y2);
  59.     x := x+d;
  60.   END;
  61. END;
  62.  
  63. {---------------------------------------------------------------------------}
  64.  
  65. BEGIN
  66.   Eingabe;
  67.   InitGraphic;                                   { Graphik-Modus aktivieren }
  68.   DrawAxis;                                      { Achsenkreuz zeichnen     }
  69.   PlotFunction;                                  { Funktion zeichnen        }
  70.   REPEAT UNTIL KeyPressed;                       { auf Tastendruck warten   }
  71.   LeaveGraphic;
  72. END.
  73.