svg-captcha
svg-captcha copied to clipboard
how to change font color (without randomizing)?
How to put all the characters in blue (or red) color while holding the white background?
If you don't want the randomizing font color , you can define the generate of captcha yourself in version 2.0.0
可以在源码中更改lib/index.js文件中的getText方法, `const getText = function (text, width, height, options) { const len = text.length; const spacing = (width - 2) / (len + 1); const min = options.inverse ? 10 : 0; const max = options.inverse ? 14 : 4; let i = -1; const out = [];
while (++i < len) {
const x = spacing * (i + 1);
const y = height / 2;
const charPath = chToPath(text[i], Object.assign({x, y}, options));
// const color = options.color ?
// random.color(options.background) : random.greyColor(min, max);
const color = random.greyColor(min, max);//使用默认字体颜色,也可以使用random.color(options."#586069");自定义颜色
out.push(`<path fill="${color}" d="${charPath}"/>`);
}
return out;
};`