Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Software
Shunting
Commits
66657756
Commit
66657756
authored
Oct 16, 2017
by
Thorsten Wißmann
🐧
Browse files
Improve bumpers
parent
25016869
Changes
1
Hide whitespace changes
Inline
Side-by-side
src/Carriage.elm
View file @
66657756
...
...
@@ -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
)
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment