import { Property } from '@nativescript/core';
import { Paint } from '../Paint';
import { Path2D } from '../../Canvas2D';
export const p1Property = new Property({
    name: 'p1',
    valueChanged(target, oldValue, newValue) {
        target.invalidate();
    },
});
export const p2Property = new Property({
    name: 'p2',
    valueChanged(target, oldValue, newValue) {
        target.invalidate();
    },
});
export class Line extends Paint {
    draw() {
        if (this.p1 === undefined || this.p2 === undefined) {
            return;
        }
        const override_color = this.parent._overrideColor;
        const context = this._canvas.getContext('2d');
        const line = new Path2D();
        line.moveTo(this.p1.x, this.p1.y);
        line.lineTo(this.p2.x, this.p2.y);
        const color = this._getColor();
        const style = this._getPaintStyle();
        if (style === 'fill') {
            context.fillStyle = color;
            context.fill(line);
        }
        else if (style === 'stroke') {
            context.strokeStyle = color;
            context.lineWidth = this._getStrokeWidth();
            context.lineJoin = this._getStrokeJoin();
            context.stroke(line);
        }
    }
}
p1Property.register(Line);
p2Property.register(Line);
//# sourceMappingURL=Line.js.map