I thing I have already shown the critical code.
But here is a larger chunk.
I had already commented out the inner loop from drawHcmb()
and replaced it with the doLoops().
My abbreviated arguments!!!
shd = shade =r =g =b = rgb(shd,shd,shd)
rng = ring number ( the hexagonal 'rings' around the central ring
stp = step, the rgb colour adjustment between neighbouring hexagons
sc = scale NOT USED.
Note the central hexagon is generated in the 'drawHcmb' function
All the surrounding hexagons are produced by doLoops.
/* * * * * * * * * * * * * * * * * * */
int doLoops ( FILE *fp, int shd, int rng, int stp )
{
int i, j, k;
char use[] = " <use xlink:href='#hx# x='%d' y='%d ";
char styl[] = " style='rgb(%d,%d,%d)' />\n";
for ( i=0 ; i<rng ; i++ )
{
for ( j=0 ; j<6 ; j++ )
{
for ( k=0 ; k<i ; k++ )
{
calcXY (i, j, k); // calculate the x,y position of hexagon
calcRGB (R, G, B, i, j, k, stp); // calculate the rgb colour of the hexagon
fprintf ( fp, use, hx, hy );
fprintf ( fp, styl, r, g, b );
labelHex( fp, hx, hy, r, g, b); // Label the individual hexagon with its R,G,B values
}
}
}
return 1;
}
/* * * * * * * * * * * * * * * * * * */
int drawHcmb ( FILE* fp, int W, int H, int shd, int rng, int sc )
{
fprintf ( fp, "<g id='BG' transform='rotate(0)'>\n" );
// Draw Central hexagon, centred on x=0, y=0
fprintf ( fp, " <use xlink:href='#hxg' x='0' y='0' " );
fprintf ( fp, " style='fill: rgb(%d,%d,%d);' />\n", r, g, b );
labelDec( fp, 0, 0, R, G, B); // Label the Central Hexagon
// Calculate the rgb(), and the x,y location
// for each individual hexagon
/*
for ( ring=1 ; ring<=rng ; ring++ ) // Count the 'Rings' in the Honeycomb
{
fputs ( "\n", fp );
for ( sector=0 ; sector<6 ; sector++ ) // Count the 6 Sectors in each Ring
{
for ( segmnt=0 ; segmnt<ring ; segmnt++ ) // Count the Segments within the Sector
{
calcXY (ring,sector,segmnt); // calculate the hx,hy position of hexagon
calcRGB (R,G,B,ring,sector,segmnt,stp); // calculate the rgb colour of the hexagon
fprintf ( fp, "<use xlink:href='#hxg' x='%d' y='%d' ", r, g, b );
fprintf ( fp, "style='fill: rgb(%d,%d,%d);' />\n", r, g, b );
labelHex( fp,x,y,r,g,b); // Label the individual hexagon with its R,G,B values
}
}
}
*/
doLoops ( fp, shd, rng, stp );
fprintf ( fp, "</g>\n" );
return 1;
}