/src/Line.js
import Controller from './Controller';

export default class Line extends Controller {
    constructor(appState) {
        super(appState);
        this.begin = null;
    }
    down(x, y) {
        this.begin = {x, y};
        this.state.pixelEditor.pushState();
        this.state.pixelEditor.drawPixel(x, y);
    }
    move(x, y) {
        if (this.begin) {
            this.state.pixelEditor.resetState();
            this.state.pixelEditor.setLine(this.begin.x, this.begin.y, x, y);
            this.state.pixelEditor.redraw();
            this.state.pixelEditor.refresh();
        }
    }
    up(x, y) {
        this.begin = null;
    }
}