https://github.com/ngageoint/color-js
Color Javascript Library
https://github.com/ngageoint/color-js
color colors hex hex-color hex-colors hsl hsl-color javascript nga rgb rgb-color rgb-colors rgba
Last synced: about 1 month ago
JSON representation
Color Javascript Library
- Host: GitHub
- URL: https://github.com/ngageoint/color-js
- Owner: ngageoint
- License: mit
- Created: 2022-09-12T16:26:09.000Z (over 2 years ago)
- Default Branch: master
- Last Pushed: 2022-10-31T17:56:48.000Z (over 2 years ago)
- Last Synced: 2024-04-27T21:40:17.719Z (about 1 year ago)
- Topics: color, colors, hex, hex-color, hex-colors, hsl, hsl-color, javascript, nga, rgb, rgb-color, rgb-colors, rgba
- Language: TypeScript
- Homepage: https://ngageoint.github.io/color-js
- Size: 646 KB
- Stars: 0
- Watchers: 11
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Color Javascript
#### Color Lib ####
The Color Library was developed at the [National Geospatial-Intelligence Agency (NGA)](http://www.nga.mil/) in collaboration with [BIT Systems](https://www.caci.com/bit-systems/). The government has "unlimited rights" and is releasing this software to increase the impact of government investments by providing developers with the opportunity to take things in new directions. The software use, modification, and distribution rights are stipulated within the [MIT license](http://choosealicense.com/licenses/mit/).
### Pull Requests ###
If you'd like to contribute to this project, please make a pull request. We'll review the pull request and discuss the changes. All pull request contributions to this project will be released under the MIT license.Software source code previously released under an open source license and then modified by NGA staff is considered a "joint work" (see 17 USC § 101); it is partially copyrighted, partially public domain, and as a whole is protected by the copyrights of the non-government authors and must be released according to the terms of the original open source license.
### About ###
Color-js is a javascript library providing color representation with support for hex, RBG, arithmetic RBG, HSL, and integer colors.
### Build and Installation ###

[](https://www.npmjs.com/package/@ngageoint/color-js)
[](https://coveralls.io/github/ngageoint/color-js)```sh
$ npm install @ngageoint/color-js
```### Usage ###
```javascript
const rgb: Color = new Color();
rgb.setRGB(154, 205, 50);
const rgba: Color = new Color();
rgba.setRGB(255, 165, 0);
rgba.setAlpha(64);
const rgbOpacity: Color = new Color();
rgbOpacity.setRGB(255, 165, 0);
rgbOpacity.setOpacity(0.25);
const arithmeticRGB: Color = new Color();
arithmeticRGB.setRGB(1.0, 0.64705882352, 0.0);
const arithmeticRGBOpacity: Color = new Color();
arithmeticRGBOpacity.setRGB(1.0, 0.64705882352, 0.0);
arithmeticRGBOpacity.setOpacity(0.25098039215);
const hex: Color = Color.color("#BA55D3");
const hexAlpha: Color = Color.color("#D9FFFF00");
const hexInteger: Color = new Color();
hexInteger.setColor(0xFFC000);
const hexIntegerAlpha: Color = new Color();
hexIntegerAlpha.setColor(0x40FFA500);
const integer: Color = new Color();
integer.setColor(16711680);
const integerAlpha: Color = new Color();
integerAlpha.setColor(-12303292);
const hexSingles: Color = new Color();
hexSingles.setRGB("FF", "C0", "CB");
const hexSinglesAlpha: Color = new Color();
hexSinglesAlpha.setRGB("00", "00", "00", "80")
const hexSinglesOpacity: Color = new Color();
hexSinglesOpacity.setRGB("FF", "A5", "00");
hexSinglesOpacity.setOpacity(0.25);
const hsl: Color = new Color();
hsl.setColorByHSL(300.0, 1.0, 0.2509804);
const hsla: Color = new Color();
hsla.setColorByHSL(60.0, 1.0, 0.5, 0.85098039215);
const orangeAlpha: Color = Color.color(ColorConstants.ORANGE);
orangeAlpha.setAlpha(120);
const orangeOpacity: Color = Color.color(ColorConstants.ORANGE);
orangeOpacity.setOpacity(0.25);const color = Color.blue();
color.setAlpha(56);
const hexValue: string = color.getColorHex();
const hexShorthand: string = color.getColorHexShorthand();
const hexWithAlpha: string = color.getColorHexWithAlpha();
const hexShorthandWithAlpha: string = color.getColorHexShorthandWithAlpha();
const integerValue: number = color.getColor();
const integerAlphaValue: number = color.getColorWithAlpha();
const red: number = color.getRed();
const greenArithmetic: number = color.getGreenArithmetic();
const blueHex: string = color.getBlueHex();
const alphaHexShorthand: string = color.getAlphaHexShorthand();
const opacity: number = color.getOpacity();
const hslValue: number[] = color.getHSL();
const hue: number = color.getHue();
const saturation: number = color.getSaturation();
const lightness: number = color.getLightness();```