mirror of
https://github.com/niklasvh/html2canvas.git
synced 2023-08-10 21:13:10 +03:00
49 lines
1.3 KiB
JavaScript
49 lines
1.3 KiB
JavaScript
|
function Renderer() {}
|
||
|
function NYI() {
|
||
|
return function() {
|
||
|
throw new Error("Render function not implemented");
|
||
|
};
|
||
|
}
|
||
|
|
||
|
Renderer.prototype.renderBackground = function(container, bounds) {
|
||
|
if (bounds.height > 0 && bounds.width > 0) {
|
||
|
this.renderBackgroundColor(container, bounds);
|
||
|
this.renderBackgroundImage(container, bounds);
|
||
|
}
|
||
|
};
|
||
|
|
||
|
Renderer.prototype.renderBackgroundColor = function(container, bounds) {
|
||
|
var color = container.css("backgroundColor");
|
||
|
if (!this.isTransparent(color)) {
|
||
|
this.rectangle(
|
||
|
bounds.left,
|
||
|
bounds.top,
|
||
|
bounds.width,
|
||
|
bounds.height,
|
||
|
container.css("backgroundColor")
|
||
|
);
|
||
|
}
|
||
|
};
|
||
|
|
||
|
Renderer.prototype.renderBorders = function(borders) {
|
||
|
borders.forEach(this.renderBorder, this);
|
||
|
};
|
||
|
|
||
|
Renderer.prototype.renderBorder = function(data) {
|
||
|
if (!this.isTransparent(data.color) && data.args !== null) {
|
||
|
this.drawShape(data.args, data.color);
|
||
|
}
|
||
|
};
|
||
|
|
||
|
Renderer.prototype.renderBackgroundImage = function(container, bounds) {
|
||
|
|
||
|
};
|
||
|
|
||
|
Renderer.prototype.isTransparent = function(color) {
|
||
|
return (!color || color === "transparent" || color === "rgba(0, 0, 0, 0)");
|
||
|
};
|
||
|
|
||
|
Renderer.prototype.clip = NYI();
|
||
|
Renderer.prototype.rectangle = NYI();
|
||
|
Renderer.prototype.shape = NYI();
|