"use strict";
var __extends = (this && this.__extends) || (function () {
    var extendStatics = function (d, b) {
        extendStatics = Object.setPrototypeOf ||
            ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
            function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
        return extendStatics(d, b);
    }
    return function (d, b) {
        extendStatics(d, b);
        function __() { this.constructor = d; }
        d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
    };
})();
Object.defineProperty(exports, "__esModule", { value: true });
var React = require("react");
var ImageCanvas = (function (_super) {
    __extends(ImageCanvas, _super);
    function ImageCanvas() {
        var _this = _super !== null && _super.apply(this, arguments) || this;
        _this.canvas = null;
        _this.setup = function (node) {
            _this.canvas = node;
            _this.redraw();
        };
        return _this;
    }
    ImageCanvas.prototype.componentDidMount = function () {
        this.redraw();
    };
    ImageCanvas.prototype.componentDidUpdate = function () {
        this.redraw();
    };
    ImageCanvas.prototype.redraw = function () {
        var image = this.props.image;
        if (!this.canvas || !image)
            return;
        var width = image.width, height = image.height;
        this.canvas.width = width;
        this.canvas.height = height;
        var ctx = this.canvas.getContext('2d');
        ctx.drawImage(image, 0, 0, width, height);
    };
    ImageCanvas.prototype.render = function () {
        return React.createElement("canvas", { ref: this.setup });
    };
    return ImageCanvas;
}(React.Component));
exports.ImageCanvas = ImageCanvas;
//# sourceMappingURL=ImageCanvas.js.map