Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- open System
- open System.Drawing
- open System.Drawing.Imaging
- open System.Drawing.Drawing2D
- open System.Windows.Forms
- let r = 5.0
- //let squareF = fun x -> Math.Sin(x)
- let squareF = fun x -> Math.PI*r*r
- let xArray = [|-3.0 .. 0.1..3.0|]
- let yArray = Array.map squareF xArray
- let W,H = 800,800
- let scaleX = Array.map (fun x -> x*44.0+400.0) xArray
- let scaleY = Array.map( fun x -> 400.0-44.0*x) yArray
- let form =
- let b = new Bitmap(W,H)
- let g = Graphics.FromImage(b)
- let pen = new Pen(Color.Black)
- g.DrawLine(pen, W/2,0,W/2,H)
- g.DrawLine (pen, 0,H/2,W,H/2)
- let red = new Pen(Color.Red)
- let mutable i=1
- while i<scaleX.Length do
- g.DrawLine(red, (float32)scaleX.[i-1], (float32)scaleY.[i-1], (float32)scaleX.[i], (float32)scaleY.[i])
- i<- i+1
- let temp = new Form()
- temp.Paint.Add(fun e -> e.Graphics.DrawImage(b, 0, 0))
- temp
- [<STAThread>]
- do Application.Run(form);;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement