mirror of
https://github.com/niklasvh/html2canvas.git
synced 2023-08-10 21:13:10 +03:00
Manually call toString for colors
This commit is contained in:
parent
2fb56dcee4
commit
e1936be4d4
10
dist/html2canvas.js
vendored
10
dist/html2canvas.js
vendored
@ -3149,7 +3149,7 @@ function CanvasRenderer(width, height) {
|
||||
}
|
||||
this.ctx = this.canvas.getContext("2d");
|
||||
if (this.options.background) {
|
||||
this.rectangle(0, 0, width, height, this.options.background);
|
||||
this.rectangle(0, 0, width, height, new Color(this.options.background));
|
||||
}
|
||||
this.taintCtx = this.document.createElement("canvas").getContext("2d");
|
||||
this.ctx.textBaseline = "bottom";
|
||||
@ -3160,7 +3160,7 @@ function CanvasRenderer(width, height) {
|
||||
CanvasRenderer.prototype = Object.create(Renderer.prototype);
|
||||
|
||||
CanvasRenderer.prototype.setFillStyle = function(fillStyle) {
|
||||
this.ctx.fillStyle = fillStyle;
|
||||
this.ctx.fillStyle = (fillStyle instanceof Color) ? fillStyle.toString() : fillStyle;
|
||||
return this.ctx;
|
||||
};
|
||||
|
||||
@ -3178,7 +3178,7 @@ CanvasRenderer.prototype.circle = function(left, top, size, color) {
|
||||
|
||||
CanvasRenderer.prototype.circleStroke = function(left, top, size, color, stroke, strokeColor) {
|
||||
this.circle(left, top, size, color);
|
||||
this.ctx.strokeStyle = strokeColor;
|
||||
this.ctx.strokeStyle = strokeColor.toString();
|
||||
this.ctx.stroke();
|
||||
};
|
||||
|
||||
@ -3235,7 +3235,7 @@ CanvasRenderer.prototype.font = function(color, style, variant, weight, size, fa
|
||||
};
|
||||
|
||||
CanvasRenderer.prototype.fontShadow = function(color, offsetX, offsetY, blur) {
|
||||
this.setVariable("shadowColor", color)
|
||||
this.setVariable("shadowColor", color.toString())
|
||||
.setVariable("shadowOffsetY", offsetX)
|
||||
.setVariable("shadowOffsetX", offsetY)
|
||||
.setVariable("shadowBlur", blur);
|
||||
@ -3295,7 +3295,7 @@ CanvasRenderer.prototype.renderBackgroundGradient = function(gradientImage, boun
|
||||
bounds.left + bounds.width * gradientImage.x1,
|
||||
bounds.top + bounds.height * gradientImage.y1);
|
||||
gradientImage.colorStops.forEach(function(colorStop) {
|
||||
gradient.addColorStop(colorStop.stop, colorStop.color);
|
||||
gradient.addColorStop(colorStop.stop, colorStop.color.toString());
|
||||
});
|
||||
this.rectangle(bounds.left, bounds.top, bounds.width, bounds.height, gradient);
|
||||
}
|
||||
|
4
dist/html2canvas.min.js
vendored
4
dist/html2canvas.min.js
vendored
File diff suppressed because one or more lines are too long
@ -7,7 +7,7 @@ function CanvasRenderer(width, height) {
|
||||
}
|
||||
this.ctx = this.canvas.getContext("2d");
|
||||
if (this.options.background) {
|
||||
this.rectangle(0, 0, width, height, this.options.background);
|
||||
this.rectangle(0, 0, width, height, new Color(this.options.background));
|
||||
}
|
||||
this.taintCtx = this.document.createElement("canvas").getContext("2d");
|
||||
this.ctx.textBaseline = "bottom";
|
||||
@ -18,7 +18,7 @@ function CanvasRenderer(width, height) {
|
||||
CanvasRenderer.prototype = Object.create(Renderer.prototype);
|
||||
|
||||
CanvasRenderer.prototype.setFillStyle = function(fillStyle) {
|
||||
this.ctx.fillStyle = fillStyle;
|
||||
this.ctx.fillStyle = (fillStyle instanceof Color) ? fillStyle.toString() : fillStyle;
|
||||
return this.ctx;
|
||||
};
|
||||
|
||||
@ -36,7 +36,7 @@ CanvasRenderer.prototype.circle = function(left, top, size, color) {
|
||||
|
||||
CanvasRenderer.prototype.circleStroke = function(left, top, size, color, stroke, strokeColor) {
|
||||
this.circle(left, top, size, color);
|
||||
this.ctx.strokeStyle = strokeColor;
|
||||
this.ctx.strokeStyle = strokeColor.toString();
|
||||
this.ctx.stroke();
|
||||
};
|
||||
|
||||
@ -93,7 +93,7 @@ CanvasRenderer.prototype.font = function(color, style, variant, weight, size, fa
|
||||
};
|
||||
|
||||
CanvasRenderer.prototype.fontShadow = function(color, offsetX, offsetY, blur) {
|
||||
this.setVariable("shadowColor", color)
|
||||
this.setVariable("shadowColor", color.toString())
|
||||
.setVariable("shadowOffsetY", offsetX)
|
||||
.setVariable("shadowOffsetX", offsetY)
|
||||
.setVariable("shadowBlur", blur);
|
||||
@ -153,7 +153,7 @@ CanvasRenderer.prototype.renderBackgroundGradient = function(gradientImage, boun
|
||||
bounds.left + bounds.width * gradientImage.x1,
|
||||
bounds.top + bounds.height * gradientImage.y1);
|
||||
gradientImage.colorStops.forEach(function(colorStop) {
|
||||
gradient.addColorStop(colorStop.stop, colorStop.color);
|
||||
gradient.addColorStop(colorStop.stop, colorStop.color.toString());
|
||||
});
|
||||
this.rectangle(bounds.left, bounds.top, bounds.width, bounds.height, gradient);
|
||||
}
|
||||
|
@ -72,12 +72,12 @@ describe('Text-shadow', function() {
|
||||
expect(shadows[0].offsetX).to.equal(i);
|
||||
expect(shadows[0].offsetY).to.equal(i);
|
||||
if (i < 2) {
|
||||
expect(shadows[0].color).to.match(/rgba?\(0, 0, 0(, 0)?\)/);
|
||||
expect(shadows[0].color.toString()).to.equal('rgba(0,0,0,0)');
|
||||
} else if (i % 2 === 0) {
|
||||
expect(shadows[0].color).to.equal('rgb(2, 2, 2)');
|
||||
expect(shadows[0].color.toString()).to.equal('rgb(2,2,2)');
|
||||
} else {
|
||||
var opacity = '0.2';
|
||||
expect(shadows[0].color).to.match(/rgba\(2, 2, 2, (0.2|0\.199219)\)/);
|
||||
expect(shadows[0].color.toString()).to.match(/rgba\(2,2,2,(0.2|0\.199219)\)/);
|
||||
}
|
||||
|
||||
// only testing blur once
|
||||
|
@ -4,6 +4,7 @@
|
||||
<title>Mocha Tests</title>
|
||||
<link rel="stylesheet" href="lib/mocha.css" />
|
||||
<script type="text/javascript" src="../../src/log.js"></script>
|
||||
<script type="text/javascript" src="../../src/color.js"></script>
|
||||
<script type="text/javascript" src="../../src/nodecontainer.js"></script>
|
||||
<script type="text/javascript" src="../../src/stackingcontext.js"></script>
|
||||
<script type="text/javascript" src="../../src/textcontainer.js"></script>
|
||||
|
Loading…
x
Reference in New Issue
Block a user