I was fooling around with drawing more or less of each hex, and I found that that tiling went a bit smoother when I started drawing a 'wrench' shape with each iteration.

BTW anyone have any hard facts on whether two integer additions are faster than a single integer multiplication?

Anyways it went a little bit like this:

Code:

int rootThree = Math.sqrt(3);
halfLength = hLength / 2;
int x = 2 * hLength;
int y = rootThree;
int xpre1 = x - halfLength;
int xpre2 = xpre1 - hLength;
int xpre3 = x - ( 2 * hLength );
int xpost1 = x + hLength;
int ypre = y - rootThree;
int ypost = y + rootThree;
int xincrement = 3 * hLength;
int yincrement = 2 * rootThree;
while ( xpost <= bWidth ) {
while ( ypost <= bHeight ) {
Draw_Line(xpre2,ypost,xpre3,y);
Draw_Line(xpre3,y,xpre2,ypre);
Draw_Line(xpre2,ypre,xpre1,ypre);
Draw_Line(xpre1,ypre,x,y);
Draw_Line(x,y,xpre1,ypost);
Draw_Line(x,y,xpost,y);
y += yincrement;
ypre += yincrement;
ypost += yincrement;
}
Draw_Line(xpre2,ypost,xpre1,ypost);
x += xincrement;
xpre1 += xincrement;
xpre2 += xincrement;
xpre3 += xincrement;
xpost1 += xincrement;
;maybe insert some cases to draw final partial columns...
}

-pb

Tweet This+ 1 thisPost To Linkedin