{"id":21467427,"url":"https://github.com/elusivecodes/frostcolor","last_synced_at":"2025-07-15T05:31:32.193Z","repository":{"id":39996647,"uuid":"138693046","full_name":"elusivecodes/FrostColor","owner":"elusivecodes","description":"FrostColor is a free, open-source color manipulation library for JavaScript.","archived":false,"fork":false,"pushed_at":"2024-06-24T01:18:42.000Z","size":615,"stargazers_count":6,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2024-10-28T23:11:35.942Z","etag":null,"topics":["cmy","cmyk","color","hex","hsl","hsv","javascript","rgb","rgba"],"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/elusivecodes.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":"2018-06-26T06:16:41.000Z","updated_at":"2024-06-24T01:18:26.000Z","dependencies_parsed_at":"2023-02-01T05:46:15.959Z","dependency_job_id":null,"html_url":"https://github.com/elusivecodes/FrostColor","commit_stats":null,"previous_names":[],"tags_count":21,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/elusivecodes%2FFrostColor","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/elusivecodes%2FFrostColor/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/elusivecodes%2FFrostColor/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/elusivecodes%2FFrostColor/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/elusivecodes","download_url":"https://codeload.github.com/elusivecodes/FrostColor/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":226017501,"owners_count":17560523,"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":["cmy","cmyk","color","hex","hsl","hsv","javascript","rgb","rgba"],"created_at":"2024-11-23T08:17:57.940Z","updated_at":"2024-11-23T08:17:58.743Z","avatar_url":"https://github.com/elusivecodes.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# FrostColor\r\n\r\n**FrostColor** is a free, open-source immutable color manipulation library for *JavaScript*.\r\n\r\nIt is a lightweight (~4kb gzipped) and modern library, and features full support for RGB, HSL, HSV, CMY and CMYK color-spaces.\r\n\r\n\r\n## Table Of Contents\r\n- [Installation](#installation)\r\n- [Basic Usage](#basic-usage)\r\n- [Color Creation](#color-creation)\r\n- [Color Formatting](#color-formatting)\r\n- [Color Attributes](#color-attributes)\r\n- [Color Manipulation](#color-manipulation)\r\n- [Color Schemes](#color-schemes)\r\n- [Color Palettes](#color-palettes)\r\n- [Static Methods](#static-methods)\r\n\r\n\r\n## Installation\r\n\r\n**In Browser**\r\n\r\n```html\r\n\u003cscript type=\"text/javascript\" src=\"/path/to/frost-color.min.js\"\u003e\u003c/script\u003e\r\n```\r\n\r\n**Using NPM**\r\n\r\n```\r\nnpm i @fr0st/color\r\n```\r\n\r\nIn Node.js:\r\n\r\n```javascript\r\nimport Color from '@fr0st/color';\r\n```\r\n\r\n\r\n## Basic Usage\r\n\r\n**From RGB**\r\n\r\n- `red` is a number between *0* and *255*.\r\n- `green` is a number between *0* and *255*.\r\n- `blue` is a number between *0* and *255*.\r\n- `alpha` is a number between *0* and *1*, and will default to *1*.\r\n\r\n```javascript\r\nconst color = new Color(red, green, blue, alpha);\r\n```\r\n\r\n**From Brightness**\r\n\r\n- `brightness` is a number between *0* and *100*.\r\n- `alpha` is a number between *0* and *1*, and will default to *1*.\r\n\r\n```javascript\r\nconst color = new Color(brightness, alpha);\r\n```\r\n\r\n\r\n## Color Creation\r\n\r\n**From String**\r\n\r\nCreate a new *Color* from a HTML color string.\r\n\r\n- `colorString` is a string containing a color value in either hexadecimal, RGB, RGBA, HSL, HSLA or a standard HTML color name.\r\n\r\n```javascript\r\nconst color = Color.fromString(colorString);\r\n```\r\n\r\n**From CMY**\r\n\r\nCreate a new *Color* from CMY values.\r\n\r\n- `cyan` is a number between *0* and *100*.\r\n- `magenta` is a number between *0* and *100*.\r\n- `yellow` is a number between *0* and *100*.\r\n- `alpha` is a number between *0* and *1*, and will default to *1*.\r\n\r\n```javascript\r\nconst color = Color.fromCMY(cyan, magenta, yellow, alpha);\r\n```\r\n\r\n**From CMYK**\r\n\r\nCreate a new *Color* from CMYK values.\r\n\r\n- `cyan` is a number between *0* and *100*.\r\n- `magenta` is a number between *0* and *100*.\r\n- `yellow` is a number between *0* and *100*.\r\n- `key` is a number between *0* and *100*.\r\n- `alpha` is a number between *0* and *1*, and will default to *1*.\r\n\r\n```javascript\r\nconst color = Color.fromCMYK(cyan, magenta, yellow, key, alpha);\r\n```\r\n\r\n**From HSL**\r\n\r\nCreate a new *Color* from HSL values.\r\n\r\n- `hue` is a number between *0* and *360*.\r\n- `saturation` is a number between *0* and *100*.\r\n- `lightness` is a number between *0* and *100*.\r\n- `alpha` is a number between *0* and *1*, and will default to *1*.\r\n\r\n```javascript\r\nconst color = Color.fromHSL(hue, saturation, lightness, alpha);\r\n```\r\n\r\n**From HSV**\r\n\r\nCreate a new *Color* from HSV values.\r\n\r\n- `hue` is a number between *0* and *360*.\r\n- `saturation` is a number between *0* and *100*.\r\n- `value` is a number between *0* and *100*.\r\n- `alpha` is a number between *0* and *1*, and will default to *1*.\r\n\r\n```javascript\r\nconst color = Color.fromHSV(hue, saturation, value, alpha);\r\n```\r\n\r\n\r\n## Color Formatting\r\n\r\n**To String**\r\n\r\nReturn a HTML string representation of the color.\r\n\r\nThe `colorString` returned will be a string containing either a HTML color name (if one exists), a hexadecimal string (if alpha is *1*) or an RGBA string.\r\n\r\n```javascript\r\nconst colorString = color.toString();\r\n```\r\n\r\n**To Hex String**\r\n\r\nReturn a hexadecimal string representation of the color.\r\n\r\n```javascript\r\nconst hexString = color.toHexString();\r\n```\r\n\r\n**To RGB String**\r\n\r\nReturn a RGB/RGBA string representation of the color.\r\n\r\n```javascript\r\nconst rgbString = color.toRGBString();\r\n```\r\n\r\n**To HSL String**\r\n\r\nReturn a HSL/HSLA string representation of the color.\r\n\r\n```javascript\r\nconst hslString = color.toHSLString();\r\n```\r\n\r\n**Label**\r\n\r\nGet the closest color name for the color.\r\n\r\n```javascript\r\nconst label = color.label();\r\n```\r\n\r\n\r\n## Color Attributes\r\n\r\n**Get Alpha**\r\n\r\nGet the alpha value of the color (between *0* and *1*).\r\n\r\n```javascript\r\nconst alpha = color.getAlpha();\r\n```\r\n\r\n**Get Brightness**\r\n\r\nGet the brightness value of the color (between *0* and *100*).\r\n\r\n```javascript\r\nconst brightness = color.getBrightness();\r\n```\r\n\r\n**Get Hue**\r\n\r\nGet the hue value of the color (between *0* and *360*).\r\n\r\n```javascript\r\nconst hue = color.getHue();\r\n```\r\n\r\n**Get Saturation**\r\n\r\nGet the saturation value of the color (between *0* and *100*).\r\n\r\n```javascript\r\nconst saturation = color.getSaturation();\r\n```\r\n\r\n**Luma**\r\n\r\nGet the relative luminance value of the color (between *0* and *1*).\r\n\r\n```javascript\r\nconst luma = color.luma();\r\n```\r\n\r\n**Set Alpha**\r\n\r\nSet the alpha value of the color.\r\n\r\n- `alpha` is a number between *0* and *1*.\r\n\r\n```javascript\r\nconst newColor = color.setAlpha(alpha);\r\n```\r\n\r\n**Set Brightness**\r\n\r\nSet the brightness value of the color.\r\n\r\n- `brightness` is a number between *0* and *100*.\r\n\r\n```javascript\r\nconst newColor = color.setBrightness(brightness);\r\n```\r\n\r\n**Set Hue**\r\n\r\nSet the hue value of the color.\r\n\r\n- `hue` is a number between *0* and *360*.\r\n\r\n```javascript\r\nconst newColor = color.setHue(hue);\r\n```\r\n\r\n**Set Saturation**\r\n\r\nSet the saturation value of the color.\r\n\r\n- `saturation` is a number between *0* and *100*.\r\n\r\n```javascript\r\nconst newColor = color.setSaturation(saturation);\r\n```\r\n\r\n\r\n## Color Manipulation\r\n\r\n**Darken**\r\n\r\nDarken the color by a specified amount.\r\n\r\n- `amount` is a number between *0* and *1*.\r\n\r\n```javascript\r\nconst newColor = color.darken(amount);\r\n```\r\n\r\n**Invert**\r\n\r\nInvert the color.\r\n\r\n```javascript\r\nconst newColor = color.invert();\r\n```\r\n\r\n**Lighten**\r\n\r\nLighten the color by a specified amount.\r\n\r\n- `amount` is a number between *0* and *1*.\r\n\r\n```javascript\r\nconst newColor = color.lighten(amount);\r\n```\r\n\r\n**Shade**\r\n\r\nShade the color by a specified amount.\r\n\r\n- `amount` is a number between *0* and *1*.\r\n\r\n```javascript\r\nconst newColor = color.shade(amount);\r\n```\r\n\r\n**Tint**\r\n\r\nTint the color by a specified amount.\r\n\r\n- `amount` is a number between *0* and *1*.\r\n\r\n```javascript\r\nconst newColor = color.tint(amount);\r\n```\r\n\r\n**Tone**\r\n\r\nTone the color by a specified amount.\r\n\r\n- `amount` is a number between *0* and *1*.\r\n\r\n```javascript\r\nconst newColor = color.tone(amount);\r\n```\r\n\r\n\r\n## Color Schemes\r\n\r\n**Complementary**\r\n\r\nCreate a complementary color variation.\r\n\r\n```javascript\r\nconst complementary = color.complementary();\r\n```\r\n\r\n**Split**\r\n\r\nCreate an array with 2 split color variations.\r\n\r\n```javascript\r\nconst [secondary, accent] = color.split();\r\n```\r\n\r\n**Analogous**\r\n\r\nCreate an array with 2 analogous color variations.\r\n\r\n```javascript\r\nconst [secondary, accent] = color.analogous();\r\n```\r\n\r\n**Triadic**\r\n\r\nCreate an array with 2 triadic color variations.\r\n\r\n```javascript\r\nconst [secondary, accent] = color.triadic();\r\n```\r\n\r\n**Tetradic**\r\n\r\nCreate an array with 3 tetradic color variations.\r\n\r\n```javascript\r\nconst [secondary, alternate, accent] = color.tetradic();\r\n```\r\n\r\n\r\n## Color Palettes\r\n\r\nCreate a palette of colors from a *Color* object you have created using the following methods.\r\n\r\n**Shades**\r\n\r\nCreate an array with a specified number of shade variations.\r\n\r\n- `shades` is a number indicating how many shades you wish to generate, and will default to *10*.\r\n\r\n```javascript\r\nconst colorShades = color.shades(shades);\r\n```\r\n\r\n**Tints**\r\n\r\nCreate an array with a specified number of tint variations.\r\n\r\n- `tints` is a number indicating how many tints you wish to generate, and will default to *10*.\r\n\r\n```javascript\r\nconst colorTints = color.tints(tints);\r\n```\r\n\r\n**Tones**\r\n\r\nCreate an array with a specified number of tone variations.\r\n\r\n- `tones` is a number indicating how many tones you wish to generate, and will default to *10*.\r\n\r\n```javascript\r\nconst colorTones = color.tones(tones);\r\n```\r\n\r\n**Palette**\r\n\r\nCreate a palette object with a specified number of shades, tints and tone variations.\r\n\r\n- `options` is an object containing options for how the palette should be generated.\r\n    - `shades` is a number indicating how many shades you wish to generate, and will default to *10*.\r\n    - `tints` is a number indicating how many tints you wish to generate, and will default to *10*.\r\n    - `tones` is a number indicating how many tones you wish to generate, and will default to *10*.\r\n\r\n```javascript\r\nconst colorPalette = color.palette(options);\r\n```\r\n\r\n\r\n## Static Methods\r\n\r\n**Contrast**\r\n\r\nCalculate the contrast between two colors (between *1* and *21*).\r\n\r\n- `color1` is a *Color* object.\r\n- `color2` is a *Color* object.\r\n\r\n```javascript\r\nconst contrast = Color.contrast(color1, color2);\r\n```\r\n\r\n**Distance**\r\n\r\nCalculate the distance between two colors.\r\n\r\n- `color1` is a *Color* object.\r\n- `color2` is a *Color* object.\r\n\r\n```javascript\r\nconst distance = Color.dist(color1, color2);\r\n```\r\n\r\n**Find Contrast**\r\n\r\nFind an optimally contrasting color for another color.\r\n\r\n- `color1` is a *Color* object.\r\n- `color2` is a *Color* object, and will default to *null*.\r\n- `options` is an object containing options for how the contrasting color should be found.\r\n    - `minContrast` is a number between *1* and *21* indicating the minimum valid contrast, and will default to *4.5*.\r\n    - `stepSize` is a number between *0* and *1* indicating the amount to darken/lighten the color on each iteration, and will default to *0.01*.\r\n\r\n```javascript\r\nconst contrastColor = Color.findContrast(color1, color2, options);\r\n```\r\n\r\nIf `color2` value is *null*, `color1` will be used instead.\r\n\r\nThis method will tint/shade `color2` until it meets a minimum contrast threshold with `color1`, then the new color will be returned. If no valid contrast value can be found, this method will return *null* instead.\r\n\r\n**Mix**\r\n\r\nCreate a new *Color* by mixing two colors together by a specified amount.\r\n\r\n- `color1` is a *Color* object.\r\n- `color2` is a *Color* object.\r\n- `amount` is a number between *0* and *1*.\r\n\r\n```javascript\r\nconst mixed = Color.mix(color1, color2, amount);\r\n```\r\n\r\n**Multiply**\r\n\r\nCreate a new *Color* by multiplying two colors together by a specified amount.\r\n\r\n- `color1` is a *Color* object.\r\n- `color2` is a *Color* object.\r\n- `amount` is a number between *0* and *1*.\r\n\r\n```javascript\r\nconst multiplied = Color.multiply(color1, color2, amount);\r\n```\r\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Felusivecodes%2Ffrostcolor","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Felusivecodes%2Ffrostcolor","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Felusivecodes%2Ffrostcolor/lists"}