aboutsummaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorMarak <[email protected]>2018-09-24 11:38:25 -0400
committerGitHub <[email protected]>2018-09-24 11:38:25 -0400
commit948d0dac5aae515739e3b5fa5b6a64f69aebaa00 (patch)
tree8824c6e7b2f60880f99fd2a5eb0b1e62f09a55bb /lib
parentfb1f21e448f74408fa9133c5e4b26e23dc91cdd3 (diff)
parenta3a4f62f8d1185c9b6113d057bbb2e47f9b89913 (diff)
downloadfaker-948d0dac5aae515739e3b5fa5b6a64f69aebaa00.tar.xz
faker-948d0dac5aae515739e3b5fa5b6a64f69aebaa00.zip
Merge pull request #682 from yuezk/master
Add background color to `image.dataUri`
Diffstat (limited to 'lib')
-rw-r--r--lib/image.js10
1 files changed, 6 insertions, 4 deletions
diff --git a/lib/image.js b/lib/image.js
index dc512a68..b25b5895 100644
--- a/lib/image.js
+++ b/lib/image.js
@@ -201,13 +201,15 @@ var Image = function (faker) {
*
* @param {number} width
* @param {number} height
- * @method faker.image.dataurl
+ * @param {string} color
+ * @method faker.image.dataUri
*/
- self.dataUri = function (width, height) {
+ self.dataUri = function (width, height, color) {
+ color = color || 'grey';
+ var svgString = '<svg xmlns="http://www.w3.org/2000/svg" version="1.1" baseProfile="full" width="' + width + '" height="' + height + '"><rect width="100%" height="100%" fill="' + color + '"/><text x="' + width / 2 + '" y="' + height / 2 + '" font-size="20" alignment-baseline="middle" text-anchor="middle" fill="white">' + width + 'x' + height + '</text></svg>';
var rawPrefix = 'data:image/svg+xml;charset=UTF-8,';
- var svgString = '<svg xmlns="http://www.w3.org/2000/svg" version="1.1" baseProfile="full" width="' + width + '" height="' + height + '"> <rect width="100%" height="100%" fill="grey"/> <text x="0" y="20" font-size="20" text-anchor="start" fill="white">' + width + 'x' + height + '</text> </svg>';
return rawPrefix + encodeURIComponent(svgString);
};
}
-module["exports"] = Image; \ No newline at end of file
+module["exports"] = Image;