import { Property } from '@nativescript/core';
import { Paint } from './Paint';
const xProperty = new Property({
    name: 'x',
    valueConverter(value) {
        return parseFloat(value);
    },
    valueChanged(target, oldValue, newValue) {
        target.invalidate();
    },
});
const yProperty = new Property({
    name: 'y',
    valueConverter(value) {
        return parseFloat(value);
    },
    valueChanged(target, oldValue, newValue) {
        target.invalidate();
    },
});
const textProperty = new Property({
    name: 'text',
    valueChanged(target, oldValue, newValue) {
        target.invalidate();
    },
});
export class Text extends Paint {
    set font(value) {
        this.style.font = value;
        this._font = value;
    }
    draw() {
        if (typeof this.text !== 'string') {
            return;
        }
        const context = this._canvas.getContext('2d');
        if (typeof this._font === 'string') {
            context.font = this._font;
        }
        const style = this._getPaintStyle();
        const color = this._getColor();
        switch (style) {
            case 'fill':
                context.fillStyle = color;
                context.fillText(this.text, this.x, this.y);
                break;
            case 'stroke':
                context.strokeStyle = color;
                context.lineWidth = this._getStrokeWidth();
                context.lineJoin = this._getStrokeJoin();
                context.strokeText(this.text, this.x, this.y);
                break;
        }
    }
}
textProperty.register(Text);
xProperty.register(Text);
yProperty.register(Text);
//# sourceMappingURL=Text.js.map