import { Stage } from 'konva/lib/Stage';
import { Layer } from 'konva/lib/Layer';
import Konva from 'konva/lib';

export const drawLine = (stage: Stage, layer: Layer) => {
	const xSnaps = Math.round(stage.width() / 50);
	const ySnaps = Math.round(stage.height() / 50);
	const cellWidth = stage.width() / xSnaps;
	const cellHeight = stage.height() / ySnaps;

	for (let i = 0; i < xSnaps; i++) {
		const xLine = new Konva.Line({
			x: i * cellWidth,
			points: [0, 0, 0, stage.height()],
			stroke: '#96e04d',
			strokeWidth: 1,
			id: 'line',
		});
		layer.add(xLine);
	}

	for (let i = 0; i < ySnaps; i++) {
		layer.add(
			new Konva.Line({
				y: i * cellHeight,
				points: [0, 0, stage.width(), 0],
				stroke: '#96e04d',
				strokeWidth: 1,
				id: 'line',
			}),
		);
	}
};
