Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Public Class Form1
- Private Angle As Single = 100
- Private NextIncrement As Single = 1
- Private Randomizer As New Random(Now.Millisecond)
- Private SliceColors As New List(Of Color)
- Private SlicesOnWheel As Integer = 6
- Private WheelRadius As Integer = 300
- Private WheelLocation As New Point(50, 50)
- Protected Overrides Sub OnPaint(e As PaintEventArgs)
- Dim g As Graphics = e.Graphics
- Dim x2, y2, d As Single
- Dim theNumbers() As String = {"V", "I", "R", "T", "U", "S"}
- g.SmoothingMode = Drawing2D.SmoothingMode.HighQuality
- g.InterpolationMode = Drawing2D.InterpolationMode.HighQualityBicubic
- g.Clear(Color.LightBlue)
- Dim sliceAngle As Single = CSng(360 / SlicesOnWheel)
- Dim rect As New Rectangle(WheelLocation, New Size(WheelRadius, WheelRadius))
- Dim r As Double = 0.495 * rect.Width
- Dim curveWidth As Integer = CInt(WheelRadius - (WheelRadius / (2.0! * 0.9)))
- Dim rect2 As New Rectangle(rect.Left + curveWidth, rect.Top + curveWidth, rect.Width - curveWidth * 2, rect.Height - curveWidth * 2)
- Dim count As Integer
- For I As Single = 0 To 359 Step sliceAngle
- g.FillPie(New SolidBrush(SliceColors(CInt(I / sliceAngle))), rect, I + NormalizeAngle(Angle), sliceAngle)
- g.DrawPie(Pens.White, rect, I + NormalizeAngle(Angle), sliceAngle)
- g.FillPie(Brushes.AliceBlue, rect2, I + NormalizeAngle(Angle) + 1, sliceAngle - 2)
- g.DrawPie(Pens.Blue, rect2, I + NormalizeAngle(Angle) + 1, sliceAngle - 2)
- d = I + NormalizeAngle(Angle)
- If theNumbers(count).ToString.Length = 1 Then d = d + sliceAngle / 2 ''se centra string en cuadro
- x2 = CInt((r * Math.Cos(d / 57.3)) + rect.X + rect.Width / 2)
- y2 = CInt((r * Math.Sin(d / 57.3)) + rect.Y + rect.Width / 2)
- g.TranslateTransform(x2, y2)
- g.RotateTransform(d + 93)
- g.DrawString(theNumbers(count).ToString, New Font("Arial", 12, FontStyle.Bold), Brushes.White, 0, 0)
- g.ResetTransform()
- count += 1
- Next
- g.FillEllipse(Brushes.LightBlue, rect2)
- g.DrawEllipse(Pens.White, rect2)
- g.DrawEllipse(Pens.White, rect)
- Dim Triangle() As Point = {New Point(400, 25), New Point(333, 108), New Point(427, 58)} '(horizontal,vertical)'
- g.DrawPolygon(Pens.Black, Triangle)
- g.FillPolygon(Brushes.Black, Triangle)
- MyBase.OnPaint(e)
- End Sub
- Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
- Me.DoubleBuffered = True
- Timer1.Interval = 15
- Dim numbers As New List(Of Integer) From {1, 2, 3, 4, 5, 6}
- SlicesOnWheel = numbers.Count
- Dim oddCount As Integer = 0
- Do
- SliceColors.Add(Color.Fuchsia)
- SliceColors.Add(Color.Orange)
- SliceColors.Add(Color.Red)
- SliceColors.Add(Color.Yellow)
- SliceColors.Add(Color.Green)
- SliceColors.Add(Color.Beige)
- Loop Until SliceColors.Count = numbers.Count
- End Sub
- Private Sub Timer1_Tick(sender As Object, e As EventArgs) Handles Timer1.Tick
- Angle = NormalizeAngle(Angle + NextIncrement)
- NextIncrement -= NextIncrement * 0.03!
- If NextIncrement <= 0.005 Then
- Timer1.Enabled = False
- End If
- Me.Text = Angle.ToString
- Me.Invalidate()
- End Sub
- Public Function NormalizeAngle(value As Single) As Single
- Return value Mod 360
- End Function
- Private Sub btnSpin_Click_1(sender As Object, e As EventArgs) Handles btnSpin.Click
- If Timer1.Enabled = False Then
- NextIncrement = Randomizer.Next(40, 75)
- End If
- Timer1.Enabled = Not Timer1.Enabled
- End Sub
- End Class
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement