Socket
Socket
Sign inDemoInstall

@coffeekraken/s-color

Package Overview
Dependencies
630
Maintainers
1
Versions
22
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    @coffeekraken/s-color

Clean and powerful class to handle colors. You can convert your color in and formats, manipulate it by desaturate it or whatever as well as access each properties of the color like "h", "s", "l", etc...


Version published
Maintainers
1
Created

Readme

Source

@coffeekraken/s-color

MIT 2.0.0-alpha.20 - Git repository

size downloads license discord

Clean and powerful class to handle colors. You can convert your color in and formats, manipulate it by desaturate it or whatever as well as access each properties of the color like "h", "s", "l", etc...

Install

npm i @coffeekraken/s-color

SColor

This SColor class allows you to manipulate and convert colors with ease. Here's some of the features supported:

  • Instanciate a color with any of these formats: hex, hsl(a) and rgb(a)
  • Get color values like r, g, b, a, h, s and l
  • Convert your color from and to any of these formats listed above.
  • Get back your color in any format using the toRgbaString, toHexString, etc...
  • Manipulate your color using these methods:
    • apply: Apply some modifiers like "--darken 30 --alpha 0.2"
    • desaturate: Desaturate your color by x [0,100]
    • saturate: Saturate your color by x [0,100]
    • greyscale: Transform your color to greyscale
    • spin: Update the hue by x [-100,100]
    • darken: Darken your color by x [0,100]
    • lighten: Lighten your color by x [0,100]
    • invert: Invert your color

Usage

Here's how to use our implementation:

import __SConductor from '@coffeekraken/s-color';
const color = new __SColor('#ff0000').darken(20).invert();
console.log(color.toHexString());
console.log(color.toHslString());

API

For more information about the API of this class, please check our API documentation

Settings
SColorSettingsInterface
returnNewInstance

Specify if the methods returns by default a new SColor instance or the same

defaultFormat
hex

Specify the default format of the color

License

Distributed under the MIT License. See LICENSE for more information.

Contact

Here's all the ways you can contact us listed:

discord email

FAQs

Last updated on 15 Sep 2023

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.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc