Commit 66657756 authored by Thorsten Wißmann's avatar Thorsten Wißmann 🐧
Browse files

Improve bumpers

parent 25016869
......@@ -131,8 +131,9 @@ newCarAt flags p =
}
carConfig =
{ axisLen = 34.0
, axisWidth = 20.0
{ axisLen = 30.0
, axisWidth = 22.0
, bumperRadius = 3.0
, carWidth = 20.0
, carLen = 84.0
, selectionWidth = 31.0
......@@ -147,6 +148,8 @@ carConfig =
, speed = 330.0 -- how much distance per second
}
railconfig = RT.railconfig
carriageOffset : MovingFlags -> Float
carriageOffset car =
let
......@@ -177,6 +180,7 @@ renderCarriageAt flags attributes (a1,p1) (a2,p2) =
Just _ -> if flags.selected then identity else (::) "carError"
Nothing -> identity
join = String.concat << List.intersperse " "
in
Svg.g
(SvgAttr.class (join <| selected_class <| error_class <| ["car", flags.class])
......@@ -188,18 +192,14 @@ renderCarriageAt flags attributes (a1,p1) (a2,p2) =
, SvgAttr.ry (toString carConfig.selectionRY)
]
carConfig.selectionLen carConfig.selectionWidth car_center car_angle
, SvgUtils.svgCenteredRect
[ SvgAttr.class "carAxis"
, SvgAttr.rx (toString carConfig.axis_roundness)
, SvgAttr.ry (toString carConfig.axis_roundness)
]
carConfig.axisLen carConfig.axisWidth p1 a1
, SvgUtils.svgCenteredRect
[ SvgAttr.class "carAxis"
, SvgAttr.rx (toString carConfig.axis_roundness)
, SvgAttr.ry (toString carConfig.axis_roundness)
]
carConfig.axisLen carConfig.axisWidth p2 a2
--, SvgUtils.svgCenteredRect
-- [ SvgAttr.class "carAxis"
-- , SvgAttr.rx (toString carConfig.axis_roundness)
-- , SvgAttr.ry (toString carConfig.axis_roundness)
-- ]
-- carConfig.axisLen carConfig.axisWidth p2 a2
, renderAxis (a1,p1)
, renderAxis (180 + a2,p2)
, SvgUtils.svgCenteredRect
[ SvgAttr.class "carBody"
, SvgAttr.rx (toString carConfig.roundness_x)
......@@ -212,6 +212,42 @@ renderCarriageAt flags attributes (a1,p1) (a2,p2) =
-- , SvgUtils.svgAngledPoint <| { angle = car_angle, p = car_center }
]
renderAxis : (Float,P2D) -> Svg.Svg msg
renderAxis (angle,center) =
let
height = carConfig.axisWidth
width = carConfig.axisLen
r = carConfig.bumperRadius
transform =
"rotate("
++ (toString angle)
++ "," ++ (toString center.x)
++ "," ++ (toString center.y)
++ ")"
in
Svg.g
[ SvgAttr.transform transform
]
(Svg.rect
[ SvgAttr.width (toString width)
, SvgAttr.height (toString height)
, SvgAttr.x (toString <| center.x - width/2)
, SvgAttr.y (toString <| center.y - height/2)
, SvgAttr.class "carAxis"
, SvgAttr.rx (toString carConfig.axis_roundness)
, SvgAttr.ry (toString carConfig.axis_roundness)
] []
:: (
List.map (\(x,y) ->
Svg.circle
[ SvgAttr.cx (toString (center.x + x))
, SvgAttr.cy (toString (center.y + y))
, SvgAttr.r (toString carConfig.bumperRadius)
, SvgAttr.class "carAxis"
] [])
[ (0.5 * r-width/2,railconfig.trackW / 2)
, (0.5 * r-width/2,-railconfig.trackW / 2)
]))
renderCarriageOnPath : Float -> RT.VerifiedPath TrackA ->
List (Svg.Attribute msg) -> Carriage -> List (Svg.Svg msg)
......
Supports Markdown
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