Advertisement
Guest User

Untitled

a guest
May 25th, 2015
223
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.96 KB | None | 0 0
  1. open System
  2. open System.Drawing
  3. open System.Drawing.Imaging
  4. open System.Drawing.Drawing2D
  5. open System.Windows.Forms
  6.  
  7. let r = 5.0
  8. //let squareF = fun x -> Math.Sin(x)
  9. let squareF = fun x -> Math.PI*r*r
  10. let xArray = [|-3.0 .. 0.1..3.0|]
  11. let yArray = Array.map squareF xArray
  12. let W,H = 800,800
  13. let scaleX = Array.map (fun x -> x*44.0+400.0) xArray
  14. let scaleY = Array.map( fun x -> 400.0-44.0*x) yArray
  15.  
  16. let form =
  17. let b = new Bitmap(W,H)
  18. let g = Graphics.FromImage(b)
  19. let pen = new Pen(Color.Black)
  20. g.DrawLine(pen, W/2,0,W/2,H)
  21. g.DrawLine (pen, 0,H/2,W,H/2)
  22. let red = new Pen(Color.Red)
  23.  
  24. let mutable i=1
  25. while i<scaleX.Length do
  26. g.DrawLine(red, (float32)scaleX.[i-1], (float32)scaleY.[i-1], (float32)scaleX.[i], (float32)scaleY.[i])
  27. i<- i+1
  28.  
  29. let temp = new Form()
  30. temp.Paint.Add(fun e -> e.Graphics.DrawImage(b, 0, 0))
  31. temp
  32.  
  33. [<STAThread>]
  34. do Application.Run(form);;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement