Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- open System.Windows.Forms
- open System.Drawing
- open System.Timers
- type ThrobberApple() as x =
- inherit UserControl()
- let mutable rotation = 0
- let mutable pensize = 0
- let colors : Color array = Array.zeroCreate 12
- do
- let timer = new Timer(Interval = 60.0, Enabled = true)
- for i in 0..11 do
- colors.[i] <- Color.FromArgb((i * 20) + 15, Color.Black)
- timer.AutoReset <- true
- timer.Elapsed.Add(fun _ ->
- rotation <- (rotation + 1) % 12
- x.Refresh()
- )
- x.DoubleBuffered <- true
- override x.OnPaint e =
- let graphics = e.Graphics
- graphics.SmoothingMode <- Drawing2D.SmoothingMode.HighQuality
- let pensize = x.Width / 15
- let pen = new Pen(Color.Black, single pensize)
- pen.StartCap <- Drawing2D.LineCap.Round
- pen.EndCap <- Drawing2D.LineCap.Round
- let from = int (single (x.Width - 2 * pensize) * 0.28f)
- let len = (x.Width - 2 * pensize) / 2 - from
- graphics.TranslateTransform(single (x.Width / 2), single (x.Width / 2))
- graphics.RotateTransform(30.f * single rotation)
- for i in 0..11 do
- pen.Color <- colors.[i]
- graphics.DrawLine(pen, from, 0, from + len, 0)
- graphics.RotateTransform(30.f)
- done
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement