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

Exclude colors or hues #58

Open
breznak opened this issue Jan 19, 2016 · 5 comments
Open

Exclude colors or hues #58

breznak opened this issue Jan 19, 2016 · 5 comments

Comments

@breznak
Copy link

breznak commented Jan 19, 2016

Extend the functionality to generate N (distinct) colors with a list of excludes that must not appear among the generated set. A typical example would be "background color" and "text color" (B&W).

The excludes should be considered as a part of the colors during the generation process, so the new colors are as far as possible from each other as well from the excludes, this is done in #50

@spacedragn
Copy link

Excluding a certain hue would be a good first step. Is this currently possible?

@davidmerfield davidmerfield changed the title Allow set of exclude colors Exclude colors or hues? May 4, 2017
@davidmerfield davidmerfield changed the title Exclude colors or hues? Exclude colors or hues May 6, 2017
@JimCraane
Copy link

I prefer this option as well! Are there any plans to develop this new feature?

@armved
Copy link

armved commented Dec 5, 2018

Great idea, would be nice to have in this lib

@sarfraznawaz2005
Copy link

sarfraznawaz2005 commented Jan 14, 2019

I had problem with colors sometimes not dark enough when using dark luminosity (or colors not light enough), so I excluded specific problematic colors something like this for now:

function getColor(luminosity, seed) {
	const excludes = [
		"#b21051",
		"#78ed9f"
	];

	let color = randomColor({
		luminosity: luminosity,
		seed: seed
	});

	while (excludes.includes(color)) {
		color = randomColor({ luminosity: luminosity });
	}

	return color;
}

// use
getColor("dark", "whatever");

@davidmerfield
Copy link
Owner

I added some commentary to @Xliff's PR #119 which might be of interest to those subscribed to this issue

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

No branches or pull requests

6 participants