The Devlander Colors package provides a collection of color utilities for JavaScript, including color pickers, color schemes, and palette generation. It's used across various projects to manage and utilize color schemes effectively.
You can install the package using either Yarn or npm:
yarn add @devlander/colors
or
npm install @devlander/colors
To use the main package, you can import the Color
class and other utilities as follows:
import { Color } from "@devlander/colors"
// Create a new color instance
const myColor = new Color('#3498db')
// Darken the color
const darkenedColor = myColor.darken(10).hex()
console.log(darkenedColor) // Output: a darkened hex color
// Lighten the color
const lightenedColor = myColor.lighten(10).hex()
console.log(lightenedColor) // Output: a lightened hex color
// Get the RGB string representation
console.log(myColor.rgb()) // Output: 'rgb(52, 152, 219)'
// Invert the color
const invertedColor = myColor.invert()
console.log(invertedColor) // Output: an inverted hex color
// Apply alpha to the color
const colorWithAlpha = myColor.alpha(0.5)
console.log(colorWithAlpha) // Output: hex color with applied alpha
// Blend with another color
const secondaryColor = { r: 255, g: 0, b: 0 } // Red color
const blendedColor = myColor.blend(50, secondaryColor).hex()
console.log(blendedColor) // Output: a blended hex color
- darkenColor: Darkens a given color by a factor.
- lightenColor: Lightens a given color by a factor.
- blendColors: Blends two colors based on a given factor.
- applyAlphaToColor: Applies alpha transparency to a color.
- toHexColor: Converts a color object to a hex string.
- toRgbString: Converts a color object to an RGB string.
- hexToDecimal: Converts a hex value to a decimal.
- Discord: Join the Devlander community here.
- npm: Download the package @devlander/colors.
- GitHub Discussions: Engage with the community and get support here.
- Twitch: Watch live coding sessions here.
- Twitter: Follow Landon Johnson @landonwjohnson.
- Wakatime: Track our development progress here.
- Develop functions to generate themes based on colors and parameters.
- Implement a function to find complementary colors.
- Create a utility to extract colors from images.