|
-
Oct 28th, 2006, 02:36 AM
#1
Thread Starter
Member
axes
How can I draw simple X and Y axes?
And how can I set my point 0 on another place?
Could someone give me the codes for it?
thx
-
Oct 28th, 2006, 02:43 AM
#2
Re: axes
 Originally Posted by Gleba
How can I draw simple X and Y axes?
And how can I set my point 0 on another place?
Could someone give me the codes for it?
thx
Hi,
Here's a link about the X and Y axes;
http://msdn.microsoft.com/library/de...transforms.asp
Hope it helps,
sparrow1
-
Oct 30th, 2006, 12:45 PM
#3
Thread Starter
Member
Re: axes
if i use this code
Private Sub YGrid _
(ByVal GridColor As Color, ByVal AxisColor As Color, _
ByVal LabelColor As Color, ByVal LineWidth As Double)
Dim lLine As GraphicsPath
Dim lGridPen As New Pen(GridColor, LineWidth / 4.0)
Dim lAxisPen As New Pen(AxisColor, LineWidth)
For Each i As Integer In AxisPoints(mMinY, mMaxY)
lLine = New GraphicsPath
lLine.AddLine(New PointF(mMinX, i), New PointF(mMaxX, i))
If i = 0 Then
mGraphics.DrawPath(lAxisPen, lLine)
Else
mGraphics.DrawPath(lGridPen, lLine)
End If
DrawString(i.ToString, New PointF(0, i), LabelColor)
Next i
End Sub
i can't get it to work, I don't know where to put it in. Do I need to put it in the sub form or what? I don't know.
-
Oct 30th, 2006, 12:57 PM
#4
Re: axes
any code to draw on a form should be done in the forms paint event.
you can draw on the form in any routine by creating a graphics object from the form class like this..
VB Code:
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim G As Graphics = Me.CreateGraphics
G.DrawString("HELLO WORLD", Me.Font, Brushes.Black, 0, 0)
G.Dispose()
End Sub
However as soon as your form is repainted (minimized and the restored, moved off screen then back on, or another window comes on top of the apps window), the string that was drawn will be gone.
If you put the drawing code in the forms paint event, it will be drawn everytime the form is repainted.
Also in the forms paint event, you can use e.Graphics that is passed in as a parameter, instead of using Me.CreateGraphics.
-
Oct 31st, 2006, 02:18 AM
#5
Thread Starter
Member
Re: axes
thx, but i still don't know how i can use this code.
Private Sub YGrid _
(ByVal GridColor As Color, ByVal AxisColor As Color, _
ByVal LabelColor As Color, ByVal LineWidth As Double)
Dim lLine As GraphicsPath
Dim lGridPen As New Pen(GridColor, LineWidth / 4.0)
Dim lAxisPen As New Pen(AxisColor, LineWidth)
For Each i As Integer In AxisPoints(mMinY, mMaxY)
lLine = New GraphicsPath
lLine.AddLine(New PointF(mMinX, i), New PointF(mMaxX, i))
If i = 0 Then
mGraphics.DrawPath(lAxisPen, lLine)
Else
mGraphics.DrawPath(lGridPen, lLine)
End If
DrawString(i.ToString, New PointF(0, i), LabelColor)
Next i
End Sub
You see I'm trying to draw the x and y axe and maybe the z axe to. But I would like to do it in a picturebox.
Also I would like that i can change the point(0,0) in the center of the picture box.
-
Oct 31st, 2006, 04:31 AM
#6
Re: axes
From what I understand, would I be correct in saying that you have no idea what that code actually does that you are using?
If so, you really must start with the basics of what and how to draw simple stuff, like lines, circles etc. Learn what the objects do, learn how to call them, learn how to change them.
If you have already done this, then ignore me .
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
|