tools/hwmap.hs
changeset 10365 d5786d4230fd
parent 10335 d56b4c109abb
child 10366 b451b8f69f44
equal deleted inserted replaced
10364:9f7be3da1245 10365:d5786d4230fd
    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 $ drawnMap01
    54 mapString = B.pack . Base64.encode . BW.unpack . BL.toStrict . compressWithLength . BL.drop 8 . encode $ drawnMap02
    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
    79         , l [(1, 4), (4, 4)]
    79         , l [(1, 4), (4, 4)]
    80         , l [(2, 4), (2, 6), (1, 6), (1, 7)]
    80         , l [(2, 4), (2, 6), (1, 6), (1, 7)]
    81         , l [(0, 8), (8, 8)]
    81         , l [(0, 8), (8, 8)]
    82         ]
    82         ]
    83     l = Line Solid 0
    83     l = Line Solid 0
    84     
    84 
       
    85 drawnMap02 = translate (-3) (-3) $ sp ++ mirror sp ++ base ++ mirror base
       
    86     where
       
    87     sp = translate 128 128 . scale 256 $ [SpecialPoints [
       
    88         (7, 0)
       
    89         , (7, 7)
       
    90         ]]
       
    91     base = scale 256 $ [
       
    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)]
       
    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         ]
       
    96     l = Line Solid 0