-
Notifications
You must be signed in to change notification settings - Fork 3
/
RoadMarking.tsx
50 lines (48 loc) · 1.05 KB
/
RoadMarking.tsx
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
49
50
import { Line } from "react-konva";
import React from "react";
import { RoadMarkingProps } from "./RoadMarking.types";
const RoadMarking = (
{
points,
dash = [],
width = 0.15,
type = "single",
color = "#ffffff"
}: RoadMarkingProps,
key: React.Key
) => {
switch (type) {
case "double":
// plot symmetrical double lines
return (
<>
<Line
key={key}
strokeWidth={width * 2.5}
dash={dash}
stroke={color}
points={points}
/>
<Line
key={`${key}_cutout`}
strokeWidth={width * 0.5}
stroke={color}
globalCompositeOperation="destination-out"
points={points}
/>
</>
);
case "single":
// plot any of the single lines (single, broken, dotted)
return (
<Line
key={key}
strokeWidth={width}
stroke={color}
dash={dash}
points={points}
/>
);
}
};
export default RoadMarking;