{"_id":"@avolutions/colorado","_rev":"3-be55f9cb315b4bffd0142091a3139bb0","name":"@avolutions/colorado","dist-tags":{"latest":"0.3.1"},"versions":{"0.1.0":{"name":"@avolutions/colorado","version":"0.1.0","keywords":["color"],"author":{"name":"Alexander Vogt","email":"alexander.vogt@avolutions.de"},"license":"MIT","_id":"@avolutions/colorado@0.1.0","maintainers":[{"name":"avolutions","email":"alexander.vogt@avolutions.de"}],"homepage":"https://github.com/AlxndrVgt/colorado#readme","bugs":{"url":"https://github.com/AlxndrVgt/colorado/issues"},"dist":{"shasum":"b407350870a094b27f572f8c636d177619698f9a","tarball":"https://registry.npmjs.org/@avolutions/colorado/-/colorado-0.1.0.tgz","fileCount":5,"integrity":"sha512-+0XimdZJ341jkiKcJvqx78fghtsI50Dl5TFfYsghgIoKd+mM1JzW0qkWLXeYDTI/IEuD896B+ET77voaO2OSGw==","signatures":[{"sig":"MEUCIBffgp5Sojz2ytq16thqDNy8YbriSAje7ZFYgPwAI2GYAiEA2HVrrvfsn16CwMex4/Y1wdhKa7KLIujQu7YC/wag8ts=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":2724},"main":"dist/Color.js","types":"dist/Color.d.ts","gitHead":"0debcddeb4f8728eb81095ab4c007a59c4a974d8","scripts":{"test":"jest","build":"tsc"},"_npmUser":{"name":"avolutions","email":"alexander.vogt@avolutions.de"},"repository":{"url":"git+https://github.com/AlxndrVgt/colorado.git","type":"git"},"_npmVersion":"10.7.0","description":"TypeScript color handling","directories":{},"_nodeVersion":"18.20.4","_hasShrinkwrap":false,"devDependencies":{"jest":"^29.7.0","ts-jest":"^29.2.5","typescript":"^5.6.2","@types/jest":"^29.5.12"},"_npmOperationalInternal":{"tmp":"tmp/colorado_0.1.0_1726147609464_0.8363414694264535","host":"s3://npm-registry-packages"}},"0.2.0":{"name":"@avolutions/colorado","version":"0.2.0","keywords":["color"],"author":{"name":"Alexander Vogt","email":"alexander.vogt@avolutions.de"},"license":"MIT","_id":"@avolutions/colorado@0.2.0","maintainers":[{"name":"avolutions","email":"alexander.vogt@avolutions.de"}],"homepage":"https://github.com/avolutions/colorado#readme","bugs":{"url":"https://github.com/avolutions/colorado/issues"},"dist":{"shasum":"47b1394038f633aca4e713c19171265f2557dc9d","tarball":"https://registry.npmjs.org/@avolutions/colorado/-/colorado-0.2.0.tgz","fileCount":28,"integrity":"sha512-Qc2gfXQXHzb6npLJiuPf7l/6kdfsPel9QDpfXdRtD+IMhKkM88O/LeAcYk+w+O7WRxyGHkt7lhT1I7mBucIIbQ==","signatures":[{"sig":"MEUCIQDDhmxfvaRPFVGmIP/EIxodH5SC8ocBu0WX1gvPzmShewIgUDtVTzjCDzNU2ePRQCrrj4uyJxoQkpAROftuw7h89YI=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":39140},"main":"dist/cjs/Color.js","type":"module","types":"dist/esm/Color.d.ts","module":"dist/esm/Color.js","exports":{".":{"import":"./dist/esm/Color.js","require":"./dist/cjs/Color.js"}},"gitHead":"62f337e7917248216aff4a7056f6cb4f1fa0d15b","scripts":{"lint":"eslint","test":"jest","build":"npm run build:cjs && npm run build:esm","build:cjs":"tsc --project tsconfig.cjs.json && echo {\"type\": \"commonjs\"} > dist/cjs/package.json","build:esm":"tsc --project tsconfig.esm.json","test:coverage":"jest --coverage"},"_npmUser":{"name":"avolutions","email":"alexander.vogt@avolutions.de"},"repository":{"url":"git+https://github.com/avolutions/colorado.git","type":"git"},"_npmVersion":"10.7.0","description":"Colorado is a lightweight, intuitive JavaScript library for handling and converting color values. Seamlessly switch between RGB and Hex formats with simple methods and generate clean string outputs for your web projects. Perfect for developers looking for","directories":{},"_nodeVersion":"18.20.4","_hasShrinkwrap":false,"devDependencies":{"jest":"^29.7.0","eslint":"^9.10.0","globals":"^15.9.0","ts-jest":"^29.2.5","@eslint/js":"^9.10.0","typescript":"^5.6.2","@types/jest":"^29.5.12","typescript-eslint":"^8.5.0","@typescript-eslint/parser":"^8.5.0","@typescript-eslint/eslint-plugin":"^8.5.0"},"_npmOperationalInternal":{"tmp":"tmp/colorado_0.2.0_1726239648324_0.49944674694004343","host":"s3://npm-registry-packages"}},"0.3.0":{"name":"@avolutions/colorado","version":"0.3.0","keywords":["color"],"author":{"name":"Alexander Vogt","email":"alexander.vogt@avolutions.de"},"license":"MIT","_id":"@avolutions/colorado@0.3.0","maintainers":[{"name":"avolutions","email":"alexander.vogt@avolutions.de"}],"homepage":"https://github.com/avolutions/colorado#readme","bugs":{"url":"https://github.com/avolutions/colorado/issues"},"dist":{"shasum":"fad1395bd5122b0bb3ef5e561022cd5597c8a927","tarball":"https://registry.npmjs.org/@avolutions/colorado/-/colorado-0.3.0.tgz","fileCount":36,"integrity":"sha512-bcte/tgJ2vHYLHM925PPUylPQdFd2C/ktShkZz87QmNm7CeP2PxizZIe889+t2EC/T+jU9lXzKoS0kZysDsuYg==","signatures":[{"sig":"MEQCIEZgcaK02paW/fdeO1SeIapRpd0q3jD5fJC8Xr3jRT5cAiAj7JzvXnMcRqvthGgp8dUkpZP9NpIXOUu++jIGjPiXFg==","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":60982},"main":"dist/cjs/index.js","type":"module","types":"dist/esm/index.d.ts","module":"dist/esm/index.js","exports":{".":{"import":"./dist/esm/index.js","require":"./dist/cjs/index.js"}},"gitHead":"9d8daa40049d6d8ae577b7e34bf51fd73c7d5be6","scripts":{"lint":"eslint","test":"jest","build":"npm run build:cjs && npm run build:esm","build:cjs":"tsc --project tsconfig.cjs.json && echo {\"type\": \"commonjs\"} > dist/cjs/package.json","build:esm":"tsc --project tsconfig.esm.json","test:coverage":"jest --coverage"},"_npmUser":{"name":"avolutions","email":"alexander.vogt@avolutions.de"},"repository":{"url":"git+https://github.com/avolutions/colorado.git","type":"git"},"_npmVersion":"10.7.0","description":"Colorado is a lightweight, intuitive and dependency free JavaScript library for handling and converting color values. Seamlessly switch between RGB and Hex formats with simple methods and generate clean string outputs for your web projects.","directories":{},"_nodeVersion":"18.20.4","_hasShrinkwrap":false,"devDependencies":{"jest":"^29.7.0","eslint":"^9.10.0","globals":"^15.9.0","ts-jest":"^29.2.5","@eslint/js":"^9.10.0","typescript":"^5.6.2","@types/jest":"^29.5.12","typescript-eslint":"^8.5.0","@typescript-eslint/parser":"^8.5.0","@typescript-eslint/eslint-plugin":"^8.5.0"},"_npmOperationalInternal":{"tmp":"tmp/colorado_0.3.0_1727110143327_0.8230143785820119","host":"s3://npm-registry-packages"}},"0.3.1":{"name":"@avolutions/colorado","version":"0.3.1","description":"Colorado is a lightweight, intuitive and dependency free JavaScript library for handling and converting color values. Seamlessly switch between RGB and Hex formats with simple methods and generate clean string outputs for your web projects.","main":"dist/cjs/index.js","module":"dist/esm/index.js","types":"dist/esm/index.d.ts","exports":{".":{"require":"./dist/cjs/index.js","import":"./dist/esm/index.js"}},"scripts":{"build:cjs":"tsc --project tsconfig.cjs.json && node scripts/generate-cjs-package.js","build:esm":"tsc --project tsconfig.esm.json","build":"npm run build:cjs && npm run build:esm","lint":"eslint","test:coverage":"jest --coverage","test":"jest"},"type":"module","repository":{"type":"git","url":"git+https://github.com/avolutions/colorado.git"},"keywords":["color"],"author":{"name":"Alexander Vogt","email":"alexander.vogt@avolutions.de"},"license":"MIT","devDependencies":{"@eslint/js":"^9.10.0","@types/jest":"^29.5.12","@typescript-eslint/eslint-plugin":"^8.5.0","@typescript-eslint/parser":"^8.5.0","eslint":"^9.10.0","globals":"^15.9.0","jest":"^29.7.0","ts-jest":"^29.2.5","typescript":"^5.6.2","typescript-eslint":"^8.5.0"},"_id":"@avolutions/colorado@0.3.1","gitHead":"485d2f8f22a98255213396552d0da5d4566a5dd6","bugs":{"url":"https://github.com/avolutions/colorado/issues"},"homepage":"https://github.com/avolutions/colorado#readme","_nodeVersion":"18.20.4","_npmVersion":"10.7.0","dist":{"integrity":"sha512-8WgzPK5RvYaQjkOiFVGDIIyHQT+3OlC8zVbgNg8BOVZ5xJwufvZ09/mAE8SUXnU0g5VZIpMgEzCYA5sn2cbf+A==","shasum":"f8a7b036f1f874d3298993e3b39f458bb384853b","tarball":"https://registry.npmjs.org/@avolutions/colorado/-/colorado-0.3.1.tgz","fileCount":36,"unpackedSize":60972,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIDU0X/TMOPTapetlzyycJbrr6oJrROgwBxXiiPE6QhGZAiEAlgJSobpF1KzUIBaKFs7a5KRCU1wvqi8Sn0DBrQuI25U="}]},"_npmUser":{"name":"avolutions","email":"alexander.vogt@avolutions.de"},"directories":{},"maintainers":[{"name":"avolutions","email":"alexander.vogt@avolutions.de"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/colorado_0.3.1_1727112984644_0.9393744753991549"},"_hasShrinkwrap":false}},"time":{"created":"2024-09-12T13:26:49.346Z","modified":"2024-09-23T17:36:25.040Z","0.1.0":"2024-09-12T13:26:49.616Z","0.2.0":"2024-09-13T15:00:48.499Z","0.3.0":"2024-09-23T16:49:03.497Z","0.3.1":"2024-09-23T17:36:24.863Z"},"bugs":{"url":"https://github.com/avolutions/colorado/issues"},"author":{"name":"Alexander Vogt","email":"alexander.vogt@avolutions.de"},"license":"MIT","homepage":"https://github.com/avolutions/colorado#readme","keywords":["color"],"repository":{"type":"git","url":"git+https://github.com/avolutions/colorado.git"},"description":"Colorado is a lightweight, intuitive and dependency free JavaScript library for handling and converting color values. Seamlessly switch between RGB and Hex formats with simple methods and generate clean string outputs for your web projects.","maintainers":[{"name":"avolutions","email":"alexander.vogt@avolutions.de"}],"readme":"# Colorado\n\n![Tests](https://github.com/AlxndrVgt/colorado/actions/workflows/tests.yml/badge.svg)\n![npm](https://img.shields.io/npm/dw/@avolutions%2Fcolorado)\n![Version](https://img.shields.io/npm/v/@avolutions%2Fcolorado)\n![License](https://img.shields.io/npm/l/@avolutions%2Fcolorado)\n\n## About\n\n**Colorado** is a lightweight, intuitive and dependency free JavaScript library for handling and converting color values. Seamlessly switch between RGB and Hex formats with simple methods and generate clean string outputs for your web projects.\n\n## Installation\n\nTo install the **Colorado** package, run the following command via [npm](https://npmjs.com/package/@avolutions/colorado):\n\n```bash\nnpm install @avolutions/colorado\n```\n\n**Colorado** is designed to be flexible and works with both CommonJS and ES Modules. You can include it in your project using either of these systems based on your environment.\n\nFor **CommonJS**:\n```js\nconst { Color } = require('@avolutions/colorado');\n```\n\nFor **ES Modules**:\n```js\nimport { Color } from '@avolutions/colorado';\n```\n\n## Usage\n\n**Colorado** provides a straightforward API for managing and converting colors in JavaScript. Whether you're working with Hex codes or RGB values, you can easily create and convert between formats with just a few methods. Below are some common use cases and examples to help you get started.\n\n### Create colors\n\nCreating new color objects with **Colorado** is simple using the `Color` constructor. You can initialize a new color by passing either RGB values or a Hex code as an argument.\n\n#### Using RGB values\n\nYou can create a color by passing three integer values for the red, green, and blue components. Each value should be an integer between 0 and 255, representing the intensity of each color channel.\n\n```js\nconst red = new Color(255, 0, 0);\n```\n\nYou can also create a RGB color with transparency by passing a alpha value between 0 and 1 as optional fourth parameter.\n\n```js\nconst red = new Color(255, 0, 0, 0.5);\n```\n\nIt is also possible to create a color by passing a valid `rgb` or `rgba` string to the constructor.\n\n```js\nconst red = new Color('rgb(255, 0, 0)');\nconst blue = new Color('rgba(0, 255, 0, 0.5)');\n```\n\n#### Using a Hex code\n\nYou can create a color by passing a 6-digit or 3-digit Hex code. It accepts both upper and lowercase letters.\n\n```js\nconst red = new Color('#FF0000'); // same as #ff0000\nconst green = new Color('#0f0'); // same as #00ff00\n```\n\nYou can also create a Hex color with transparency by passing a 8-digit Hex code including alpha value.\n\n```js\nconst red = new Color('#FF0000CC'); // same as #ff0000\n```\n\n#### Using HTML color name\n\nThere are currently 140 predefined colors supported by all modern browsers. A list of these colors can be found [here](https://www.w3schools.com/colors/colors_names.asp).\n\nTo create a predefined color, you can either pass the name as a string or simply use the `HtmlColors` constant.\n\n```js\nimport { Color, HtmlColors } from '@avolutions/colorado';\n\nconst royalBlue = new Color(HtmlColors.RoyalBlue); // #4169E1\nconst fireBrick = new Color('firebrick'); // #B22222\n```\n\nColors created by color name or from `HtmlColors` constant are in Hex format by default, but can be converted to RGB anytime.\n\n### Checking Color Format\n\n**Colorado** provides simple methods to check whether a color is in RGB or Hex format using the `isRgb()` and `isHex()` methods. These methods are useful when you need to validate the format of the color or ensure you're working with the right type before performing conversions or operations.\n\n#### Checking if the Color is RGB\n\nThe `isRgb()` method returns `true` if the color is in RGB format, otherwise it returns `false`.\n\n```js\nconst red = new Color(255, 0, 0).isRgb(); // true\nconst green = new Color('#00FF00').isRgb(); // false\n```\n\n#### Checking if the Color is Hex\n\nSimilarly, the `isHex()` method checks if the color is in Hex format and returns `true` if it is, otherwise `false`.\n\n```js\nconst red = new Color('#FF0000').isHex(); // true\nconst green = new Color(0, 255, 0).isHex(); // false\n```\n\n### Converting Colors\n\n**Colorado** makes it simple to convert between RGB and Hex formats using the built-in methods `toRgb()` and `toHex()`. These methods allow you to easily switch between the two color representations as needed for your project.\n\n#### Converting RGB to Hex\n\nIf you have a color in RGB format, you can use the `toHex()` method to convert it to a Hex color.\n\n```js\nconst red = new Color(255, 0, 0).toHex(); // #FF0000\nconst green = new Color(0, 255, 0, 0.25).toHex(); // #00FF0040\n```\n\n#### Converting Hex to RGB\n\nSimilarly, you can convert a Hex color to a RGB color using the `toRgb()` method. This works whether the Hex code is in 6-digit or 3-digit format, and regardless of case.\n\n```js\nconst red = new Color('#FF0000').toRgb(); // 255, 0, 0\nconst green = new Color('#0f0').toRgb(); // 0, 255, 0\nconst blue = new Color('#0000FF40').toRgb(); // 0, 0, 255, 0.25\n```\n\n#### No Conversion Needed\n\nIf you attempt to convert a color from RGB to RGB or from Hex to Hex, nothing will happen. The methods `toRgb()` and `toHex()` will simply return the color in the same format if it’s already in the desired form.\n\n```js\nconst red = new Color('255, 0, 0').toRgb(); // 255, 0, 0\nconst green = new Color('#00ff00').toHex(); // #00ff00\n```\n\n### Outputting Colors as Strings\n\nThe `toString()` method in **Colorado** provides an easy way to output a color in string format. Depending on whether the color is in RGB or Hex format, the `toString()` method will return the appropriate representation.\n\n#### RGB Colors\n\nIf the color is in RGB format, `toString()` will return a string in the format `rgb(r, g, b)`, where `r`, `g`, and `b` are the integer values for the red, green, and blue channels.\n\n```js\nconst red = new Color(255, 0, 0).toString(); // 'rgb(255, 0, 0)'\nconst green = new Color('#00ff00').toRgb().toString(); // 'rgb(0, 255, 0)'\n```\n\nIf you pass `true` as a parameter to `toString()`, it will return a string in the format `rgba(r, g, b, a)`,  where `r`, `g` and `b` are the integer values for the red, green, and blue channels and `a` is the decimal value for alpha channel.\n\n```js\nconst red = new Color(255, 0, 0).toString(true); // 'rgba(255, 0, 0, 1)'\nconst green = new Color(0, 255, 0, 0.75).toString(true); // 'rgba(0, 255, 0, 0.75)'\n```\n\n#### Hex Colors\n\nIf the color is in Hex format, `toString()` will return the Hex code as a string, including the # symbol. The output will be in 6-digit and match the original case (upper- or lowercase).\n\n```js\nconst red = new Color('#F00').toString(); // '#FF0000'\nconst blue = new Color('#0000FF').toString(); // '#0000FF'\nconst green = new Color(0, 255, 0).toHex().toString(); // '#00FF00'\n```\n\nBy passing `true` as a parameter to `toString()` you will receive a 8-digit Hex string including the alpha channel.\n\n```js\nconst red = new Color('#FF0000').toString(true); // '#FF0000FF'\nconst green = new Color('#00FF00CC').toString(true); // '#00FF00CC'\nconst blue = new Color(0, 0, 255, 0.68).toHex().toString(true); // '#0000FFAD'\n```\n\n## License\n\nThis project is licensed under the **MIT License**. For more details, see the [LICENSE](https://github.com/avolutions/colorado/blob/main/LICENSE) file included in the repository.","readmeFilename":"README.md"}