1. Andrew Godwin
  2. myne

Commits

Andrew Godwin  committed 048ff69

Full imager

  • Participants
  • Parent commits 403eba6
  • Branches default

Comments (0)

Files changed (1)

File topographer/imager.py

View file
  • Ignore whitespace
 
 # Block colours for the map, in HSV.
 BLOCK_COLOURS = {
-    BLOCK_GRASS: (133, 97, 51), 
+    BLOCK_ROCK: (0, 0, 60),
+    BLOCK_GRASS: (133, 97, 51),
+    BLOCK_DIRT: (35, 59, 46),
+    BLOCK_STONE: (0, 0, 50),
+    BLOCK_WOOD: (35, 92, 62),
+    BLOCK_PLANT: (133, 44, 70),
+    BLOCK_GROUND_ROCK: (241, 8, 20),
+    BLOCK_WATER: (215, 57, 56),
+    BLOCK_STILL_WATER: (215, 57, 56),
+    BLOCK_LAVA: (18, 100, 77),
+    BLOCK_STILL_LAVA: (215, 57, 56),
+    BLOCK_SAND: (53, 38, 76),
+    BLOCK_GRAVEL: (31, 23, 52),
+    BLOCK_GOLD_ORE: (35, 59, 46),
+    BLOCK_COPPER_ORE: (35, 59, 46),
+    BLOCK_COAL_ORE: (35, 59, 46),
+    BLOCK_LOG: (35, 79, 24),
+    BLOCK_LEAVES: (133, 44, 70),
+    BLOCK_SPONGE: (57, 100, 70),
+    BLOCK_RED_CLOTH: (0, 100, 70),
+    BLOCK_ORANGE_CLOTH: (31, 100, 70),
+    BLOCK_YELLOW_CLOTH: (57, 100, 70),
+    BLOCK_LIME_CLOTH: (84, 100, 70),
+    BLOCK_GREEN_CLOTH: (114, 100, 56),
+    BLOCK_TURQUOISE_CLOTH: (158, 100, 70),
+    BLOCK_CYAN_CLOTH: (180, 100, 70),
+    BLOCK_BLUE_CLOTH: (215, 100, 70),
+    BLOCK_INDIGO_CLOTH: (259, 100, 70),
+    BLOCK_VIOLET_CLOTH: (272, 100, 70),
+    BLOCK_PURPLE_CLOTH: (286, 100, 70),
+    BLOCK_MAGENTA_CLOTH: (307, 100, 70),
+    BLOCK_PINK_CLOTH: (325, 100, 70),
+    BLOCK_DARKGREY_CLOTH: (0, 0, 40),
+    BLOCK_GREY_CLOTH: (0, 0, 60),
+    BLOCK_WHITE_CLOTH: (0, 0, 80),
+    BLOCK_YELLOW_FLOWER: (57, 100, 70),
+    BLOCK_RED_FLOWER: (0, 100, 70),
+    BLOCK_RED_MUSHROOM: (0, 100, 70),
+    BLOCK_BROWN_MUSHROOM: (22, 61, 50),
+    BLOCK_GOLD: (57, 82, 62),
 }
 
+CHR_AIR = chr(BLOCK_AIR)
+CHR_GLASS = chr(BLOCK_GLASS)
+
 
 class Imager(object):
     
 
     def top_block(self, x, z):
         "Returns the top block in an x,z column that isn't air."
+        cur_offset = self.get_offset(x, self.y-1, z)
+        offset_jump = self.x * self.z
         for y in reversed(range(self.y)):
-            block = ord(self.blocks[self.get_offset(x, y, z)])
-            if block is not BLOCK_AIR:
-                return block, y
+            block = self.blocks[cur_offset]
+            cur_offset -= offset_jump
+            if block is not CHR_AIR and block is not CHR_GLASS:
+                return ord(block), y
+        return BLOCK_GROUND_ROCK, 0
     
     def draw_map(self, filename):
         img = Image.new("RGBA", (self.x, self.z))
             for z in range(self.z):
                 block, y = self.top_block(x, z)
                 h, s, v = BLOCK_COLOURS.get(block, (0, 0, 0))
-                v = (y / float(self.y)) * 100
+                if not (h or s or v):
+                    print block
+                v = (y / float(self.y)) * 50 + v * 0.5
                 r, g, b = colorsys.hsv_to_rgb(h/360.0, s/100.0, v/100.0)
                 #print ord(block), h, s, v, r, g, b
                 px[x, z] = (int(r*255), int(g*255), int(b*255), 255)
         print "Please provide a world folder and a filename to save to."
     else:
         Imager(sys.argv[1]).draw_map(sys.argv[2])
-        os.system("display %s" % sys.argv[2])
+        #os.system("display %s" % sys.argv[2])