import Shape from './shape'; import { LineOptions } from '../models/painter'; class Line extends Shape { draw(): void { const { config, ctx } = this; const { x1 = 0, y1 = 0, x2 = 0, y2 = 0, type = 'line', lineWidth = 1, strokeStyle = '#333333', } = config as LineOptions; ctx.save(); ctx.beginPath(); if (type === 'dashed') { ctx.setLineDash([4, 2]); } ctx.lineWidth = lineWidth; ctx.strokeStyle = strokeStyle; ctx.beginPath(); ctx.moveTo(x1, y1); ctx.lineTo(x2, y2); ctx.stroke(); ctx.closePath(); ctx.restore(); } } export default Line;