-
March 3rd, 2008, 04:39 PM
#1
how to draw a hexagon?
hey there, im trying to make an application that will create a hex-map (essentially a grid map where each cell is a hexagon instead of a square).... im not really sure where to start with this, but i figured that the best place to start would be one single cell.... is hexagon an object that is supported already? ie. does the system.drawing allow for hexagons to be drawn
-
March 3rd, 2008, 05:25 PM
#2
Re: how to draw a hexagon?
call DrawPolygon and pass in the 6 points needed to draw your shape.
Last edited by MadHatter; March 3rd, 2008 at 05:54 PM.
-
March 3rd, 2008, 05:37 PM
#3
Re: how to draw a hexagon?
thanks for the help.... i was thinking that i would have to do that and it turns out i have to.... i was hoping for something easier, but if thats how it needs to be done, then so be it
-
March 3rd, 2008, 05:55 PM
#4
Re: how to draw a hexagon?
you can always create helper methods to do things like drawing a hexagon that wrap the lower level api's, and make your life a little easier.
-
March 3rd, 2008, 06:04 PM
#5
Re: how to draw a hexagon?
Change count to 6 and draw a line...
Code:
Private Sub Form_Load()
Dim px As Double, py As Double, i%, cnt%, r1 As Double, r As Double
px = ScaleWidth / 2 - Text1(0).Width / 2
py = ScaleHeight / 2 - Text1(0).Height / 2
r = 1365 ' radius
cnt = 12 ' number of images
Text1(0).Move px, py
Text1(0).Visible = False
For i = 1 To cnt
If Not i = 0 Then Load Text1(i)
With Text1(i)
r1 = 360 / cnt * (i) * 3.1428571 / 180
.Move px + r * Sin(r1), py - r * Cos(r1)
.Text = i
.Visible = True
End With
Next i
End Sub
This draws numbers on a clock face
-
March 5th, 2008, 09:00 AM
#6
Re: how to draw a hexagon?
Why VB6 code in response to a question posted in the C# section?
-
March 5th, 2008, 10:01 AM
#7
Re: how to draw a hexagon?
MadHatter is correct about the DrawPolygon method - that's what I would have done as well. I prefer to make use of the .NET classes as much as possible, instead of API ( although they can be extremely handy ), I guess it's just a matter of opinion
Here is a very nice example to get you started with drawing Hexagons, only issue I have with this article is the fact that it's not a CG one !
http://www.codeproject.com/KB/cs/hexagonal_part1.aspx
I hope my post was useful, if even a little
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
|