Sorry, I'm new to coding and am struggling on something I believe is quite basic.
I want to draw a shape via multiple konva line objects. Once I've created a line, instead of manually calculating where the next line should begin, I'm thinking there has to be a way of grabbing the ending position of the last line and setting that as the beginning point of the new line.
As you can see below. I've been calculating the beginning values manually.
import React, { Component } from "react";
import Konva from "konva";
import { Stage, Layer, Rect, Text, Circle, Line, Group } from "react-konva";
class Perimeter extends Component {
render() {
return (
<Stage width={window.innerWidth} height={window.innerHeight}>
<Layer>
<Group>
<Line
ref="topBar"
x={450}
y={150}
points={[0, 0, 575, 0, 0, 0]}
stroke="blue"
strokeWidth={4}
/>
<Line
x={450}
y={150}
points={[0, 0, 0, 350, 0, 0]}
stroke="blue"
strokeWidth={4}
/>
<Line
x={1025}
y={150}
points={[0, 0, 0, 400, 0, 0]}
stroke="blue"
strokeWidth={4}
/>
<Line
x={450}
y={500}
points={[0, 0, 150, 0, 0, 0]}
stroke="blue"
strokeWidth={4}
/>
<Line
x={600}
y={500}
points={[0, 0, 0, 100, 0, 0]}
stroke="blue"
strokeWidth={4}
/>
<Line
x={675}
y={550}
points={[0, 0, 0, 0, 350, 0]}
stroke="blue"
strokeWidth={4}
/>
<Line
x={675}
y={550}
points={[0, 50, 0, 0, 0, 0]}
stroke="blue"
strokeWidth={4}
/>
</Group>
</Layer>
</Stage>
);
}
}
export default Perimeter;