import { Property } from '@nativescript/core';
import { Paint } from '../Paint';
export const xProperty = new Property({
    name: 'x',
    valueConverter(value) {
        return parseFloat(value);
    },
});
export const yProperty = new Property({
    name: 'y',
    valueConverter(value) {
        return parseFloat(value);
    },
});
export const widthProperty = new Property({
    name: 'width',
    valueConverter(value) {
        return parseFloat(value);
    },
});
export const heightProperty = new Property({
    name: 'height',
    valueConverter(value) {
        return parseFloat(value);
    },
});
export class Rect extends Paint {
    constructor() {
        super(...arguments);
        this._children = [];
    }
    draw() {
        const context = this._canvas.getContext('2d');
        context.rect(this.x, this.y, this.width, this.height);
        if (this._children.length > 0) {
            this._children.forEach((child) => {
                switch (child.paintStyle) {
                    case 'fill':
                        context.fillStyle = child.color.hex;
                        context.fill();
                        break;
                    case 'stroke':
                        context.strokeStyle = child.color.hex;
                        context.lineWidth = child.strokeWidth;
                        context.stroke();
                        break;
                }
            });
        }
        else {
            super.draw();
        }
    }
    _addViewToNativeVisualTree(view, atIndex) {
        if (view instanceof Paint) {
            this._children.push(view);
        }
        return false;
    }
}
xProperty.register(Rect);
yProperty.register(Rect);
//# sourceMappingURL=Rect.js.map