-
Notifications
You must be signed in to change notification settings - Fork 0
/
go-board.elm
48 lines (35 loc) · 1.51 KB
/
go-board.elm
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
-- Elm v0.18
-- import Html.App as Ap
import Html exposing (Html, button, div, text, beginnerProgram)
import Html.Events exposing (onClick)
import Svg exposing (svg, rect, line, circle, Svg)
import Svg.Attributes exposing ( width, height, fill, stroke, x1, x2, y1, y2, strokeWidth, cx, cy, r)
main =
beginnerProgram { model = Model [] , view = view, update = update }
type Msg = Increment | Decrement
type alias Model = { board: List Move }
type Board = List Move
type Move = Color Int Int
type Color = Black | White
update : Msg -> Model -> Model
update msg model = model
f : Int -> Int -> Svg Msg
f a b = line [ x1 (toString <| (a+1)*25 ), y1 (toString <| (b+1)*25 ), x2 (toString <| (a+19)*25 ), y2 (toString <| (b+ 1)*25 ), stroke "black" , strokeWidth "2" ] []
g : Int -> Int -> Svg Msg
g a b = line [ x1 (toString <| (a+1)*25 ), y1 (toString <| (b+1)*25 ), x2 (toString <| (a+ 1)*25 ), y2 (toString <| (b+19)*25 ), stroke "black" , strokeWidth "2" ] []
h: (Int, Int) -> Svg Msg
h (a, b) = circle [ cx ( toString <| (a+1)*25 ) , cy (toString <| (b+1)*25) , r (toString 5) ] []
view: Model -> Html Msg
view model =
div []
[ div []
[ text "Go Board"
]
, div [] [ svg [ width "500", height "500" ] <|
[ rect [ width "500", height "500", fill "#DCFFB4"] []
] ++
( List.map (\c -> f 0 c) <| List.range 0 18 ) ++
( List.map (\c -> g c 0) <| List.range 0 18 ) ++
( List.map h [ (3,3), (3,9), (3,15), (9,3), (9,9), (9,15), (15,3), (15,9), (15,15) ] )
]
]