Color Map
Description
color-map is a TypeScript library that allows developers to easily generate a wide range of colors within a specified interval of numbers. The library utilizes a unique mapping system that assigns specific colors to specific values, allowing for precise and consistent color generation. With color-map, developers can easily create color palettes for use in web and mobile applications, as well as in data visualization and graphic design projects. Whether you're a designer looking to create a cohesive color scheme or a developer building an interactive data visualization, color-map is the perfect tool for the job.
Getting Started
Dependencies
Installing
Usage
colorMap()
import colorMap from "@heyeso/color-map";
/**
* Default colors for mapping.
*/
export const test_colors = [
[255, 0, 255],
[217, 130, 181],
[128, 0, 128],
[0, 0, 255],
[135, 206, 235],
[0, 255, 0],
[27, 142, 45],
[255, 255, 0],
[255, 215, 0],
[255, 36, 0],
[255, 0, 0],
[139, 0, 0],
];
/**
* Default ranges for mapping.
*/
export const test_ranges = [-1, 4, 10, 16, 21, 27, 32, 38, -23, -18, -12, -7];
const temperatureMap = colorMap(test_colors, test_ranges);
const temp1 = temperatureMap.getColor(30);
temp1?.rgb; // { r: 255, g: 22, b: 0 }
temp1?.toString(); // "rgb(255, 22, 0)"
temp1?.toHex(); // "#ff1600"
createColor()
import { createColor } from "@heyeso/color-map";
const color = createColor([3, 40, 69]);
color.toString(); // "rgb(3, 40, 69)"
color.toHex(); // "#032845"
Sample Use
Sample use in projects.
Contributing
Contributions are what make the open source community such an amazing place to learn, inspire, and create. Any contributions you make are greatly appreciated.
If you have a suggestion that would make this better, please fork the repo and create a pull request. You can also simply open an issue with the tag "enhancement".
Don't forget to give the project a star! Thanks again!
- Fork the Project
- Create your Feature Branch (
git checkout -b feature/AmazingFeature
)
- Commit your Changes (
git commit -m 'Add some AmazingFeature'
)
- Push to the Branch (
git push origin feature/AmazingFeature
)
- Open a Pull Request
Authors
Abdulsalam Odetayo @linkedIn
License
Distributed under the MIT License. See LICENSE
for more information.
References