Security News
Fluent Assertions Faces Backlash After Abandoning Open Source Licensing
Fluent Assertions is facing backlash after dropping the Apache license for a commercial model, leaving users blindsided and questioning contributor rights.
@scidian/iris
Advanced tools
Color library with support for RGB, RYB, HSL color models and RYB hue shifting.
Small, fast, dependency free JavaScript color library with support for the RGB, RYB, and HSL color models and easy interaction with HTML, CSS, and third party frameworks.
Features
Iris
and THREE.Color
.Iris.js
to project, import from file...import { Iris } from 'Iris.js';
npm install @scidian/iris
import { Iris } from '@scidian/iris';
import { Iris } from 'https://unpkg.com/@scidian/iris/build/iris.module.js';
new Iris(); // Defaults to white, 0xffffff
new Iris(0xff0000); // Hexadecimal (0xff0000, i.e. 16711680)
new Iris(1.0, 0.0, 0.0); // RGB Values (0.0 to 1.0)
new Iris(255, 0, 0, 'rgb'); // RGB Values (0 to 255)
new Iris(255, 0, 0, 'ryb'); // RYB Values (0 to 255)
new Iris(360, 1.0, 0.5, 'hsl'); // HSL Values (H: 0 to 360, SL: 0.0 to 1.0)
new Iris({ r: 1.0, g: 0.0, b: 0.0 }); // Object, RGB Properties (0.0 to 1.0)
new Iris({ r: 1.0, y: 0.0, b: 0.0 }); // Object, RYB Properties (0.0 to 1.0)
new Iris({ h: 1.0, s: 1.0, l: 0.5 }); // Object, HSL Properties (0.0 to 1.0)
new Iris([ 1.0, 0.0, 0.0 ], offset); // RGB Array (0.0 to 1.0), optional offset
new Iris('#ff0000'); // Hex String (also 3 digits: '#f00')
new Iris('rgb(255, 0, 0)'); // CSS Color String
new Iris('red'); // X11 Color Name
new Iris(myIrisColor); // Copy from Iris Color Object
new Iris(myThreeColor); // Copy from Three.js Color Object
const color = new Iris(0xff0000);
console.log(color.rybRotateHue(270).darken(0.5).hexString().toUpperCase());
output
#2E007F
const color = new Iris(0xff0000);
// To find the RYB color wheel complement (opposite) color
const complement = new Iris.set(color).rybComplementary();
// To adjust hue a specific number of degrees (0 to 360) around the RYB color wheel
const tetrad1 = new Iris.set(color).rybRotateHue(90);
const tetrad2 = new Iris.set(color).rybRotateHue(270);
// Some possible ways to initialize Iris using THREE.Color
const eyeColor = new Iris(threeColor);
const eyeColor = new Iris(threeColor.getHex());
const eyeColor = new Iris(threeColor.toArray());
// Some possible ways to initialize THREE.Color using Iris
const threeColor = new THREE.Color(eyeColor);
const threeColor = new THREE.Color(eyeColor.hex());
const threeColor = new THREE.Color(eyeColor.hexString());
// Some possible ways to copy the values of the THREE.Color back to Iris
eyeColor.copy(threeColor);
eyeColor.set(threeColor.getHex());
eyeColor.setRGBF(threeColor.r, threeColor.g, threeColor.b);
// Some possible ways to copy the values of the Iris back to THREE.Color
threeColor.copy(eyeColor);
threeColor.setHex(eyeColor.hex());
threeColor.setRGB(eyeColor.r, eyeColor.g, eyeColor.b);
Red channel value between 0.0 and 1.0, default is 1.
Green channel value between 0.0 and 1.0, default is 1.
Blue channel value between 0.0 and 1.0, default is 1.
Copies the r, g, b properties from colorObject. This Object can be any type as long as it has r, g, b properties containing numeric values ranging from 0.0 to 1.0.
Returns a new Iris Object with the same color value as this Iris Object.
All arguments are optional. Sets this color based on a wide range of possible inputs, all options are the same as with the constructor.
Sets this color based on a X11 color name.
Sets this color based on a hexidecimal / decimal value (i.e. 0xff0000 or 16711680).
Sets this color based on hue (0 to 360), saturation (0.0 to 1.0), and lightness (0.0 to 1.0) values.
Sets this color to a random color.
Sets this color based on a red, green, and blue values ranging from 0 to 255.
Sets this color based on a red, green, and blue values ranging from 0.0 to 1.0.
Sets this color based on a red, yellow, and blue values ranging from 0 to 255.
Sets this colors red, green, and blue values all equal to a singular value ranging from 0 to 255.
Sets this colors red, green, and blue values all equal to a singular value ranging from 0.0 to 1.0.
Sets this color based on CSS ('rgb(255,0,0)' / 'hsl(360,50%,50%)'), Hex ('#FF0000'), or X11 ('darkred') strings.
Returns string for use with CSS, for example "rgb(255, 0, 0)". Optionally include an alpha value from 0 to 255 to be included with the string, for example "rgba(255, 0, 0, 255)".
Returns value as hexidecimal.
Returns value as hex string for use in CSS, HTML, etc. Example: "#ff0000". If optional hexColor is supplied, the returned string will be for the supplied color, not the underlying value of the current Iris Object.
Returns value as inner section of cssString(). For example "255, 0, 0". This allows you to write to CSS variables for use with custom alpha channels in your CSS. Optional alpha value.
Returns value as hexidecimal, JSON friendly data.
Provide an optional target to copy hue, saturation, lightness values into, they will be in the range 0.0 to 1.0. If no target is provided a new Object with h, s, l properties is returned.
Provide an optional target to copy red, green, blue values into, they will be in the range 0.0 to 1.0. If no target is provided a new Object with r, g, b properties is returned.
Provide an optional target to copy red, yellow, blue values into, they will be in the range 0.0 to 1.0. If no target is provided a new Object with r, y, b properties is returned.
Provide an optional array to copy red, green, blue values into, they will be in the range 0.0 to 1.0. Optionally provide an offset to specify where in the array to write the data. If no array is provided a new Array will be returned.
Returns red value of current Iris object in range 0 to 255.
Returns green value of current Iris object in range 0 to 255.
Returns blue value of current Iris object in range 0 to 255.
Returns red value of current Iris object in range 0.0 to 1.0.
Returns green value of current Iris object in range 0.0 to 1.0.
Returns blue value of current Iris object in range 0.0 to 1.0.
Returns hue value of current Iris object in range 0 to 360.
Returns saturation value of current Iris object in range 0.0 to 1.0.
Returns lightness value of current Iris object in range 0.0 to 1.0.
Returns hue value of current Iris object in range 0.0 to 1.0.
Returns the RYB adjusted hue value of current Iris object in range 0 to 360.
Adds the red, green, blue values from color to this Iris Object's values.
Adds the value scalar to the red, green, blue of this Iris Object, scalar should be in range -255 to 255.
Adds the value scalar to the red, green, blue of this Iris Object, scalar should be in range -1.0 to 1.0.
Increases the lightness of this Iris Object by amount as a percentage of the remainder of 100% lightness less the current lightness. For example, if the current hsl lightness value is 0.6 (between 0.0 and 1.0), an amount of 0.5 will increase the lightness value to 0.6 + ((1.0 - 0.6) * 0.5) = 0.8, an amount value of 1.0 will always bring lightness value up to 1.0 (100%).
Decreases the lightness of this Iris Object by amount. A value of 0.5 (default) will decrease lightness by 50%, a value of 2.0 will double lightness.
Changes color into grayscale by percent ranging from 0.0 to 1.0. This can be done by type 'average' which takes an average of the red, green, blue values. Or by default type of 'luminosity' which scales red, green, blue values according to how human eyes see color (see details at GIMP).
Change the HSL values of this Iris object by h (-360 to 360), s (-1.0 to 1.0), and l (-1.0 to 1.0).
Mixes in another Iris Object's color value to this Iris Object by percent (default of 0.5, i.e. 50%).
Multiplies another Iris Object's RGB values to this Iris Object's RGB values.
Multiplies this Iris Object's RGB values by scalar. There is no range for scalar, however, color values will be clamped between 0.0 and 1.0 after multiplication.
Adjusts this color to be 180 degress (opposite) of the current color on the RGB color wheel.
Adjusts this color to be degress of the current color on the RGB color wheel, range from -360 to 360.
Adjusts the RGB values to fit in the RYB spectrum as best as possible.
Adjusts this color to be 180 degress (opposite) of the current color on the RYB color wheel.
Adjusts this color to be degress of the current color on the RYB color wheel, range from -360 to 360.
Subtracts the red, green, blue values from color to this Iris Object's values.
Returns true if the RGB values of color are the same as those of this Object.
Returns true if this Iris Object's color value would be considered "dark", helpful for determining whether of not to use black or white text with this color as a background.
Returns true if this Iris Object's color value would be considered "light", helpful for determining whether of not to use black or white text with this color as a background.
FAQs
Color library with support for RGB, RYB, HSL color models and RYB hue shifting.
We found that @scidian/iris demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Fluent Assertions is facing backlash after dropping the Apache license for a commercial model, leaving users blindsided and questioning contributor rights.
Research
Security News
Socket researchers uncover the risks of a malicious Python package targeting Discord developers.
Security News
The UK is proposing a bold ban on ransomware payments by public entities to disrupt cybercrime, protect critical services, and lead global cybersecurity efforts.