import { Property, Screen } from '@nativescript/core';
import { Paint } from './Paint';
const xProperty = new Property({
    name: 'x',
    valueConverter(value) {
        return parseFloat(value);
    },
});
const yProperty = new Property({
    name: 'y',
    valueConverter(value) {
        return parseFloat(value);
    },
});
const textProperty = new Property({
    name: 'text',
});
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');
        const scale = Screen.mainScreen.scale;
        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 * scale, this.y * scale);
                break;
            case 'stroke':
                context.strokeStyle = color;
                context.lineWidth = this.strokeWidth;
                context.strokeText(this.text, this.x * scale, this.y * scale);
                break;
        }
    }
}
textProperty.register(Text);
xProperty.register(Text);
yProperty.register(Text);
//# sourceMappingURL=Text.js.map