From 8ceef99f0702851f6519a07a4a272f902204e472 Mon Sep 17 00:00:00 2001 From: Mike Buland Date: Wed, 8 Apr 2015 09:23:03 -0600 Subject: It now produces one image with titles and stuff. --- src/renderpng.cpp | 45 ++++++++++++++++++++++++++++++++------------- 1 file changed, 32 insertions(+), 13 deletions(-) diff --git a/src/renderpng.cpp b/src/renderpng.cpp index 6ff9fbe..f452c07 100644 --- a/src/renderpng.cpp +++ b/src/renderpng.cpp @@ -30,9 +30,24 @@ void RenderPng::render() iSize = (int)ceil(sqrt((rMap.getDims()-2)*2)); int iCellSize = 11; + int iFloorSpacing = 15; int iCellMid = iCellSize/2; int iBufWidth = ((iSize+1)*rMap.getSize( 0 )+1)*iCellSize; int iBufHeight = ((iSize+1)*rMap.getSize( 1 )+1)*iCellSize+12; + int iFloorWidth = iBufWidth; + int iFloorHeight = iBufHeight; + + int *aiPixDims = new int[iDims]; + aiPixDims[0] = iBufHeight+iFloorSpacing; + aiPixDims[1] = iBufWidth+iFloorSpacing; + + for( int j = 2; j < iDims; j++ ) + { + if( j%2 == 0 ) + aiPixDims[j] = iBufHeight = rMap.getSize( j )*(iBufHeight+iFloorSpacing); + else + aiPixDims[j] = iBufWidth = rMap.getSize( j )*(iBufWidth+iFloorSpacing); + } int ox = 0; int oy = 12; Image im( iBufWidth, iBufHeight ); @@ -48,7 +63,7 @@ void RenderPng::render() int x = p[0]*(iSize+1); int y = p[1]*(iSize+1); int iWalls = rMap[p].iWalls; - + for( int iRow = 0; iRow < iSize+2; iRow++ ) { for( int iCol = 0; iCol < iSize+2; iCol++ ) @@ -274,7 +289,6 @@ void RenderPng::render() } int iDim; - char fname[1024]; char title[1024]; for( iDim = 0; iDim < iDims; iDim++ ) { @@ -283,35 +297,38 @@ void RenderPng::render() p[iDim] = 0; if( iDim == 1 ) { - strcpy(fname, "floor"); if( iDims > 2 ) { char buf[1024]; - sprintf( buf, "-%d", rMap.getSize(2)-p[2] ); - strcat( fname, buf ); sprintf( buf, "Floor: %d", rMap.getSize(2)-p[2] ); strcpy( title, buf ); for( int j = 3; j < iDims; j++ ) { - sprintf( buf, "-%d", rMap.getSize(j)-p[j] ); - strcat( fname, buf ); sprintf( buf, ", %d", rMap.getSize(j)-p[j] ); strcat( title, buf ); } } else title[0] = '\0'; + printf("Completed %s\n", title ); im.drawText( fnt, ox, oy-2, 0, title ); - strcat( fname, ".png"); - printf("Output: %s\n", fname ); - - im.save( fname, pal ); - - im.clear( 1 ); } } if( iDim == iDims ) break; + else if( iDim >= 2 ) + { + ox = oy = 0; + for( int j = 2; j < iDims; j++ ) + { + if( j%2 == 0 ) + oy += p[j]*aiPixDims[j-2]; + else + ox += p[j]*aiPixDims[j-2]; + } + oy += 12; + } + /* for( int j = 2; j < iDims; j++ ) { @@ -330,6 +347,8 @@ void RenderPng::render() */ } // printf(buf); + im.save("lost.png", pal ); + delete[] aiPixDims; } -- cgit v1.2.3