diff options
author | Mike Buland <mike@xagasoft.com> | 2015-04-08 09:23:03 -0600 |
---|---|---|
committer | Mike Buland <mike@xagasoft.com> | 2015-04-08 09:23:03 -0600 |
commit | 8ceef99f0702851f6519a07a4a272f902204e472 (patch) | |
tree | c284768409ce85a45094389b4956107e43fa92a9 | |
parent | f314041b6b37bb9274d9fc79946858341befa0f2 (diff) | |
download | lost-8ceef99f0702851f6519a07a4a272f902204e472.tar.gz lost-8ceef99f0702851f6519a07a4a272f902204e472.tar.bz2 lost-8ceef99f0702851f6519a07a4a272f902204e472.tar.xz lost-8ceef99f0702851f6519a07a4a272f902204e472.zip |
It now produces one image with titles and stuff.
-rw-r--r-- | src/renderpng.cpp | 45 |
1 files 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() | |||
30 | iSize = (int)ceil(sqrt((rMap.getDims()-2)*2)); | 30 | iSize = (int)ceil(sqrt((rMap.getDims()-2)*2)); |
31 | 31 | ||
32 | int iCellSize = 11; | 32 | int iCellSize = 11; |
33 | int iFloorSpacing = 15; | ||
33 | int iCellMid = iCellSize/2; | 34 | int iCellMid = iCellSize/2; |
34 | int iBufWidth = ((iSize+1)*rMap.getSize( 0 )+1)*iCellSize; | 35 | int iBufWidth = ((iSize+1)*rMap.getSize( 0 )+1)*iCellSize; |
35 | int iBufHeight = ((iSize+1)*rMap.getSize( 1 )+1)*iCellSize+12; | 36 | int iBufHeight = ((iSize+1)*rMap.getSize( 1 )+1)*iCellSize+12; |
37 | int iFloorWidth = iBufWidth; | ||
38 | int iFloorHeight = iBufHeight; | ||
39 | |||
40 | int *aiPixDims = new int[iDims]; | ||
41 | aiPixDims[0] = iBufHeight+iFloorSpacing; | ||
42 | aiPixDims[1] = iBufWidth+iFloorSpacing; | ||
43 | |||
44 | for( int j = 2; j < iDims; j++ ) | ||
45 | { | ||
46 | if( j%2 == 0 ) | ||
47 | aiPixDims[j] = iBufHeight = rMap.getSize( j )*(iBufHeight+iFloorSpacing); | ||
48 | else | ||
49 | aiPixDims[j] = iBufWidth = rMap.getSize( j )*(iBufWidth+iFloorSpacing); | ||
50 | } | ||
36 | int ox = 0; | 51 | int ox = 0; |
37 | int oy = 12; | 52 | int oy = 12; |
38 | Image im( iBufWidth, iBufHeight ); | 53 | Image im( iBufWidth, iBufHeight ); |
@@ -48,7 +63,7 @@ void RenderPng::render() | |||
48 | int x = p[0]*(iSize+1); | 63 | int x = p[0]*(iSize+1); |
49 | int y = p[1]*(iSize+1); | 64 | int y = p[1]*(iSize+1); |
50 | int iWalls = rMap[p].iWalls; | 65 | int iWalls = rMap[p].iWalls; |
51 | 66 | ||
52 | for( int iRow = 0; iRow < iSize+2; iRow++ ) | 67 | for( int iRow = 0; iRow < iSize+2; iRow++ ) |
53 | { | 68 | { |
54 | for( int iCol = 0; iCol < iSize+2; iCol++ ) | 69 | for( int iCol = 0; iCol < iSize+2; iCol++ ) |
@@ -274,7 +289,6 @@ void RenderPng::render() | |||
274 | } | 289 | } |
275 | 290 | ||
276 | int iDim; | 291 | int iDim; |
277 | char fname[1024]; | ||
278 | char title[1024]; | 292 | char title[1024]; |
279 | for( iDim = 0; iDim < iDims; iDim++ ) | 293 | for( iDim = 0; iDim < iDims; iDim++ ) |
280 | { | 294 | { |
@@ -283,35 +297,38 @@ void RenderPng::render() | |||
283 | p[iDim] = 0; | 297 | p[iDim] = 0; |
284 | if( iDim == 1 ) | 298 | if( iDim == 1 ) |
285 | { | 299 | { |
286 | strcpy(fname, "floor"); | ||
287 | if( iDims > 2 ) | 300 | if( iDims > 2 ) |
288 | { | 301 | { |
289 | char buf[1024]; | 302 | char buf[1024]; |
290 | sprintf( buf, "-%d", rMap.getSize(2)-p[2] ); | ||
291 | strcat( fname, buf ); | ||
292 | sprintf( buf, "Floor: %d", rMap.getSize(2)-p[2] ); | 303 | sprintf( buf, "Floor: %d", rMap.getSize(2)-p[2] ); |
293 | strcpy( title, buf ); | 304 | strcpy( title, buf ); |
294 | for( int j = 3; j < iDims; j++ ) | 305 | for( int j = 3; j < iDims; j++ ) |
295 | { | 306 | { |
296 | sprintf( buf, "-%d", rMap.getSize(j)-p[j] ); | ||
297 | strcat( fname, buf ); | ||
298 | sprintf( buf, ", %d", rMap.getSize(j)-p[j] ); | 307 | sprintf( buf, ", %d", rMap.getSize(j)-p[j] ); |
299 | strcat( title, buf ); | 308 | strcat( title, buf ); |
300 | } | 309 | } |
301 | } | 310 | } |
302 | else | 311 | else |
303 | title[0] = '\0'; | 312 | title[0] = '\0'; |
313 | printf("Completed %s\n", title ); | ||
304 | im.drawText( fnt, ox, oy-2, 0, title ); | 314 | im.drawText( fnt, ox, oy-2, 0, title ); |
305 | strcat( fname, ".png"); | ||
306 | printf("Output: %s\n", fname ); | ||
307 | |||
308 | im.save( fname, pal ); | ||
309 | |||
310 | im.clear( 1 ); | ||
311 | } | 315 | } |
312 | } | 316 | } |
313 | if( iDim == iDims ) | 317 | if( iDim == iDims ) |
314 | break; | 318 | break; |
319 | else if( iDim >= 2 ) | ||
320 | { | ||
321 | ox = oy = 0; | ||
322 | for( int j = 2; j < iDims; j++ ) | ||
323 | { | ||
324 | if( j%2 == 0 ) | ||
325 | oy += p[j]*aiPixDims[j-2]; | ||
326 | else | ||
327 | ox += p[j]*aiPixDims[j-2]; | ||
328 | } | ||
329 | oy += 12; | ||
330 | } | ||
331 | |||
315 | /* | 332 | /* |
316 | for( int j = 2; j < iDims; j++ ) | 333 | for( int j = 2; j < iDims; j++ ) |
317 | { | 334 | { |
@@ -330,6 +347,8 @@ void RenderPng::render() | |||
330 | */ | 347 | */ |
331 | } | 348 | } |
332 | // printf(buf); | 349 | // printf(buf); |
350 | im.save("lost.png", pal ); | ||
333 | 351 | ||
352 | delete[] aiPixDims; | ||
334 | } | 353 | } |
335 | 354 | ||