-- | SVG images for each piece -- Copyright 2009 Colin Adams -- -- This file is part of chu-shogi. -- -- Chu-shogi is free software: you can redistribute it and/or modify -- it under the terms of the GNU General Public License as published by -- the Free Software Foundation, either version 3 of the License, or -- (at your option) any later version. -- Chu-shogi is distributed in the hope that it will be useful, -- but WITHOUT ANY WARRANTY; without even the implied warranty of -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -- GNU General Public License for more details. -- You should have received a copy of the GNU General Public License -- along with chu-shogi. If not, see . module SVG ( -- * Creation new_pieces, -- * Access svg_for_cell ) where import Data.Map import Graphics.Rendering.Cairo.SVG import Board import Piece -- | Create map of pieces to their SVG images new_pieces :: IO (Map Piece SVG) new_pieces = do svg_map <- svg_for_pieces return (svg_map) -- | SVG image for piece at rank and file on board svg_for_cell :: Map Piece SVG -- ^ Map of pieces to SVG images -> Board -- ^ Position being queried -> Int -- ^ Rank of square -> Int -- ^ File of square -> IO (Maybe SVG) svg_for_cell pieces board rank file = case piece_at board rank file of Nothing -> return Nothing Just (p, _) -> return (Data.Map.lookup p pieces)