summaryrefslogtreecommitdiff
path: root/opendc-web/opendc-web-ui/src/components/app/map/elements/TilePlusIcon.js
blob: 186c2b3a4e39f6c458150fa085da8b4d3e62a86c (plain)
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
import PropTypes from 'prop-types'
import React from 'react'
import { Group, Line } from 'react-konva'
import { TILE_PLUS_COLOR } from '../../../../util/colors'
import { TILE_PLUS_MARGIN_IN_PIXELS, TILE_PLUS_WIDTH_IN_PIXELS, TILE_SIZE_IN_PIXELS } from '../MapConstants'

function TilePlusIcon({ x, y, scale = 1 }) {
    const linePoints = [
        [
            x + 0.5 * TILE_SIZE_IN_PIXELS * scale,
            y + TILE_PLUS_MARGIN_IN_PIXELS * scale,
            x + 0.5 * TILE_SIZE_IN_PIXELS * scale,
            y + TILE_SIZE_IN_PIXELS * scale - TILE_PLUS_MARGIN_IN_PIXELS * scale,
        ],
        [
            x + TILE_PLUS_MARGIN_IN_PIXELS * scale,
            y + 0.5 * TILE_SIZE_IN_PIXELS * scale,
            x + TILE_SIZE_IN_PIXELS * scale - TILE_PLUS_MARGIN_IN_PIXELS * scale,
            y + 0.5 * TILE_SIZE_IN_PIXELS * scale,
        ],
    ]
    return (
        <Group>
            {linePoints.map((points, index) => (
                <Line
                    key={index}
                    points={points}
                    lineCap="round"
                    stroke={TILE_PLUS_COLOR}
                    strokeWidth={TILE_PLUS_WIDTH_IN_PIXELS * scale}
                    listening={false}
                />
            ))}
        </Group>
    )
}

TilePlusIcon.propTypes = {
    x: PropTypes.number,
    y: PropTypes.number,
    scale: PropTypes.number,
}

export default TilePlusIcon