Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

how to change font color (without randomizing)? #16

Open
petkovic43 opened this issue Dec 19, 2017 · 2 comments
Open

how to change font color (without randomizing)? #16

petkovic43 opened this issue Dec 19, 2017 · 2 comments
Labels
Milestone

Comments

@petkovic43
Copy link

How to put all the characters in blue (or red) color while holding the white background?

@Leoword Leoword added this to the 2.0.0 milestone Jul 25, 2018
@Leoword
Copy link

Leoword commented Jul 25, 2018

If you don't want the randomizing font color , you can define the generate of captcha yourself in version 2.0.0

@lichaozhy lichaozhy modified the milestones: 2.0.0, 3.x Oct 27, 2018
@820465323
Copy link

可以在源码中更改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;

};`

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Development

No branches or pull requests

4 participants