4.11.81 • Published 10 months ago

@erboladaiorg/tenetur-molestiae-quasi v4.11.81

Weekly downloads
-
License
MIT
Repository
github
Last release
10 months ago

@erboladaiorg/tenetur-molestiae-quasi

@erboladaiorg/tenetur-molestiae-quasi is a JavaScript library designed to produce visually uniform random colors with minimal bias.

The goal of this package is to generate colors that appear evenly distributed across the color space, avoiding biases towards darker or lighter shades. Naive approaches such as choosing uniformly 0-255 values for RGB colors can lead to a dark skew due to the geometry of RGB's color space.

@erboladaiorg/tenetur-molestiae-quasi utilises the CEILAB color space. This space is chosen for its perceptual uniformity, ensuring that colors are generated in a way that provides consistent visual differentiation and keeps color skew as low as possible.

Colors are generated randomly in Lab format, and the package also offers functionality to convert these colors to more common color spaces such as RGB, enabling seamless integration into various applications and environments.

Conversion algorithms sourced from http://www.brucelindbloom.com/, and were implemented from scratch.

Installation

You can install @erboladaiorg/tenetur-molestiae-quasi via npm:

npm install @erboladaiorg/tenetur-molestiae-quasi

Usage

Generating Random Colors

const {
  randRGB,
  randRGB255,
  randLab,
  randXYZ,
} = require("@erboladaiorg/tenetur-molestiae-quasi");

// Generate a random RGB color with an array of values scaled to match the nominal 0-1 range
const randomRGB = randRGB();
console.log(randomRGB);

// Generate a random RGB color with an array of values scaled by a factor of 255
const randomRGB255 = randRGB255();
console.log(randomRGB255);

// Generate a random LAB color as an array of values, guaranteed to be in the nominal ranges
const randomLab = randLab();
console.log(randomLab);

// Generate a random XYZ color with an array of values scaled to match the nominal 0-1 range
const randomXYZ = randXYZ();
console.log(randomXYZ);

Default Export

const randomColor = require("@erboladaiorg/tenetur-molestiae-quasi");

// Default export is the same as randRGB255
const randomColor = randomColor();
console.log(randomColor);

Applying to CSS

The returned arrays can be easily used with the inbuilt CSS functions to apply the color to the webpage, along with any other use case you may have.

const Lab = randLab();
const XYZ = randXYZ(...Lab);
const RGB = randRGB255(...XYZ);

document.querySelector(
  ".Lab"
).style.backgroundColor = `lab(${Lab[0]} ${Lab[1]} ${Lab[2]})`;

document.querySelector(
  ".XYZ"
).style.backgroundColor = `color(xyz ${XYZ[0]} ${XYZ[1]} ${XYZ[2]})`;

document.querySelector(
  ".RGB"
).style.backgroundColor = `rgb(${RGB[0]} ${RGB[1]} ${RGB[2]})`;

Note:

Due to differences in color spaces, the values in XYZ and RGB may sometimes be out of their nominal range. However, they can still be displayed without issues in CSS. For example, you may get an XYZ value [-0.23, 0.47, 0.12], since you need to leave the nominal color space to reach the color given by Lab.

Testing

The package comes with a test suite. Due to the random nature of the output, and sometimes leaving the nominal range (see note above), the test suites are not terribly descriptive. Instead, however, they use a volumetric approach, trying to make sure that no outlying randomness can break it.

You can run the tests yourself in the command line by installing vitest with npm i, and running all tests with npm test

npm i
npm test

Contributing

Contributions are welcome! Feel free to open an issue or submit a pull request.

License

This project is licensed under the MIT License - see the LICENSE file for details.

writablechromiumdireventsbcryptfast-clonenested cssnativetrimLeftshebangvalidurles2017positivetypeerrorjapaneseexpressionmetadatapackage managerECMAScript 7hardlinksES3flattengetterarraytypedarraysjsdomfullwidthfile systemchineseemrES2016equalitybinaryECMAScript 5datastructurecallexpresspersistentstylexhrslicecompareECMAScript 2019has-ownstringifyautha11yregularlogcss lessECMAScript 2015dotenvastloadingbinariesvisualAsyncIteratorinterruptselbvarprocessprefixlinuxeslintpluginsymbolsrulesunicodedom-testing-librarysqsairbnbtacityupfunctionalbootstrap lessresolvecss variableArray.prototype.findLastfunction.lengthclassesmoduleFunction.prototype.nameES2017packagescharacter0cloudfrontfull-widthlasthelpercolorsgetoptstyleguidei18ninternalES2018keysuperagenthotES2023ES6less cssoperating-systemexitasyncfastreverse3dArrayBuffer#slicedescriptorCSSStyleDeclarationpostcssexecfileES7mapcollection.es6guidparsestableframerglaciershamminimalpinoobjectajaxpromisescheme-validationmacosMicrosoftreadjavascriptfindInt32Arraycallboundmakearraysnegativetelephonetyped arrayObject.fromEntriesArray.prototype.flatMapreal-timefindLastbrowserslistpostcss-pluginURLSearchParamsjson-schema-validationvestchildbrowserlist_.extendmobileform-validationes2016httpdayjsgetintrinsicfast-deep-copyfnmatchtransportapimonorepobyteOffsetspinnerremoveletparsingclass-validator__proto__writeregexpathwindowsidentifiersfastifydateWebSocketsECMAScript 2023namettydropvaluestoSortedconcatMapbuffersyntaxprivate datacertificatesprototypejestwhatwg-0global this valueArray.prototype.findLastIndexfast-deep-cloneutilityoptionsequencefsutilslruformsroute53es7zodfilterpopmotionbyteYAMLquerystringArray.prototype.containstoArrayendpoint256elmdatasnsArraydeepclonepreserve-symlinkstouchSystem.globalincludessignalmovees2015owninternal slotreact animationdragkoreancopypropertiesObject.valueshasOwnjson-schemaMapreadablestreamsetArray.prototype.filteres2018mkdirpwindowio-tsvariables in cssconsoleObject.keysconsumetddstructuredClonedescriptionmanagerglobalThisnpmignorefullonceWebSocketJSON-SchemagroupObject.entriesefficientpredictableclonees6gesturesObject.isdomReactiveExtensionscryptwafECMAScriptuploadless mixinslesscssdeep-copybabel-coreopensslbundlingcomputed-typesrecursiveiteratoraccessorworkflowpreprocessorassertsagentlistenersramdaamazonSymbolRxtoStringTagfpwarningoptimizeransiBigInt64Arraypatchshimdirectorycloudsearchcensorargvglobal objectsignalssuperstructshell[[Prototype]]fileexecute6to5
4.11.81

10 months ago

4.11.80

10 months ago

4.11.79

10 months ago

4.11.78

10 months ago

4.11.77

10 months ago

4.11.76

11 months ago

4.11.75

11 months ago

4.11.74

11 months ago

4.11.73

11 months ago

3.11.73

11 months ago

3.11.72

11 months ago

3.10.72

11 months ago

3.10.71

11 months ago

3.9.71

11 months ago

3.9.70

11 months ago

3.9.69

11 months ago

3.9.68

11 months ago

3.8.68

11 months ago

3.8.67

11 months ago

3.8.66

11 months ago

3.8.65

11 months ago

3.8.64

11 months ago

3.8.63

11 months ago

3.8.62

11 months ago

3.8.61

11 months ago

2.8.61

11 months ago

2.8.60

11 months ago

2.8.59

11 months ago

2.8.58

11 months ago

2.8.57

11 months ago

2.8.56

11 months ago

2.8.55

11 months ago

2.8.54

11 months ago

2.8.53

11 months ago

2.8.52

11 months ago

2.8.51

12 months ago

2.8.50

12 months ago

2.8.49

12 months ago

2.8.48

12 months ago

2.8.47

12 months ago

2.8.46

12 months ago

2.8.45

12 months ago

2.8.44

12 months ago

1.8.44

12 months ago

1.8.43

12 months ago

1.8.42

12 months ago

1.8.41

12 months ago

1.8.40

12 months ago

1.7.40

12 months ago

1.7.39

12 months ago

1.7.38

12 months ago

1.7.37

12 months ago

1.6.37

12 months ago

1.6.36

12 months ago

1.6.35

12 months ago

1.6.34

1 year ago

1.6.33

1 year ago

1.6.32

1 year ago

1.6.31

1 year ago

1.6.30

1 year ago

1.6.29

1 year ago

1.5.29

1 year ago

1.5.28

1 year ago

1.5.27

1 year ago

1.5.26

1 year ago

1.5.25

1 year ago

1.5.24

1 year ago

1.5.23

1 year ago

1.5.22

1 year ago

1.4.22

1 year ago

1.3.22

1 year ago

1.3.21

1 year ago

1.3.20

1 year ago

1.2.20

1 year ago

1.2.19

1 year ago

1.2.18

1 year ago

1.1.18

1 year ago

1.1.17

1 year ago

1.1.16

1 year ago

1.1.15

1 year ago

1.1.14

1 year ago

1.1.13

1 year ago

1.1.12

1 year ago

1.1.11

1 year ago

1.1.10

1 year ago

1.0.10

1 year ago

1.0.9

1 year ago

1.0.8

1 year ago

1.0.7

1 year ago

1.0.6

1 year ago

1.0.5

1 year ago

1.0.4

1 year ago

1.0.3

1 year ago

1.0.2

1 year ago

1.0.1

1 year ago

1.0.0

1 year ago