Files
node-factorio-recipes/src/svg.ts
Sebastian Seedorf de95f57b18 Linting
2022-08-18 09:20:00 +02:00

16 lines
739 B
TypeScript

export function createPath(container: DOMRect, start: DOMRect, end: DOMRect) {
const startX = Math.round(start.x + start.width / 2 - container.x)
const startY = Math.round(start.bottom - container.y)
const endX = Math.round(end.x + end.width / 2 - container.x)
const endY = Math.round(end.top - container.y)
const mid = Math.round((start.bottom + end.top) / 2 - container.y)
return `M${startX},${startY} C${startX},${mid} ${endX},${mid} ${endX},${endY}`
}
export function drawLine(container: DOMRect, elem: DOMRect) {
const x = Math.round(elem.x + elem.width / 2 - container.x)
const top = Math.round(elem.top - container.y)
const bottom = Math.round(elem.bottom - container.y)
return `M${x},${top} L${x},${bottom}`
}