module Game.Disc where
import Data.Map
import qualified Data.Map as Map
import Data.Text
import Game.Util
import Graphics.Blank
data Disc = White | Black deriving (Show, Eq, Ord)
swap :: Disc -> Disc
swap White = Black
swap Black = White
isBlack = (== Black)
isWhite = not . isBlack
drawDisc :: Double -> Disc -> Canvas ()
drawDisc radius disc = do
beginPath()
arc(0, 0, radius, 0, 2 * pi, False)
fillStyle $ pack $ clr disc
fill()
lineWidth 5
strokeStyle $ pack $ clr disc
stroke()
clr :: Disc -> String
clr Black = "#000000"
clr White = "#ffffff"
drawDiscs sz board =
sequence_ [ do save()
translate (sz / 2
+ (1.8 * sz / 9)
+ fromIntegral x * (sz / 9)
, sz / 2
+ fromIntegral y * (sz / 9))
case Map.lookup (x,y) board of
Just d -> drawDisc (sz / 32) d
Nothing -> return ()
restore()
| x <- [minX..maxX::Int]
, y <- [minY..maxY::Int]
]