2QSPJPRMJRQ65WIGWYYRGTSWCDFRWLSUPPKEJPAH25QG4MY6476AC
XO3SEH4DLXPD7V4YAHGJANXRWMCLHR7VWZJ2YAFS5335FPI2U52QC
JFVDXTQS6OZQWXXRQ3I4HC7BBFXWQUWQO56C7AXQ35PMWUQI2MKAC
F2NSN45RYCMFIJ4WVEKRTCORP2IEFSAWH3XNRAT2I55CNSBK6DUAC
PUEVD5LHJH2GUKOBNHZTGYW6YTIBZGE7AMAHPDMMGSCUQFULII2AC
ZUIY422H4XJARH5I366XA4WXHY72VFMGJJPL4T6BIXBH6OHY4USAC
5Q3SORE3SJYL2W7UQLQPK2XQAHQJ4CHN7FYJTYXDR2M7MPXEPABQC
KZKRGZBWLSKWVN6ZKDGGK6W6EAQLMSKUEJBVMMZ2UD3TZERZKS7QC
PBRYNWYOTORTAAYHMNGLU5KNAS4T5FCSEIWM656VQ7IZJ6P7NQ3QC
COS2T3FPTP6JB7UANIDCGVTW5T7HEAOSTNWI6JNVL6K3I6EOWJNQC
[ Svg.rect
[ Attr.x <| String.fromInt (i * w)
, Attr.y <| String.fromInt (j * w)
, Attr.width <| String.fromInt w
, Attr.height <| String.fromInt w
, Attr.fill <| if modBy 2 (i+j) == 1 then "lightblue" else "white"
, Events.onClick (AddQueen i j)
]
[]
[ if modBy 2 (i+j) == 1
then
loadTile "static/base.svg" w i j
else
loadTile "static/base-alternative.svg" w i j
Svg.foreignObject
[ Attr.width <| String.fromInt w
, Attr.height <| String.fromInt w
, Attr.x <| String.fromInt (i * w)
, Attr.y <| String.fromInt (j * w)
]
(
[ img
[ HAttr.width w
, HAttr.height w
, src "static/attacked.svg"
]
[]
]
)
loadTile "static/attacked.svg" w i j
queen color (i, j) = Svg.g
[]
[ Svg.foreignObject
[ Attr.width <| String.fromInt w
, Attr.height <| String.fromInt w
, Attr.x <| String.fromInt (i * w)
, Attr.y <| String.fromInt (j * w)
]
(
[ img
[ HAttr.width w
, HAttr.height w
, src "static/queen.svg"
]
[]
]
)
, Svg.rect
[ Attr.x <| String.fromInt (i * w)
, Attr.y <| String.fromInt (j * w)
, Attr.width <| String.fromInt w
, Attr.height <| String.fromInt w
, Attr.fillOpacity "0.0"
, Attr.stroke color
, Events.onClick (RemoveQueen i j)
]
[]
]
++ (List.map (queen "red") <| Set.toList model.fixedQueens)
++ (List.map (queen "none") <| Set.toList model.solutionQueens)
++ (List.map (loadQueen Fixed w) <| Set.toList model.fixedQueens)
++ (List.map (loadQueen Auto w) <| Set.toList model.solutionQueens)
loadTile : String -> Int -> Int -> Int -> Svg.Svg Msg
loadTile path size i j =
Svg.foreignObject
[ Attr.width <| String.fromInt size
, Attr.height <| String.fromInt size
, Attr.x <| String.fromInt (i * size)
, Attr.y <| String.fromInt (j * size)
, Events.onClick <| AddQueen i j
]
(
[ loadSVG path size ]
)
loadSVG : String -> Int -> Html Msg
loadSVG path size =
img
[ HAttr.width size
, HAttr.height size
, src path
] []
loadQueen : QueenVariant -> Int -> (Int, Int) -> Svg.Svg Msg
loadQueen variant size (i, j) = Svg.g
[]
[ Svg.foreignObject
[ Attr.width <| String.fromInt size
, Attr.height <| String.fromInt size
, Attr.x <| String.fromInt (i * size)
, Attr.y <| String.fromInt (j * size)
]
(
[ img
[ HAttr.width size
, HAttr.height size
, src <| variantPath variant
]
[]
]
)
, Svg.rect
[ Attr.x <| String.fromInt (i * size)
, Attr.y <| String.fromInt (j * size)
, Attr.width <| String.fromInt size
, Attr.height <| String.fromInt size
, Attr.fillOpacity "0.0"
, Events.onClick (RemoveQueen i j)
]
[]
]
variantPath : QueenVariant -> String
variantPath variant = case variant of
Fixed -> "static/fixed-queen.svg"
Auto -> "static/queen.svg"