diff options
| author | Sylvain BANNIER <[email protected]> | 2016-10-04 22:25:06 +0200 |
|---|---|---|
| committer | Marak <[email protected]> | 2017-02-11 18:05:52 -0500 |
| commit | 2b0d1152b603764004fd1f0e2fbed2f30f7b7c28 (patch) | |
| tree | ec73c7ae5e1c0ec822e14fb56dd1c777cffbd8af /lib | |
| parent | 2456150e5c09a35d0336619a2696274d742ad6d4 (diff) | |
| download | faker-2b0d1152b603764004fd1f0e2fbed2f30f7b7c28.tar.xz faker-2b0d1152b603764004fd1f0e2fbed2f30f7b7c28.zip | |
#420 Added dataurl method
Diffstat (limited to 'lib')
| -rw-r--r-- | lib/image.js | 14 |
1 files changed, 13 insertions, 1 deletions
diff --git a/lib/image.js b/lib/image.js index 1c48c235..5293ba33 100644 --- a/lib/image.js +++ b/lib/image.js @@ -195,7 +195,19 @@ var Image = function (faker) { */ self.transport = function (width, height, randomize) { return faker.image.imageUrl(width, height, 'transport', randomize); - } + }; + /** + * dataurl + * + * @param {number} width + * @param {number} height + * @method faker.image.dataurl + */ + self.dataurl = function (width, height) { + 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 |
