JSPM

mix-colors-palette

1.0.1
  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 2
  • Score
    100M100P100Q21348F
  • License ISC

Mix two different colors/array of colors together.

Package Exports

  • mix-colors-palette
  • mix-colors-palette/index.js

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (mix-colors-palette) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

Mix colors

Mix two colors/array of colors together and get mixed colored or average of both colors.

RGB and HEX support?

Yes, it can convert both Hex and RGB colors.

Installation

npm install mix-colors-palette

Hex Usage

import { mixColors, blendColors } from "mix-colors-palette";

// mix colors array
// mixColors([c1,c2,...],ratio) // default ration 0.5 - min 0 - max 1
mixColors(["#000000", "#ffffff", "#ff0000"], 0.5); // return #bf3f3f

// mix two colors only
// blendColors(color1,color2,ratio) // default ration 0.5 - min 0 - max 1
blendColors("#000000", "#FFFFFF", 0.5); // returns #7F7F7F

RGB Usage

import { mixColors, blendColors } from "mix-colors-palette";

// mix colors array
// mixColors([c1,c2,...],ratio) // default ration 0.5 - min 0 - max 1
mixColors(
  [
    { r: 0, g: 0, b: 0 },
    { r: 255, g: 255, b: 255 },
  ],
  0.5
); // return #7f7f7f

// mix two colors only
// blendColors(color1,color2,ratio) // default ration 0.5 - min 0 - max 1
blendColors({ r: 0, g: 0, b: 0 }, { r: 255, g: 255, b: 255 }, 0.5); // returns #7F7F7F

Contributing

Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.

Please make sure to update tests as appropriate.