Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- open System.Windows.Forms
- open System.Drawing
- // Prepare window form
- let win = new System.Windows.Forms.Form ()
- // Set some properties
- win.BackColor <- System.Drawing.Color.White
- let height = 250
- let width = 200
- win.Size <- System.Drawing.Size (width, height)
- // make a timer
- let timer = new Timer ()
- timer.Interval <- 1000 // create an event every 1000 millisecond
- timer.Enabled <- true // activate the timer
- let getEndPoint degrees =
- let t = float 50
- let s = float 0
- let theta = float degrees * (System.Math.PI / float 180)
- let u = (s * (cos theta) + t * (sin theta)) + float 100
- let v = (-s * (sin theta) + -t * (cos theta)) + float 100
- Point (int u,int v)
- // Set paint call-back function
- let paint (e : PaintEventArgs) (x) : unit =
- let pen = new Pen (Color.Black)
- let endPoint = getEndPoint x
- let points = [|Point (100,100); endPoint|]
- e.Graphics.DrawLines (pen, points)
- let getDegrees =
- 360/60*System.DateTime.Now.Second
- let addPaint degrees =
- printfn "Draws with degrees %A" degrees
- win.Paint.Add (fun e -> (paint e degrees))
- win.Paint.Add (fun e -> (paint e 90))
- //timer.Tick.Add (fun e -> (addPaint 90)) // Doesn't draw
- //timer.Tick.Add (fun e -> (addPaint getDegrees)) // Doesn't draw, updates every second, but doesn't change degrees
- //timer.Tick.Add (fun e -> (addPaint (360/60*System.DateTime.Now.Second))) // Doesn't draw, but get correct degrees
- // Start the event-loop.
- System.Windows.Forms.Application.Run win
Add Comment
Please, Sign In to add comment