Mercurial > games > semicongine
comparison semiconginev2/contrib/algorithms/texture_packing.nim @ 1234:841e12f33c47
add: text & font rendering, not tested yet
| author | sam <sam@basx.dev> |
|---|---|
| date | Sat, 20 Jul 2024 00:03:57 +0700 |
| parents | 4e465583ea32 |
| children | c15770761865 |
comparison
equal
deleted
inserted
replaced
| 1233:1cf698973dca | 1234:841e12f33c47 |
|---|---|
| 70 result.atlas = Image[T](width: maxDim, height: maxDim, data: newSeq[T](maxDim * maxDim)) | 70 result.atlas = Image[T](width: maxDim, height: maxDim, data: newSeq[T](maxDim * maxDim)) |
| 71 result.coords.setLen(images.len) | 71 result.coords.setLen(images.len) |
| 72 for rect in assignedAreas: | 72 for rect in assignedAreas: |
| 73 for y in 0 ..< rect.h: | 73 for y in 0 ..< rect.h: |
| 74 for x in 0 ..< rect.w: | 74 for x in 0 ..< rect.w: |
| 75 assert result.atlas[rect.x + x, rect.y + y] == 0, "Atlas texture packing encountered an overlap error" | 75 when T is Gray: |
| 76 assert result.atlas[rect.x + x, rect.y + y] == [0'u8], "Atlas texture packing encountered an overlap error" | |
| 77 elif T is RGBA: | |
| 78 assert result.atlas[rect.x + x, rect.y + y] == [0'u8, 0'u8, 0'u8, 0'u8], "Atlas texture packing encountered an overlap error" | |
| 79 else: | |
| 80 {.error: "Unsupported type for texture packing".} | |
| 76 result.atlas[rect.x + x, rect.y + y] = images[rect.i][x, y] | 81 result.atlas[rect.x + x, rect.y + y] = images[rect.i][x, y] |
| 77 result.coords[rect.i] = (x: rect.x, y: rect.y) | 82 result.coords[rect.i] = (x: rect.x, y: rect.y) |
