|
Imports System.Drawing.Drawing2D
Dim bmp As Bitmap = New Bitmap(310, 310)
Private Sub Timer1_Tick(ByVal sender As System.Object, _
ByVal e As System.EventArgs) Handles Timer1.Tick
Me.Text = CStr(DateTime.Now)
Dim g As Graphics = Graphics.FromImage(bmp)
Dim gFont As New Font("Comic Sans MS", 20, FontStyle.Bold)
Dim f1 As Pen = New Pen(Color.BlueViolet, 10)
Dim f2 As Pen = New Pen(Color.BlueViolet, 3)
Dim x, y, wi, b As Int32
Dim h As Int32 = DateTime.Now.Hour
Dim m As Int32 = DateTime.Now.Minute
Dim s As Int32 = DateTime.Now.Second
f1.EndCap = LineCap.Triangle
f1.StartCap = LineCap.RoundAnchor
g.SmoothingMode = Drawing2D.SmoothingMode.HighQuality
g.TextRenderingHint = _
Drawing.Text.TextRenderingHint.ClearTypeGridFit
If h > 12 Then h -= 12
g.FillEllipse(Brushes.DarkGray, 1, 1, 308, 308)
g.FillEllipse(Brushes.Silver, 15, 15, 280, 280)
b = 12
For wi = 90 To 420 Step 30
x = CInt(132 + Math.Cos(wi * Math.PI / 180) * 120)
y = CInt(136 - Math.Sin(wi * Math.PI / 180) * 120)
If b = 12 Then x -= 7
g.DrawString(Str(b), gFont, Brushes.Red, x, y)
b -= 1
Next wi
gFont.Dispose()
For wi = 90 To 450 Step 6
x = CInt(154 + Math.Cos(wi * Math.PI / 180) * 135)
y = CInt(154 - Math.Sin(wi * Math.PI / 180) * 135)
g.FillEllipse(Brushes.BlueViolet, x, y, 3, 3)
Next wi
g.TranslateTransform(-155, -155)
g.RotateTransform(-90 + h * 30 + (m \ 2), MatrixOrder.Append)
g.TranslateTransform(155, 155, MatrixOrder.Append)
g.DrawLine(f1, 155, 155, 245, 155)
g.ResetTransform()
g.TranslateTransform(-155, -155)
g.RotateTransform(-90 + m * 6 + (s \ 10), MatrixOrder.Append)
g.TranslateTransform(155, 155, MatrixOrder.Append)
f1.Width = 8
g.DrawLine(f1, 155, 155, 280, 155)
f1.Dispose()
g.ResetTransform()
g.TranslateTransform(-155, -155)
g.RotateTransform(-90 + s * 6, MatrixOrder.Append)
g.TranslateTransform(155, 155, MatrixOrder.Append)
g.DrawLine(f2, 155, 155, 280, 155)
f2.Dispose()
g.FillEllipse(Brushes.Red, 147, 147, 16, 16)
PictureBox1.Image = bmp
End Sub
|
|