diff options
| author | Kevin Yue <[email protected]> | 2018-08-13 00:03:09 +0800 |
|---|---|---|
| committer | Kevin Yue <[email protected]> | 2018-08-13 00:03:09 +0800 |
| commit | 1605703565046c40f3d4b5ff318ff2d5846c8685 (patch) | |
| tree | 2e5474f5f5605b618be536f161aabaf4a7821805 /lib | |
| parent | 3a4bb358614c1e1f5d73f4df45c13a1a7aa013d7 (diff) | |
| download | faker-1605703565046c40f3d4b5ff318ff2d5846c8685.tar.xz faker-1605703565046c40f3d4b5ff318ff2d5846c8685.zip | |
Make data URI text align center and middle
Diffstat (limited to 'lib')
| -rw-r--r-- | lib/image.js | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/lib/image.js b/lib/image.js index dc512a68..311acee4 100644 --- a/lib/image.js +++ b/lib/image.js @@ -201,13 +201,13 @@ var Image = function (faker) { * * @param {number} width * @param {number} height - * @method faker.image.dataurl + * @method faker.image.dataUri */ self.dataUri = function (width, height) { + 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="' + 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; |
