tools/hwmap.hs
changeset 10366 b451b8f69f44
parent 10365 d5786d4230fd
child 10369 5adc765da26b
equal deleted inserted replaced
10365:d5786d4230fd 10366:b451b8f69f44
    49 compressWithLength b = BL.drop 8 . encode . runPut $ do
    49 compressWithLength b = BL.drop 8 . encode . runPut $ do
    50     put $ ((fromIntegral $ BL.length b)::Word32)
    50     put $ ((fromIntegral $ BL.length b)::Word32)
    51     mapM_ putWord8 $ BW.unpack $ BL.toStrict $ Z.compress b
    51     mapM_ putWord8 $ BW.unpack $ BL.toStrict $ Z.compress b
    52 
    52 
    53 mapString :: B.ByteString
    53 mapString :: B.ByteString
    54 mapString = B.pack . Base64.encode . BW.unpack . BL.toStrict . compressWithLength . BL.drop 8 . encode $ drawnMap02
    54 mapString = B.pack . Base64.encode . BW.unpack . BL.toStrict . compressWithLength . BL.drop 8 . encode $ drawnMap03
    55 
    55 
    56 main = B.writeFile "out.hwmap" mapString
    56 main = B.writeFile "out.hwmap" mapString
    57 
    57 
    58 drawnMap01 = translate (-3) (-3) $ sp ++ mirror sp ++ base ++ mirror base
    58 drawnMap01 = translate (-3) (-3) $ sp ++ mirror sp ++ base ++ mirror base
    59     where
    59     where
    92         l [(8, 0), (8, 1), (1, 1)]
    92         l [(8, 0), (8, 1), (1, 1)]
    93         , l [(2, 1), (2, 2), (3, 2), (3, 3), (4, 3), (4, 4), (5, 4), (5, 5), (6, 5), (6, 6), (7, 6), (7, 7), (7, 1)]
    93         , l [(2, 1), (2, 2), (3, 2), (3, 3), (4, 3), (4, 4), (5, 4), (5, 5), (6, 5), (6, 6), (7, 6), (7, 7), (7, 1)]
    94         , l [(0, 2), (1, 2), (1, 3), (2, 3), (2, 4), (3, 4), (3, 5), (4, 5), (4, 6), (5, 6), (5, 7), (6, 7), (6, 8), (8, 8), (8, 2)]
    94         , l [(0, 2), (1, 2), (1, 3), (2, 3), (2, 4), (3, 4), (3, 5), (4, 5), (4, 6), (5, 6), (5, 7), (6, 7), (6, 8), (8, 8), (8, 2)]
    95         ]
    95         ]
    96     l = Line Solid 0
    96     l = Line Solid 0
       
    97 
       
    98 
       
    99 drawnMap03 = translate (-3) (-3) $ sp ++ mirror sp ++ base ++ mirror base
       
   100     where
       
   101     sp = translate 128 128 . scale 256 $ [SpecialPoints [
       
   102         (3, 1)
       
   103         , (2, 4)
       
   104         ]]
       
   105     base = scale 256 $ [
       
   106         l [(6, 0), (6, 1)]
       
   107         , l [(1, 1), (5, 1)]
       
   108         , l [(4, 1), (4, 2), (3, 2)]
       
   109         , l [(0, 2), (1, 2), (1, 4)]
       
   110         , l [(0, 4), (3, 4), (3, 3), (5, 3), (5, 2), (7, 2)]
       
   111         , l [(7, 1), (7, 3)]
       
   112         , l [(8, 0), (8, 4), (4, 4), (4, 5), (1, 5), (1, 6)]
       
   113         , l [(6, 3), (6, 4)]
       
   114         , l [(0, 8), (8, 8)]
       
   115         , l [(1, 7), (1, 8)]
       
   116         , l [(2, 7), (2, 5)]
       
   117         , l [(3, 6), (3, 5)]
       
   118         , l [(3, 7), (3, 8)]
       
   119         , l [(4, 6), (4, 8)]
       
   120         , l [(5, 4), (5, 6)]
       
   121         , l [(5, 7), (5, 8)]
       
   122         , l [(6, 5), (6, 8)]
       
   123         , l [(7, 4), (7, 6)]
       
   124         , l [(7, 7), (7, 8)]
       
   125         , l [(8, 5), (8, 8)]
       
   126         ]
       
   127     l = Line Solid 0