"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); var validator_1 = require("../../utils/validator"); var Synthetizer = (function () { function Synthetizer() { } Synthetizer.prototype.rasterize = function (target, markerImage, done) { if (!validator_1.isHTMLImageElement(target)) { throw new Error('Error: only support export to HTMLImageElement'); } var canvas = document.createElement('canvas'); canvas.width = markerImage.width.baseVal.value; canvas.height = markerImage.height.baseVal.value; var data = markerImage.outerHTML; var ctx = canvas.getContext('2d'); if (!ctx) { throw new Error('Invalid ctx'); } ctx.drawImage(target, 0, 0, canvas.width, canvas.height); var DOMURL = window.URL; var img = new Image(canvas.width, canvas.height); img.setAttribute('crossOrigin', 'anonymous'); var blob = new Blob([data], { type: 'image/svg+xml' }); var url = DOMURL.createObjectURL(blob); img.onload = function () { ctx.drawImage(img, 0, 0); DOMURL.revokeObjectURL(url); done(canvas.toDataURL('image/png')); }; img.src = url; }; return Synthetizer; }()); exports.Synthetizer = Synthetizer;