• Advertisement
Sign in to follow this  

hex grids and c#

This topic is 4680 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Advertisement
Quote:
Original post by phil67rpg
I want to draw a hex grid using c# and the gdi+


Do you have a more specific question? Check out the article sections here on hex grids, drawing it using GDI+ is only a mattter of looking at the GDI+ documentation and making use of simple drawing functions.

Share this post


Link to post
Share on other sites
well here some code for drawing a hex grid using c# and the gdi+ it is not complete though

private void From1_Paint(object sender,System.Windows.Forms.PaintEventArgs e)
{
this.BackColor=Color.Black;
Graphics g=e.Graphics;
Pen pn = new Pen(Color.White,1);
for (int j=0;j<=600;j+=40)
{
g.DrawLine(pn,+60,j+20,+80,j+20);
}

for (int k=0;k<=600;k+=40)
{
g.DrawLine(pn,80,k+20,100,k+40);
}
for (int l=0;l<=600;l+=40)
{
g.DrawLine(pn,100,l+40,80,l+60);
}
for (int m=0;m<=600;m+=40)
{
g.DrawLine(pn,80,m+60,60,m+60);
}
for (int n=0;n<=600;n+=40)
{
g.DrawLine(pn,60,n+60,40,n+40);
}




for (int q=0;q<=600;q+=40)
{
g.DrawLine(pn,0,q+20,20,q);
}

for (int r=0;r<=600;r+=40)
{
g.DrawLine(pn,20,r,40,r);
}
for (int s=0;s<=600;s+=40)
{
g.DrawLine(pn,40,s,60,s+20);
}
for(int t=0;t<=600;t+=40)
{
g.DrawLine(pn,60,t+20,40,t+40);
}
for (int u=0;u<=600;u+=40)
{
g.DrawLine(pn,40,u+40,20,u+40);
}
for (int v=0;v<=600;v+=40)
{
g.DrawLine(pn,20,v+40,0,v+20);
}
}
}
}

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement