Commit 1b930d39 authored by Reg Huijben's avatar Reg Huijben

added switch for north

parent 0144522e
......@@ -48,12 +48,24 @@ filteredSwitchList (t,i) = filter (\(_,_,_,active). active) (switchList (t,i))
switchList :: (Tile,Int) -> [(XYAlign,ImageOffset,Image State, Bool)]
switchList (t,i) = [
((AtMiddleX,AtTop),(px 0.0, px (0.0)), (north t i), drawNorth t ),
((AtRight,AtMiddleY),(px 0.0, px (0.0)), (east t i), drawEast t ),
((AtLeft,AtBottom),(px (half/2.0), px (0.0)),(switchIndicatorLine (-45.0)), drawSouth t && drawL t.south ),
((AtRight,AtBottom),(px (0.0-(half/2.0)),px (0.0)), (switchIndicatorLine 45.0), drawSouth t && drawR t.south),
((AtMiddleX,AtBottom),(px (0.0), px (0.0)),(switchIndicatorLine 0.0), (drawSouth t && drawM t.south)),
((AtLeft,AtBottom),(px (half/2.0), px (0.0)),(switchIndicatorLine False), drawSouth t && drawL t.south ),
((AtRight,AtBottom),(px (0.0-(half/2.0)),px (0.0)), (switchIndicatorLine True), drawSouth t && drawR t.south),
((AtMiddleX,AtBottom),(px (0.0), px (0.0)), switchIndicatorLine2 False , drawSouth t && drawM t.south),
((AtRight,AtTop),(px (0.0-(half/2.0)), px (0.0)),(switchIndicatorLine False), drawNorth t && drawL t.north ),
((AtLeft,AtTop),(px ((half/2.0)),px (0.0)), (switchIndicatorLine True), drawNorth t && drawR t.north),
((AtMiddleX,AtTop),(px (0.0), px (0.0)),(switchIndicatorLine2 False), drawNorth t && drawM t.north),
//((AtLeft,AtBottom),(px (half/2.0), px (0.0)),(switchIndicatorLine (-45.0)), drawSouth t && drawL t.south ),
//((AtRight,AtBottom),(px (0.0-(half/2.0)),px (0.0)), (switchIndicatorLine 45.0), drawSouth t && drawR t.south),
//((AtMiddleX,AtBottom),(px (0.0), px (0.0)),(switchIndicatorLine 0.0), (drawSouth t && drawM t.south)),
//((AtLeft,AtBottom),(px (half/2.0), px (0.0)),(switchIndicatorLine (-45.0)), drawSouth t && drawL t.south ),
//((AtRight,AtBottom),(px (0.0-(half/2.0)),px (0.0)), (switchIndicatorLine 45.0), drawSouth t && drawR t.south),
//((AtMiddleX,AtBottom),(px (0.0), px (0.0)),(switchIndicatorLine 0.0), (drawSouth t && drawM t.south)),
//((AtLeft,AtBottom),(px (half), px (0.0)),(line (px (0.0)) (px (half/2.0))
// <@< { stroke = toSVGColor "cyan"}
......@@ -61,8 +73,12 @@ switchList (t,i) = [
//((px 0.0, px (half - strw)), (south t i), drawEast t )
((AtMiddleX,AtTop),(px 0.0, px (0.0)), (north t i), drawNorth t ),
((AtRight,AtMiddleY),(px 0.0, px (0.0)), (east t i), drawEast t ),
((AtMiddleX,AtBottom),(px 0.0, px (0.0 )), (south t i), drawSouth t ),
((AtLeft,AtMiddleY),(px 0.0, px (0.0)), (west t i), drawWest t )
((AtLeft,AtMiddleY),(px 0.0, px (0.0)), (west t i), drawWest t )//,
// ((AtLeft, AtTop), (px 0.0, px 0.0), empty (px full) (px full) , True)
//((px 0.0, px (half - strw)), (south t i), drawWest t )
]
......@@ -76,9 +92,22 @@ drawR dir = case dir of
Right -> True
_ -> False
switchIndicatorLine degree = (rotate (Deg (45.0+degree)) (line (px (half/2.0)) (px (half/2.0))
switchIndicatorLine2 hor = if hor ln2 ln where
ln = line (px (0.0)) (px (sqrt ( ((half/2.0)^2.0)*2.0) ) )
<@< { stroke = toSVGColor "cyan"}
<@< { strokewidth = (px (strw/2.0))}
ln2 = line (px (sqrt ( ((half/2.0)^2.0)*2.0) ) ) (px (0.0))
<@< { stroke = toSVGColor "cyan"}
<@< { strokewidth = (px (strw/2.0))}
switchIndicatorLine flp = if flp (flipx ln) ln where
ln = line (px (half/2.0)) (px (half/2.0))
<@< { stroke = toSVGColor "cyan"}
<@< { strokewidth = (px (strw/2.0))}))
<@< { strokewidth = (px (strw/2.0))}
createTracksOfTile :: (Tile,Int) -> Image State
createTracksOfTile (t,i) = overlay [] offs imgs NoHost where
......@@ -151,21 +180,9 @@ south tile i = overlay [] [] [
] NoHost
nextDirS tile = case tile.south of
Blocked = if tile.sw Left (if tile.ns Middle (if tile.se Right Blocked))
Left = if tile.ns Middle (if tile.se Right Blocked)
Middle = if tile.se Right Blocked
Right = Blocked
nextDir old = case old of
Blocked = Left
Left = Middle
Middle = Right
Right = Blocked
north tile i = circle (px (strw * 2.0))
// <@< { onclick = \span s.{s & tiles = (trace "f" updateAt i {tile & south = Middle} s.tiles ) } , local = False}
<@< { onclick = \span s.{s & tiles = (updateAt i {tile & north = Middle} s.tiles ) } , local = False}
<@< { onclick = \span s.{s & tiles = (updateAt i {tile & north = nextDirN tile} s.tiles ) } , local = False}
<@< { opacity = if (drawNorth tile) (1.0) (0.0) }
<@< { strokewidth = if (drawNorth tile) (px 1.0) (px 0.0) }
<@< { fill = case tile.north of
......@@ -191,6 +208,24 @@ west tile i = circle (px (strw * 2.0))
Blocked -> toSVGColor "red"
_ -> toSVGColor "yellow" }
nextDirS tile = case tile.south of
Blocked = if tile.sw Left (if tile.ns Middle (if tile.se Right Blocked))
Left = if tile.ns Middle (if tile.se Right Blocked)
Middle = if tile.se Right Blocked
Right = Blocked
nextDirN tile = case tile.north of
Blocked = if tile.ne Left (if tile.ns Middle (if tile.nw Right Blocked))
Left = if tile.ns Middle (if tile.nw Right Blocked)
Middle = if tile.nw Right Blocked
Right = Blocked
//nextDir old = case old of
// Blocked = Left
// Left = Middle
// Middle = Right
// Right = Blocked
drawSouth :: Tile -> Bool
drawSouth t = (length (filter id [t.ns,t.se,t.sw])) >= 2
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment