Advertisement
Guest User

Untitled

a guest
Nov 19th, 2017
58
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.61 KB | None | 0 0
  1. uses GraphABC;
  2.  
  3. type realFun= real -> real;
  4.  
  5. procedure DrawGraph(f:realFun; a, b, d:real);
  6. begin
  7. var k:= (window.Width div 2) / (b - a);
  8. coordinate.SetOrigin(round(window.Width div 2 - (b + a)*k), window.Height div 2);
  9. Line(0, -300, 0, 300);
  10. Line(-600, 0, 600, 0);
  11. for var i:= floor(a) to ceil(b) do
  12. Line(round(i*k), -3, round(i*k), 3);
  13. var x:= a;
  14. var y:= f(x);
  15. pen.color:= Color.Red;
  16. while x < b do
  17. begin
  18. Line(round(x*k), round(y*k),
  19. round((x + d)*k), round((f(x + d))*k));
  20. x+=d;
  21. y:= f(x);
  22. end;
  23. end;
  24.  
  25. begin
  26. DrawGraph(x -> x, -10, 5, 0.1);
  27. end.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement