{"id":17138066,"url":"https://github.com/moagrius/color","last_synced_at":"2025-07-03T08:35:36.534Z","repository":{"id":141864076,"uuid":"2310991","full_name":"moagrius/Color","owner":"moagrius","description":"abstract Color management class for JavaScript; discreet component manipulation; output formatting; conversions.","archived":false,"fork":false,"pushed_at":"2019-09-11T18:34:08.000Z","size":191,"stargazers_count":21,"open_issues_count":1,"forks_count":9,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-04-13T10:01:07.094Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"http://moagrius.github.io/Color/Color.html","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/moagrius.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,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2011-09-01T23:50:02.000Z","updated_at":"2023-07-05T20:46:48.000Z","dependencies_parsed_at":null,"dependency_job_id":"f74de4c5-a525-4e8a-9ab2-32531b405df1","html_url":"https://github.com/moagrius/Color","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/moagrius/Color","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/moagrius%2FColor","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/moagrius%2FColor/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/moagrius%2FColor/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/moagrius%2FColor/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/moagrius","download_url":"https://codeload.github.com/moagrius/Color/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/moagrius%2FColor/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":263291213,"owners_count":23443719,"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-14T20:08:40.330Z","updated_at":"2025-07-03T08:35:36.521Z","avatar_url":"https://github.com/moagrius.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"\u003ch1\u003eColor.js\u003c/h1\u003e\n\u003ch2\u003eabstract Color management class written in JavaScript\u003c/h2\u003e\n\u003cp\u003e\u003ca href=\"http://moagrius.github.io/Color/Color.html\" target=\"_blank\"\u003eDocumentation\u003c/a\u003e\u003c/p\u003e\n\u003cp\u003eThis class allows a Color to be created in any format (RGB, hex, decimal, HSL, HSV, CSS, etc), while allowing any component to be manipulated.\u003c/p\u003e\n\u003cul\u003e\n\u003cli\u003enew Color();\t\u003c/li\u003e\n\u003cli\u003enew Color('#FF9900');\t\u003c/li\u003e\n\u003cli\u003enew Color(element.style.color);\t\u003c/li\u003e\n\u003cli\u003enew Color('pink');\t\u003c/li\u003e\n\u003cli\u003enew Color(123456);\t\u003c/li\u003e\n\u003cli\u003enew Color({ red : 255, green : 100, blue : 0 });\t\u003c/li\u003e\n\u003cli\u003enew Color(colorInstance);\u003c/li\u003e\n\u003c/ul\u003e\n\u003cp\u003eFor example, you can create a color in RGB format, but then modify the lightness, or brightness, or saturation - it need not be converted between formats (although format output is also available).\u003c/p\u003e\n\u003cp\u003eComponent methods include:\u003cp\u003e\n\u003cul\u003e\n\u003cli\u003e.red()\t\u003c/li\u003e\n\u003cli\u003e.green()\t\u003c/li\u003e\n\u003cli\u003e.blue()\t\u003c/li\u003e\n\u003cli\u003e.hue()\t\u003c/li\u003e\n\u003cli\u003e.saturation()\t\u003c/li\u003e\n\u003cli\u003e.lightness()\t\u003c/li\u003e\n\u003cli\u003e.brightness()\t\u003c/li\u003e\n\u003cli\u003e.hex()\t\u003c/li\u003e\n\u003cli\u003e.decimal()\u003c/li\u003e\n\u003c/ul\u003e\n\u003cp\u003eComponent methods signatures are similar to jquery mutators - invoked without arguments, the method functions as a getter, and returns the current value;\ninvoked with an argument, they function as setters, and update that value on the calling instance.\u003c/p\u003e\n\u003cpre\u003e// usage...\nvar color = new Color('#FF9900');\ncolor.brightness(20);\nelement.style.backgroundColor = color;\nconsole.log(color.getRGB());\nconsole.log(color.saturation());\u003c/pre\u003e\n\u003cp\u003eThe component is equipped to handle the vagaries of the DOM, and should be able to parse any CSS color output automatically.\u003c/p\u003e\n\u003cp\u003eA number of other convenience methods exist, such as \u003ca target=\"_blank\" href=\"http://moagrius.github.io/Color/Color.html#interpolate\"\u003e.interpolate\u003c/a\u003e,\nwhich smoothly blends one color to another, and \u003ca target=\"_blank\" href=\"http://moagrius.github.io/Color/Color.html#bind\"\u003e.bind\u003c/a\u003e that links a Color\ninstance with an object (e.g., a DOM element's style property, like background-color or (text) color), so that when the Color instance is mutated,\nthe bound object property will also be updated.\u003c/p\u003e\n\u003ch2\u003eTypeScript support\u003c/h2\u003e\n\u003cp\u003eThis library is not a module, so to use it in a TypeScript project, add the following line at the top of the file you want to use it in:\u003c/p\u003e\n\u003cpre\u003e/// \u0026lt;reference path=\"./path-to-color/Color.ts\"/\u0026gt; \u003c/pre\u003e\n\u003cp\u003eIt has been tested to be compatible with all of the following strict compiler options: \u003cpre\u003e--strictNullChecks --noFallthroughCasesInSwitch --noImplicitReturns --noImplicitAny\u003c/pre\u003e\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmoagrius%2Fcolor","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmoagrius%2Fcolor","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmoagrius%2Fcolor/lists"}