import { Property } from '@nativescript/core';
import { Paint } from '../Paint';
const imageProperty = new Property({
    name: 'image',
    valueChanged(target, oldValue, newValue) {
        target.invalidate();
    },
});
const spritesProperty = new Property({
    name: 'sprites',
    valueChanged(target, oldValue, newValue) {
        target.invalidate();
    },
});
const transformsProperty = new Property({
    name: 'transforms',
    valueChanged(target, oldValue, newValue) {
        target.invalidate();
    },
});
const colorsProperty = new Property({
    name: 'colors',
    valueChanged(target, oldValue, newValue) {
        target.invalidate();
    },
});
const blendModeProperty = new Property({
    name: 'blendMode',
    defaultValue: 'destination-over',
    valueChanged(target, oldValue, newValue) {
        target.invalidate();
    },
});
export class Atlas extends Paint {
    constructor() {
        super(...arguments);
        this._children = [];
    }
    draw() {
        const context = this._canvas.getContext('2d');
        context.drawAtlas(this.image, this.transforms, this.sprites, this.colors ?? null, this.blendMode);
    }
    _addViewToNativeVisualTree(view, atIndex) {
        if (view === this._canvas) {
            this.nativeView.addView(this._canvas.nativeView);
            return true;
        }
        else if (view instanceof Paint) {
            view._canvas = this._canvas;
            this._children.push(view);
        }
        return false;
    }
}
imageProperty.register(Atlas);
spritesProperty.register(Atlas);
transformsProperty.register(Atlas);
colorsProperty.register(Atlas);
blendModeProperty.register(Atlas);
//# sourceMappingURL=Atlas.js.map