|
-
Feb 5th, 2011, 11:29 PM
#1
Thread Starter
Hyperactive Member
Re: Drawing a circle with a center reference
Okay, thanks. Sorry to be a pest. I think it's just the syntax that's screwing me up. Sometimes I know what I want to do but I don't know how to write it. This being the first time using the Paint event isn't helping either. I'll give it another go though.
Thanks for your patience.
-
Feb 5th, 2011, 11:45 PM
#2
Thread Starter
Hyperactive Member
Re: Drawing a circle with a center reference
Finally, I got it!
vb Code:
Public Class Form1
Dim userClick As Boolean
Private Sub Form1_MouseClick(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles Me.MouseClick
userClick = True
Refresh()
End Sub
Private Sub Form1_Paint1(ByVal sender As Object, ByVal e As System.Windows.Forms.PaintEventArgs) Handles Me.Paint
If userClick = True Then
Dim g As Graphics = e.Graphics
Dim pn As New Pen(Color.Blue, 3)
g.DrawEllipse(pn, 50, 50, 100, 100)
End If
End Sub
End Class
Thanks for the help!
-
Feb 5th, 2011, 11:54 PM
#3
Thread Starter
Hyperactive Member
Re: Drawing a circle with a center reference
Here's the rest. How can it be improved?
vb Code:
Public Class Form1 Dim userClick As Boolean Private Sub Form1_MouseClick(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles Me.MouseClick userClick = True Me.Refresh() End Sub Private Sub Form1_Paint1(ByVal sender As Object, ByVal e As System.Windows.Forms.PaintEventArgs) Handles Me.Paint If userClick = True Then Dim g As Graphics = e.Graphics Dim diameter As Int32 = 5 Dim random As New Random For count As Int32 = 1 To 50 Dim radius As Int32 = CInt(diameter / 2) Dim xCenter As Int32 = CInt(Me.ClientSize.Width / 2) - radius Dim yCenter As Int32 = CInt(Me.ClientSize.Height / 2) - radius Dim penCurrent As New Pen(Color.FromArgb(random.Next(1, 256), random.Next(1, 256), random.Next(1, 256)), 4) Me.CreateGraphics.DrawEllipse(penCurrent, xCenter, yCenter, diameter, diameter) diameter += 15 System.Threading.Thread.Sleep(45) Next End If End Sub End Class
-
Feb 6th, 2011, 12:48 AM
#4
Thread Starter
Hyperactive Member
Re: Drawing a circle with a center reference
Just noticed in my last post I forgot to replace CreateGraphics with g.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|