I'm trying to create a watch. Which is a pain in my (3 letter word for rear). I've all ready sucessfuly drawn the numbers on the watches face with Boops help:
problem is, I don't know how this math works inside the loop, and well outside it too. I know that the circumfrance of a circle is pi times radius squared,the radius is half the distance, and that the center point is 1/2 of the width and height. Also, I found out that the angle of a triangle from the center to 2 numbers is 30 degrees(360/12). Could y'all kinda help me out on this one? I did terrible in highschool math, and I just wanna understand it :PCode:Public Class Form1 Dim P As New Pen(Brushes.Red, 1) Dim a As Integer = 12 Dim b As Integer = 2 Dim Angle As Single = CSng(b / a * Math.PI) Dim drawingMargin As Integer = CInt(Me.Width / 6) Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load Me.SetClientSizeCore(400, 400) End Sub Private Sub Form1_Paint(ByVal sender As Object, ByVal e As System.Windows.Forms.PaintEventArgs) Handles Me.Paint e.Graphics.SmoothingMode = SmoothingMode.HighQuality Dim Rect As Rectangle = Me.ClientRectangle Rect.Inflate(-drawingMargin, -drawingMargin) Using mypen As New Pen(Color.Blue, 1) For i As Integer = 1 To a Step 1 Dim Centre As New Point(Me.ClientSize.Width \ 2, Me.ClientSize.Height \ 2) Dim outerRadius As Single = Centre.X - drawingMargin / 2.0F Dim outerX, outerY As Single outerX = Centre.X + CSng(outerRadius * Math.Sin(Angle * i)) outerY = Centre.Y - CSng(outerRadius * Math.Cos(Angle * i)) Dim number As String = i.ToString Dim numberSize As SizeF = e.Graphics.MeasureString(number, Me.Font) Dim textLocation As New PointF(outerX - numberSize.Width / 2.0F, outerY - numberSize.Height / 2.0F) e.Graphics.DrawString(i.ToString, Me.Font, Brushes.Black, textLocation) Next i End Using e.Graphics.DrawEllipse(Pens.Black, Me.ClientRectangle) End Sub


Reply With Quote