|
-
Oct 17th, 2015, 07:06 AM
#1
Thread Starter
Junior Member
[RESOLVED] Graphing a Circle in a Coordinate Plane with inputs Center and Radius
I'm trying to plot a circle on a Coordinate Plane. Now my problem is that whenever I'm trying to input something (for example, C:0,0 R:10), it doesn't plot correctly in the cartesian coordinate plane.
I've been trying to solve this for like hours but it seems like I can't fix this on my own. I think my problem lies within the Button1_Click event, I've tried changing the values of variables x, y and r but still can't get it right. Any help would be appreciated. Thanks.
My Code so far:
Code:
Private Sub Form1_Load(ByVal sender As Object, ByVal e As EventArgs) Handles MyBase.Load
g = Me.CreateGraphics()
End Sub
Private Sub Form1_Paint(ByVal sender As Object, ByVal e As PaintEventArgs) Handles Me.Paint //the drawing of Cartesian Plane
e.Graphics.FillRectangle(Brushes.White, New Rectangle(300, 10, 500, 491))
e.Graphics.DrawLine(Pens.Black, New Point(555, 10), New Point(555, 500))
e.Graphics.DrawLine(Pens.Black, New Point(300, 250), New Point(800, 250))
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
If TextBox1.TextLength <> 0 And TextBox2.TextLength <> 0 And TextBox3.TextLength <> 0 Then
Click = True
g.Clear(DefaultBackColor)
g.FillRectangle(Brushes.White, New Rectangle(300, 10, 500, 491))
g.DrawLine(Pens.Black, New Point(555, 10), New Point(555, 500))
g.DrawLine(Pens.Black, New Point(300, 250), New Point(800, 250))
x = CType(TextBox1.Text, Integer) * distance
y = CType(TextBox2.Text, Integer) * distance
r = CType(TextBox3.Text, Integer) * distance
g.FillEllipse(Brushes.Black, x, y, 7, 7)
g.DrawEllipse(Pens.Black, x, y, r, r)
Else
MessageBox.Show("Please Complete All Fields Before Plotting!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Warning)
End If
End Sub
Last edited by angel06; Oct 17th, 2015 at 11:07 AM.
Tags for this Thread
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
|