{"id":21964331,"url":"https://github.com/dunosaurs/color","last_synced_at":"2025-04-24T01:28:06.011Z","repository":{"id":62422702,"uuid":"488057392","full_name":"dunosaurs/color","owner":"dunosaurs","description":"A simple, fast, and comprehensive color library for Deno.","archived":false,"fork":false,"pushed_at":"2023-04-15T13:26:33.000Z","size":38,"stargazers_count":8,"open_issues_count":2,"forks_count":1,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-04-16T04:06:47.735Z","etag":null,"topics":["color","deno","fast","typescript"],"latest_commit_sha":null,"homepage":"https://deno.land/x/color","language":"TypeScript","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/dunosaurs.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":"2022-05-03T02:42:27.000Z","updated_at":"2024-06-12T13:31:58.000Z","dependencies_parsed_at":"2023-01-22T03:19:58.676Z","dependency_job_id":null,"html_url":"https://github.com/dunosaurs/color","commit_stats":null,"previous_names":[],"tags_count":5,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dunosaurs%2Fcolor","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dunosaurs%2Fcolor/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dunosaurs%2Fcolor/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dunosaurs%2Fcolor/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/dunosaurs","download_url":"https://codeload.github.com/dunosaurs/color/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":250543296,"owners_count":21447866,"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":["color","deno","fast","typescript"],"created_at":"2024-11-29T12:06:01.731Z","updated_at":"2025-04-24T01:28:05.996Z","avatar_url":"https://github.com/dunosaurs.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# color\n\n\u003e Deno library for immutable color conversion and manipulation with support for\n\u003e CSS color strings.\n\n```typescript\nimport { Color } from \"https://deno.land/x/color/mod.ts\";\n\nconst color = Color.rgb(35, 64, 115);\nconsole.log(color.string()); // rgb(35, 64, 115)\nconsole.log(color.cmyk().string()); // cmyk(70%, 44%, 0%, 55%)\nconsole.log(color.hsv().string()); // hsv(218, 70%, 45%)\nconsole.log(color.hex()); // #234073\n```\n\n## Usage\n\n### Getters\n\nConvert a color to a different space (hsl(), cmyk(), etc.).\n\n```typescript\ncolor.hsl();\n```\n\nGet an object representing the color\n\n```typescript\ncolor.object(); // {r: 255, g: 255, b: 255}\n```\n\nGet an array representing the color\n\n```typescript\ncolor.rgb().array(); // [255, 255, 255]\n```\n\nGet decimal number representing the color\n\n```typescript\ncolor.rgbNumber(); // 16777215 (0xffffff)\n```\n\nGet the hexidecimal value a color represents\n\n```typescript\ncolor.hex(); // #ffffff\n```\n\nGet an individual attribute from a color\n\n```typescript\ncolor.red(); // 255\ncolor.green(); // 255\ncolor.blue(); // 255\n```\n\n### CSS Strings\n\nCSS strings can be generated from a color using the `.string()` method\n\n```typescript\ncolor.hsl().string(); // 'hsl(320, 50%, 100%)'\n```\n\nAlso, you can generate Color objects from CSS strings\n\n```typescript\nColor.string(\"#FDA\").hex(); // #ffddaa\nColor.string(\"hsl(180, 10%, 20%)\").hsl().string(); // hsl(180, 10%, 20%)\nColor.string(\"hsla(180, 10%, 20%, 0.2)\").hsla().string(); // hsla(180, 10%, 20%, 0.2)\nColor.string(\"cmyk(100%, 0%, 0%, 0%)\").cmyk().string(); // cmyk(100%, 0%, 0%, 0%)\nColor.string(\"hwb(12 50% 0%)\").hwb().string(); // hwb(12 50% 0%)\n```\n\n### Luminosity\n\nThe WCAG luminosity of the color. 0 is black, 1 is white.\n\n```typescript\ncolor.luminosity(); // 0.412\n```\n\nThe WCAG contrast ratio to another color, from 1 (same color) to 21 (contrast\nb/w white and black).\n\n```typescript\ncolor.contrast(Color.rgb(50, 10, 5)); // 12\n```\n\nGet whether the color is \"light\" or \"dark\", useful for deciding text color.\n\n```typescript\ncolor.isLight(); // true\ncolor.isDark(); // false\n```\n\n### Manipulation\n\n```typescript\ncolor.negate(); // rgb(0, 100, 255) -\u003e rgb(255, 155, 0)\n\ncolor.lighten(0.5); // hsl(100, 50%, 50%) -\u003e hsl(100, 50%, 75%)\ncolor.lighten(0.5); // hsl(100, 50%, 0)   -\u003e hsl(100, 50%, 0%)\ncolor.darken(0.5); // hsl(100, 50%, 50%) -\u003e hsl(100, 50%, 25%)\ncolor.darken(0.5); // hsl(100, 50%, 0)   -\u003e hsl(100, 50%, 0%)\n\ncolor.setLightness(50); // hsl(100, 50%, 10%) -\u003e hsl(100, 50%, 50%)\n\ncolor.saturate(0.5); // hsl(100, 50%, 50%) -\u003e hsl(100, 75%, 50%)\ncolor.desaturate(0.5); // hsl(100, 50%, 50%) -\u003e hsl(100, 25%, 50%)\ncolor.grayscale(); // #5CBF54 -\u003e #969696\n\ncolor.fade(0.5); // rgba(10, 10, 10, 0.8) -\u003e rgba(10, 10, 10, 0.4)\ncolor.opaquer(0.5); // rgba(10, 10, 10, 0.8) -\u003e rgba(10, 10, 10, 1)\n\ncolor.rotate(180); // hsl(60, 20%, 20%) -\u003e hsl(240, 20%, 20%)\ncolor.rotate(-90); // hsl(60, 20%, 20%) -\u003e hsl(330, 20%, 20%)\n\nred.mix(blue); // rgb(255, 0, 0) -\u003e rgb(128, 0, 128)\nred.mix(blue, 0.75); // rgb(255, 0, 0) -\u003e rgb(64, 0, 191)\n\n// chaining\ncolor.setGreen(100).grayscale().lighten(0.6);\n```\n\n## Color-Space Conversions\n\nColor space rules can be mixed together, and all of the color-space conversions\nhappen behind the scenes!\n\n```typescript\nconst rgb = Color.rgb(255, 0, 0);\ncolor.setBlack(255); // rgb(255, 0, 0) -\u003e rgb(0, 0, 0)\ncolor.setHue(200); // rgb(255, 0, 0) -\u003e rgb(0, 170, 255)\n```\n\n## Propers\n\nHeavily inspired by: [Color](https://github.com/Qix-/color)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdunosaurs%2Fcolor","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdunosaurs%2Fcolor","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdunosaurs%2Fcolor/lists"}