{"id":13606034,"url":"https://github.com/stayradiated/colr","last_synced_at":"2025-04-09T15:06:38.668Z","repository":{"id":19951475,"uuid":"23218282","full_name":"stayradiated/colr","owner":"stayradiated","description":"Fast and simple color conversion.","archived":false,"fork":false,"pushed_at":"2020-05-07T13:47:26.000Z","size":52,"stargazers_count":105,"open_issues_count":1,"forks_count":12,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-04-09T15:06:27.168Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","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/stayradiated.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2014-08-22T08:23:20.000Z","updated_at":"2024-11-13T05:19:57.000Z","dependencies_parsed_at":"2022-07-27T01:02:01.960Z","dependency_job_id":null,"html_url":"https://github.com/stayradiated/colr","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/stayradiated%2Fcolr","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/stayradiated%2Fcolr/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/stayradiated%2Fcolr/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/stayradiated%2Fcolr/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/stayradiated","download_url":"https://codeload.github.com/stayradiated/colr/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248055284,"owners_count":21040157,"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-08-01T19:01:05.431Z","updated_at":"2025-04-09T15:06:38.646Z","avatar_url":"https://github.com/stayradiated.png","language":"JavaScript","funding_links":[],"categories":["Colors"],"sub_categories":["Reactive Programming"],"readme":"colr\n====\n\nSimple color conversion library based on simplicity and stability\n\n## API\n\n### Constructors\n\nCreate a new instance of the Colr class\n\n```javascript\n// create a  empty instance\nvar colr = new Colr();\n\n// create from hex\nvar colr = Colr.fromHex('#abc123');\n\n// create from rgb\nvar colr = Colr.fromRgb(20, 30, 40);\nvar colr = Colr.fromRgbArray([20, 30, 40]);\nvar colr = Colr.fromRgbObject({r:20, g:30, b:40});\n\n// create from hsl\nvar colr = Colr.fromHsl(320, 20, 90);\nvar colr = Colr.fromHslArray([320, 20, 90]);\nvar colr = Colr.fromHslObject({h:320, s:20, l:90});\n\n// create from grayscale\nvar colr = Colr.fromGrayscale(128);\n```\n\n### Importers\n\nChange the color of an existing Colr instance.\n\nAll methods return the `colr` instance and can be chained.\n\n```javascript\nvar colr = new Colr();\n\n// import from hex\ncolr.fromHex('#abc123');\n\n// import from rgb\ncolr.fromRgb(20, 30, 40);\ncolr.fromRgbArray([20, 30, 40]);\ncolr.fromRgbObject({r:20, g:30, b:40});\n\n// import from hsl\ncolr.fromHsl(320, 20, 90);\ncolr.fromHslArray([320, 20, 90]);\ncolr.fromHslObject({h:320, s:20, l:90});\n\n// import from hsv/hsb\ncolr.fromHsv(30, 80, 20);\ncolr.fromHsvArray([30, 80, 20]);\ncolr.fromHsvObject({h:30, s:80, v:20});\n\n// create from grayscale\ncolr.fromGrayscale(128);\n```\n\n### Hsl/Hsv ranges\nThese are not 0 to 255 but rather:\n```\nHue:              [0, 360]\nSaturation:       [0, 100]\nLightness/Value:  [0, 100]\n```\n### Exporters\n\nConvert the color to another format\n\n```javascript\nvar colr = Colr().fromHex('bada55');\n\ncolr.toHex(); // \"#BADA55\"\n\ncolr.toRgbArray(); // [186, 218, 85]\ncolr.toRgbObject(); // {r:186, g:218, b:85}\ncolr.toRawRgbArray(); // [186, 218, 85]\ncolr.toRawRgbObject(); // {r:186, g:218, b:85}\n\ncolr.toHslArray(); // [74, 64, 59]\ncolr.toHslObject(); // {h:74, s:64, l:59}\ncolr.toRawHslArray(); // {74.4360902255639, 64.25120772946859, 59.411764705882355]\ncolr.toRawHslObject(); // {r:74.4360902255639, g:64.25120772946859, b:59.411764705882355}\n\ncolr.toHsvArray(); // [74, 61, 85]\ncolr.toHsvObject(); //{h: 74, s: 61, l: 85}\ncolr.toRawHsvArray(); // [74.4360902255639, 61.00917431192661, 85.49019607843137]\ncolr.toRawHsvObject(); // {r:74.4360902255639, g:61.00917431192661, b:85.49019607843137}\n\ncolr.toGrayscale(); // 193.27\n```\n\n### Modifiers\n\nAll methods return the `colr` instance and can be chained.\n\n```javascript\nvar colr = Colr.fromHex('000').lighten(20);\ncolr.toHex(); // \"#333333\"\n\nvar colr = Colr.fromHex('FFF').darken(20);\ncolr.toHex(); // \"#CCCCCC\"\n```\n\n### Misc\n\n```javascript\nvar a = Colr.fromHex('#000');\nvar b = a.clone();\n\na.lighten(20);\n\na.toHex(); // '#333333'\nb.toHex(); // '#000000'\n```\n\n## Benchmarks\n\n```\n$ node benchmark.js\n\n# FromHsv -\u003e ToRgb\ncolr      x 4,552,216 ops/sec ±0.75% (102 runs sampled)\ncolor     x 334,029 ops/sec ±0.40% (98 runs sampled)\ntinycolor x 1,018,397 ops/sec ±0.45% (102 runs sampled)\nchroma    x 346,686 ops/sec ±0.36% (97 runs sampled)\nFastest is colr\n\n# FromHex -\u003e Lighten -\u003e ToHex\ncolr      x 1,400,992 ops/sec ±0.27% (102 runs sampled)\ncolor     x 61,486 ops/sec ±0.39% (102 runs sampled)\ntinycolor x 80,712 ops/sec ±0.96% (97 runs sampled)\nchroma    x 100,885 ops/sec ±0.73% (100 runs sampled)\nFastest is colr\n\n# FromHex -\u003e Lighten -\u003e Darken -\u003e ToHex\ncolr      x 1,334,580 ops/sec ±0.72% (98 runs sampled)\ncolor     x 47,224 ops/sec ±0.86% (101 runs sampled)\ntinycolor x 54,639 ops/sec ±1.07% (101 runs sampled)\nchroma    x 65,039 ops/sec ±0.93% (101 runs sampled)\nFastest is colr\n\n# FromHex -\u003e ToHex\ncolr      x 2,192,730 ops/sec ±0.77% (98 runs sampled)\ncolor     x 92,882 ops/sec ±0.87% (101 runs sampled)\ntinycolor x 201,324 ops/sec ±0.98% (98 runs sampled)\nchroma    x 266,279 ops/sec ±0.89% (98 runs sampled)\nFastest is colr\n\n# FromHsv -\u003e ToRgb -\u003e ToHex\ncolr      x 1,680,538 ops/sec ±0.68% (97 runs sampled)\ncolor     x 155,721 ops/sec ±0.48% (101 runs sampled)\ntinycolor x 530,777 ops/sec ±0.81% (99 runs sampled)\nchroma    x 235,950 ops/sec ±1.00% (95 runs sampled)\nFastest is colr\n\n# FromHsv -\u003e ToHsl\ncolr      x 4,387,198 ops/sec ±0.45% (99 runs sampled)\ncolor     x 201,875 ops/sec ±0.73% (101 runs sampled)\ntinycolor x 434,277 ops/sec ±0.65% (102 runs sampled)\nchroma    x 306,594 ops/sec ±1.21% (92 runs sampled)\nFastest is colr\n\n# FromHsl -\u003e ToHsv\ncolr      x 4,296,682 ops/sec ±0.69% (95 runs sampled)\ncolor     x 187,083 ops/sec ±0.72% (102 runs sampled)\ntinycolor x 471,617 ops/sec ±0.59% (102 runs sampled)\nchroma    x 229,835 ops/sec ±0.52% (100 runs sampled)\nFastest is colr\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fstayradiated%2Fcolr","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fstayradiated%2Fcolr","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fstayradiated%2Fcolr/lists"}