import MapEditTool from './map-edit-tool';

export default class MapBrushTool extends MapEditTool {

  constructor(mapEditLayer) {
    super(mapEditLayer, `map-edit-brush`,
      'url("/static/cursor/cursor-paint.png") 0 24, default');
    this.setProp('lineWidth', 1);
  }

  override onDragStart(evt: MouseEvent) {
    if (!this.mapEditLayer) return;
    this.mapEditLayer.brushStart(evt._contentPoint);
  }

  override onDragMove(evt: MouseEvent) {
    this.mapEditLayer.brushMove(evt._contentPoint, this.getProp('lineWidth'));
  }

  override onDragEnd(evt: MouseEvent) {
    if (!this.mapEditLayer) return;
    this.mapEditLayer.brushEnd();
  }
}
