Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- open System.Windows.Forms
- open System.Drawing
- type MyForm() as this =
- inherit Form()
- do
- this.SetStyle(ControlStyles.DoubleBuffer, true)
- this.SetStyle(ControlStyles.UserPaint, true)
- this.SetStyle(ControlStyles.AllPaintingInWmPaint, true)
- let f = new MyForm(Text="Porygon", TopMost=true)
- f.Show()
- let mutable n = 3.
- let disegnaPoli (g:Graphics) n =
- let gradi = 360. / n
- let rad = (gradi / 180.) * System.Math.PI
- let arr: Point[] = Array.zeroCreate (int(n))
- for i=0 to (int(n-1.)) do
- let k = float(i)
- let x = int(200. * cos(rad * k))
- let y = int(200. * sin(rad * k))
- arr.[i] <- Point(x, y)
- // g.RotateTransform(float32(gradi))
- // arr.[i] <- new Point(200, 0)
- // g.DrawLine(Pens.Black, 0, 0, 200, 0)
- g.FillPolygon(Brushes.DarkCyan, arr)
- //g.Restore(s)
- f.Paint.Add( fun e ->
- let g = e.Graphics
- g.SmoothingMode <- Drawing2D.SmoothingMode.HighQuality
- g.TranslateTransform(350.f, 350.f)
- g.RotateTransform(-90.f)
- // let s = g.Save()
- disegnaPoli g n
- // disegnaPoli g 3. s
- // disegnaPoli g 4.
- )
- f.Invalidated.Add( fun _ ->
- if (n = 20.)
- then n <- 3.
- else n <- n+1.
- )
- let timer = new Timer(Interval=250)
- timer.Tick.Add(fun _ ->
- f.Invalidate()
- )
- timer.Start()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement