1.1 --- a/Source/HexGrid.m Fri Mar 07 11:43:02 2008 -0800
1.2 +++ b/Source/HexGrid.m Sat Jul 05 17:46:43 2008 -0700
1.3 @@ -57,9 +57,17 @@
1.4 // Compute the horizontal spacing:
1.5 CGFloat s = floor(MIN( (frame.size.width -2.0)/nColumns,
1.6 (frame.size.height-2.0)/(nRows+0.5*tan(M_PI/6)) / (0.5*(tan(M_PI/6)+1/cos(M_PI/6))) ));
1.7 - return [self initWithRows: nRows columns: nColumns
1.8 + self = [self initWithRows: nRows columns: nColumns
1.9 spacing: CGSizeMake(s,s)
1.10 position: frame.origin];
1.11 + if( self ) {
1.12 + // Center in frame:
1.13 + CGRect curFrame = self.frame;
1.14 + curFrame.origin.x = round( curFrame.origin.x + (frame.size.width - curFrame.size.width )/2.0f );
1.15 + curFrame.origin.y = round( curFrame.origin.y + (frame.size.height- curFrame.size.height)/2.0f );
1.16 + self.frame = curFrame;
1.17 + }
1.18 + return self;
1.19 }
1.20
1.21