{"id":16731418,"url":"https://github.com/skratchdot/color-stats","last_synced_at":"2025-04-10T11:23:55.740Z","repository":{"id":18038911,"uuid":"21082243","full_name":"skratchdot/color-stats","owner":"skratchdot","description":"Generate color information based off of the hash of any object (or a valid color string)","archived":false,"fork":false,"pushed_at":"2016-09-04T00:30:30.000Z","size":18,"stargazers_count":7,"open_issues_count":0,"forks_count":1,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-03-20T20:16:47.124Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/skratchdot.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE-MIT","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2014-06-22T00:52:40.000Z","updated_at":"2022-10-17T18:11:51.000Z","dependencies_parsed_at":"2022-08-25T15:02:51.651Z","dependency_job_id":null,"html_url":"https://github.com/skratchdot/color-stats","commit_stats":null,"previous_names":[],"tags_count":7,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/skratchdot%2Fcolor-stats","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/skratchdot%2Fcolor-stats/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/skratchdot%2Fcolor-stats/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/skratchdot%2Fcolor-stats/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/skratchdot","download_url":"https://codeload.github.com/skratchdot/color-stats/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248208612,"owners_count":21065203,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-10-12T23:37:02.779Z","updated_at":"2025-04-10T11:23:55.708Z","avatar_url":"https://github.com/skratchdot.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# color-stats\n\n[![NPM version](https://badge.fury.io/js/color-stats.svg)](http://badge.fury.io/js/color-stats)\n[![Build Status](https://travis-ci.org/skratchdot/color-stats.png?branch=master)](https://travis-ci.org/skratchdot/color-stats)\n[![Code Climate](https://codeclimate.com/github/skratchdot/color-stats.png)](https://codeclimate.com/github/skratchdot/color-stats)\n[![Coverage Status](https://coveralls.io/repos/skratchdot/color-stats/badge.png)](https://coveralls.io/r/skratchdot/color-stats)\n[![Dependency Status](https://david-dm.org/skratchdot/color-stats.svg)](https://david-dm.org/skratchdot/color-stats)\n[![devDependency Status](https://david-dm.org/skratchdot/color-stats/dev-status.svg)](https://david-dm.org/skratchdot/color-stats#info=devDependencies)\n\n[![NPM](https://nodei.co/npm/color-stats.png)](https://npmjs.org/package/color-stats)\n\n\n## Description\n\nGenerate color information based off of the hash of any object.  If you pass in a valid\ncolor name or css value, the information for that color will be returned.\n\n\n## Getting Started\n\nInstall the module with: `npm install color-stats`\n\n```javascript\nvar colorStats = require('color-stats');\ncolorStats('red'); // get a bunch of stats about the color red\ncolorStats('#ff0000'); // get a bunch of stats about the color red\ncolorStats({info:\"Based On Hash - always the same color\"}); // get a color based on some object.\ncolorStats.random(); // get the stats for a random color\n```\n\n\n## Documentation\n\n#### colorStats(colorObject)\n\nPass in a color string (or any object), and get the stats for that object.\n\n#### colorStats.parse(colorObject)\n\nThis is the same as calling colorStats(colorObject).  It's just a proxy for\npeople that like explicit function names.\n\n#### colorStats.random()\n\nReturns the stats for a random color.\n\n\n## Example\n\n#### Get Stats function call:\n```javascript\nvar colorStats = require('color-stats');\nvar result = colorStats('#4682b4'); // see result output below\n```\n\n#### Get Stats Result:\n```javascript\n{\n  \"lib\": {\n    \"onecolor\": {\n      \"red\": 0.27450980392156865,\n      \"green\": 0.5098039215686274,\n      \"blue\": 0.7058823529411765,\n      \"alpha\": 1,\n      \"hue\": 0.5757575757575757,\n      \"saturation\": 0.611111111111111,\n      \"value\": 0.7058823529411765,\n      \"lightness\": 0.4901960784313726,\n      \"cyan\": 0.611111111111111,\n      \"magenta\": 0.2777777777777779,\n      \"yellow\": 0,\n      \"black\": 0.2941176470588235,\n      \"x\": 0.18743597342600288,\n      \"y\": 0.2056088063416628,\n      \"z\": 0.46152037838994725,\n      \"l\": 1,\n      \"a\": 1,\n      \"b\": 0.7058823529411765,\n      \"hex\": \"#4682b4\",\n      \"hexa\": \"#ff4682b4\",\n      \"css\": \"rgb(70,130,180)\",\n      \"cssa\": \"rgba(70,130,180,1)\",\n      \"cmyk\": [\n        \"CMYK\",\n        0.611111111111111,\n        0.2777777777777779,\n        0,\n        0.2941176470588235,\n        1\n      ],\n      \"hsl\": [\n        \"HSL\",\n        0.5757575757575757,\n        0.43999999999999995,\n        0.4901960784313726,\n        1\n      ],\n      \"hsv\": [\n        \"HSV\",\n        0.5757575757575757,\n        0.611111111111111,\n        0.7058823529411765,\n        1\n      ],\n      \"lab\": [\n        \"LAB\",\n        1,\n        0,\n        0,\n        1\n      ],\n      \"rgb\": [\n        \"RGB\",\n        0.27450980392156865,\n        0.5098039215686274,\n        0.7058823529411765,\n        1\n      ],\n      \"xyz\": [\n        \"XYZ\",\n        0.18743597342600288,\n        0.2056088063416628,\n        0.46152037838994725,\n        1\n      ]\n    },\n    \"color\": {\n      \"rgb\": {\n        \"r\": 70,\n        \"g\": 130,\n        \"b\": 180\n      },\n      \"hsl\": {\n        \"h\": 207,\n        \"s\": 44,\n        \"l\": 49\n      },\n      \"hsv\": {\n        \"h\": 207,\n        \"s\": 61,\n        \"v\": 71\n      },\n      \"cmyk\": {\n        \"c\": 61,\n        \"m\": 28,\n        \"y\": 0,\n        \"k\": 29\n      },\n      \"rgbArray\": [\n        70,\n        130,\n        180\n      ],\n      \"hslArray\": [\n        207,\n        44,\n        49\n      ],\n      \"hsvArray\": [\n        207,\n        61,\n        71\n      ],\n      \"cmykArray\": [\n        61,\n        28,\n        0,\n        29\n      ],\n      \"rgbaArray\": [\n        70,\n        130,\n        180,\n        1\n      ],\n      \"hslaArray\": [\n        207,\n        44,\n        49,\n        1\n      ],\n      \"alpha\": 1,\n      \"red\": 70,\n      \"green\": 130,\n      \"blue\": 180,\n      \"hue\": 207,\n      \"saturation\": 44,\n      \"lightness\": 49,\n      \"saturationv\": 61,\n      \"value\": 71,\n      \"cyan\": 61,\n      \"magenta\": 28,\n      \"yellow\": 0,\n      \"black\": 29,\n      \"hexString\": \"#4682B4\",\n      \"rgbString\": \"rgb(70, 130, 180)\",\n      \"rgbaString\": \"rgba(70, 130, 180, 1)\",\n      \"percentString\": \"rgb(27%, 51%, 71%)\",\n      \"hslString\": \"hsl(207, 44%, 49%)\",\n      \"hslaString\": \"hsla(207, 44%, 49%, 1)\",\n      \"keyword\": \"steelblue\",\n      \"luminosity\": 0.20562642207624857,\n      \"dark\": true,\n      \"light\": false\n    },\n    \"colorConvert\": {\n      \"rgb\": [\n        70,\n        130,\n        180\n      ],\n      \"hsl\": [\n        207,\n        44,\n        49\n      ],\n      \"hsv\": [\n        207,\n        61,\n        71\n      ],\n      \"hwb\": [\n        207,\n        27,\n        29\n      ],\n      \"cmyk\": [\n        61,\n        28,\n        0,\n        29\n      ],\n      \"keyword\": \"steelblue\",\n      \"xyz\": [\n        19,\n        21,\n        46\n      ],\n      \"lab\": [\n        52,\n        -4,\n        -32\n      ],\n      \"lch\": [\n        52,\n        32,\n        263\n      ],\n      \"ansi16\": 36,\n      \"ansi\": 74\n    }\n  },\n  \"alpha\": 1,\n  \"cmyk\": {\n    \"c\": 61.11,\n    \"m\": 27.78,\n    \"y\": 0,\n    \"k\": 29.41\n  },\n  \"hsl\": {\n    \"h\": 207.27,\n    \"s\": 44,\n    \"l\": 49.02\n  },\n  \"hsv\": {\n    \"h\": 207.27,\n    \"s\": 61.11,\n    \"v\": 70.59\n  },\n  \"rgb\": {\n    \"r\": 70,\n    \"g\": 130,\n    \"b\": 180\n  },\n  \"rgbPercent\": {\n    \"r\": 27.45,\n    \"g\": 50.98,\n    \"b\": 70.59\n  },\n  \"hex\": \"#4682b4\",\n  \"hexTriplet\": \"4682b4\",\n  \"isRandom\": false,\n  \"parseSuccessful\": true,\n  \"closest\": {\n    \"name\": \"Steel Blue\",\n    \"rgb\": [\n      70,\n      130,\n      180\n    ]\n  },\n  \"websafe\": \"#3399cc\",\n  \"websmart\": \"#4488bb\",\n  \"isWebsafe\": false,\n  \"isWebsmart\": false,\n  \"schemes\": {\n    \"complementary\": [\n      \"#4682b4\",\n      \"#b47846\"\n    ],\n    \"splitComplementary\": [\n      \"#4682b4\",\n      \"#b4464b\",\n      \"#46b49d\"\n    ],\n    \"splitComplementaryCW\": [\n      \"#4682b4\",\n      \"#b4464b\",\n      \"#46b478\"\n    ],\n    \"splitComplementaryCCW\": [\n      \"#4682b4\",\n      \"#7846b4\",\n      \"#b4af46\"\n    ],\n    \"triadic\": [\n      \"#4682b4\",\n      \"#b44682\",\n      \"#82b446\"\n    ],\n    \"clash\": [\n      \"#4682b4\",\n      \"#af46b4\",\n      \"#4bb446\"\n    ],\n    \"tetradic\": [\n      \"#4682b4\",\n      \"#af46b4\",\n      \"#b47846\",\n      \"#4bb446\"\n    ],\n    \"fourToneCW\": [\n      \"#4682b4\",\n      \"#7846b4\",\n      \"#b47846\",\n      \"#82b446\"\n    ],\n    \"fourToneCCW\": [\n      \"#4682b4\",\n      \"#b44682\",\n      \"#b47846\",\n      \"#46b478\"\n    ],\n    \"fiveToneA\": [\n      \"#4682b4\",\n      \"#b4468b\",\n      \"#b44a46\",\n      \"#b4a646\",\n      \"#79b446\"\n    ],\n    \"fiveToneB\": [\n      \"#4682b4\",\n      \"#5346b4\",\n      \"#af46b4\",\n      \"#b44670\",\n      \"#79b446\"\n    ],\n    \"fiveToneC\": [\n      \"#4682b4\",\n      \"#6646b4\",\n      \"#af46b4\",\n      \"#b4a646\",\n      \"#46b49d\"\n    ],\n    \"fiveToneD\": [\n      \"#4682b4\",\n      \"#5346b4\",\n      \"#b44a46\",\n      \"#4bb446\",\n      \"#46b48a\"\n    ],\n    \"fiveToneE\": [\n      \"#4682b4\",\n      \"#b4468b\",\n      \"#94b446\",\n      \"#4bb446\",\n      \"#46b49d\"\n    ],\n    \"sixToneCW\": [\n      \"#4682b4\",\n      \"#464bb4\",\n      \"#b44682\",\n      \"#b4464b\",\n      \"#82b446\",\n      \"#4bb446\"\n    ],\n    \"sixToneCCW\": [\n      \"#4682b4\",\n      \"#af46b4\",\n      \"#b44682\",\n      \"#b4af46\",\n      \"#82b446\",\n      \"#46b4af\"\n    ],\n    \"neutral\": [\n      \"#4682b4\",\n      \"#4667b4\",\n      \"#464bb4\",\n      \"#5c46b4\",\n      \"#7846b4\",\n      \"#9346b4\"\n    ],\n    \"analogous\": [\n      \"#4682b4\",\n      \"#464bb4\",\n      \"#7846b4\",\n      \"#af46b4\",\n      \"#b44682\",\n      \"#b4464b\"\n    ]\n  },\n  \"shades\": [\n    \"#4682b4\",\n    \"#3f75a2\",\n    \"#386890\",\n    \"#315b7e\",\n    \"#2a4e6c\",\n    \"#23415a\",\n    \"#1c3448\",\n    \"#152736\",\n    \"#0e1a24\",\n    \"#070d12\"\n  ],\n  \"tints\": [\n    \"#4682b4\",\n    \"#598fbc\",\n    \"#6b9bc3\",\n    \"#7da8cb\",\n    \"#90b4d2\",\n    \"#a2c1da\",\n    \"#b5cde1\",\n    \"#c7dae9\",\n    \"#dae6f0\",\n    \"#ecf3f8\"\n  ],\n  \"tones\": [\n    \"#4682b4\",\n    \"#4c82af\",\n    \"#5282aa\",\n    \"#5781a4\",\n    \"#5d819f\",\n    \"#63819a\",\n    \"#688194\",\n    \"#6e808f\",\n    \"#74808a\",\n    \"#7a8085\"\n  ],\n  \"blind\": {\n    \"protanomaly\": \"#5e7db0\",\n    \"protanopia\": \"#6c7bae\",\n    \"deuteranomaly\": \"#597eb5\",\n    \"deuteranopia\": \"#647bb5\",\n    \"tritanomaly\": \"#3c859e\",\n    \"tritanopia\": \"#368792\",\n    \"achromatomaly\": \"#667c8e\",\n    \"achromatopsia\": \"#797979\"\n  }\n}\n```\n\n\n## Credits\n\nBelow are some of the libraries that are being used, and what they are used for:\n\n- [onecolor](https://www.npmjs.org/package/onecolor) - parses color, and gets normalized data\n- [color](https://www.npmjs.org/package/color) - gets un-normalized data and user friendly display\n- [color-blind](https://www.npmjs.org/package/color-blind) - simulates color blindness\n- [color-harmony](https://www.npmjs.org/package/color-harmony) - creates color scales/harmonies by rotating the hue of the given color\n- [color-quantize](https://www.npmjs.org/package/color-quantize) - convert colors to websafe / websmart values\n- [colorname](https://www.npmjs.org/package/colorname) - gets the closest color name\n- [cycle](https://www.npmjs.org/package/cycle) - encodes cyclical structures in json\n- [jsonfn](https://www.npmjs.org/package/jsonfn) - stringify non-json compatible objects\n- [random-seed](https://www.npmjs.org/package/random-seed) - make sure our non-color objects always return the same information\n\n\n## FAQ\n\n#### Is it slow in a loop?\n\nYes\n\n#### Why?\n\nBecause I'm trying to return \"all the things\" and depend on a lot of libraries (which\ndo some duplicate re-parsing, etc).\n\n\n## Release History\n\n#### v0.3.0 - Released June 28, 2014\n\n- modifying return format so \"lib\" data is more explicit\n- adding optional \"rgbOnly\" argument to random()\n- don't allow an alpha channel of 0 when returning random colors\n\n#### v0.2.1 - Released June 22, 2014\n\n- colorStats.random() should return alpha channel sometimes\n\n#### v0.2.0 - Released June 22, 2014\n\n- fixing a bug with the harmonies/scales that were being generated\n\n#### v0.1.0 - Released June 21, 2014\n\n- initial release\n\n\n## License\n\nCopyright (c) 2014 skratchdot  \nLicensed under the MIT license.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fskratchdot%2Fcolor-stats","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fskratchdot%2Fcolor-stats","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fskratchdot%2Fcolor-stats/lists"}