farhadtolooie
asked on
draw curve
hello experts
I'm beginner in vb.net .
I want to draw a curve with a couple of points those represent a profile of oil pipeline, I found these code from MSDN:
Dim points As Point() = { _
New Point(0, 100), _
New Point(50, 80), _
New Point(100, 20), _
New Point(150, 80), _
New Point(200, 100)}
Dim pen As New Pen(Color.FromArgb(255, 0, 0, 255))
e.Graphics.DrawCurve(pen, points)
how do I use these code in my program?
what component need to these code draw curve in it?
where I declare "e" object ?
how I print the drawed curve in page A3?
is there any better way to draw curve?
please write me codes.
thanks
I'm beginner in vb.net .
I want to draw a curve with a couple of points those represent a profile of oil pipeline, I found these code from MSDN:
Dim points As Point() = { _
New Point(0, 100), _
New Point(50, 80), _
New Point(100, 20), _
New Point(150, 80), _
New Point(200, 100)}
Dim pen As New Pen(Color.FromArgb(255, 0, 0, 255))
e.Graphics.DrawCurve(pen, points)
how do I use these code in my program?
what component need to these code draw curve in it?
where I declare "e" object ?
how I print the drawed curve in page A3?
is there any better way to draw curve?
please write me codes.
thanks
ASKER
thank you for your speed answer.
I replace poits with real points such as
Dim points As Point() = { _
New Point(1, 800), _
New Point(2, 780), _
New Point(5, 900), _
New Point(10, 1200), _
New Point(13, 2000)}
and run the program and I saw the curve is out of my form while form was in maximum size of my monitor.
how do you solve this problem,
if I want to draw curve with axis of x and y(x-axis,y-axis) how do I it?
please write me some code
thanks
I replace poits with real points such as
Dim points As Point() = { _
New Point(1, 800), _
New Point(2, 780), _
New Point(5, 900), _
New Point(10, 1200), _
New Point(13, 2000)}
and run the program and I saw the curve is out of my form while form was in maximum size of my monitor.
how do you solve this problem,
if I want to draw curve with axis of x and y(x-axis,y-axis) how do I it?
please write me some code
thanks
You need to define a coordinate system that breaks the screen coordinates into quadrants.
Bob
Bob
ASKER
how do I that
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Your code snippet above goes typically into the Paint event or DrawItem event of a Windows Control, such as a PictureBox or any other control with a visible body.
In case of a PictureBox Control which has a Paint event, the "e" object is an argument of the event subroutine. In this case it is a System.Windows.Forms.Paint
To your questions:
how do I use these code in my program?
A: just copy it into the Paint event handler of a Picturebox, as an example.
Private Sub PictureBox1_Paint(ByVal sender As Object, ByVal e As System.Windows.Forms.Paint
Dim points As Point() = { _
New Point(0, 100), _
New Point(50, 80), _
New Point(100, 20), _
New Point(150, 80), _
New Point(200, 100)}
Dim pen As New Pen(Color.FromArgb(255, 0, 0, 255))
e.Graphics.DrawCurve(pen, points)
End Sub
what component need to these code draw curve in it?
A: Any form or component which has a Paint or DrawItem argument. There are other ways too, but this should be good enough for your tests.
where I declare "e" object ?
A: see above
how I print the drawed curve in page A3?
A: make your object on which you draw the size of A3. Be aware that the monitor has a different resolution than for example a printer, so A3 is relative and depends on the output device.
is there any better way to draw curve?
A: all depends on what curve you plan to draw. DrawCurve produces a Cardinal Spline. You may want to check all the other draw methods which the Graphics method exposes. Use Help of Visual Studio to find them all.
Have fun with GDI+, Jack.net