An open API service indexing awesome lists of open source software.

https://github.com/chokobole/color

A C++ utility library for color. Contents
https://github.com/chokobole/color

Last synced: 15 days ago
JSON representation

A C++ utility library for color. Contents

Awesome Lists containing this project

README

        

# Color

A C++ utility library for color.

## Contents
- [Color](#color)
- [Contents](#contents)
- [How to use](#how-to-use)
- [Usages](#usages)
- [Supported colorspace](#supported-colorspace)
- [Conversion](#conversion)
- [Named Colors](#named-colors)
- [Gradients](#gradients)
- [Gradient](#gradient)
- [StopColor](#stopcolor)
- [Gradient::StepMethod](#gradientstepmethod)
- [Colormap](#colormap)

## How to use

To use `color`, add the followings to your `WORKSPACE` file.

```python
load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")

http_archive(
name = "com_chokobole_color",
sha256 = "",
strip_prefix = "color-",
urls = [
"https://github.com/chokobole/color/archive/.tar.gz",
],
)

load("@com_chokobole_base//bazel:base_deps.bzl", "base_deps")

base_deps()

load("@com_chokobole_bazel_utils//:buildifier_deps.bzl", "buildifier_deps")

buildifier_deps()

load("@com_chokobole_bazel_utils//:buildifier_deps_deps.bzl", "buildifier_deps_deps")

buildifier_deps_deps()
```

Then, in your `BUILD` files, import and use the rules.

```python
load("@com_chokobole_color//bazel:color_cc.bzl", "color_copts")

cc_binary(
name = "name",
srcs = [...],
copts = color_copts(),
deps = ["@com_chokobole_color//:color"],
)
```

## Usages

### Supported colorspace

* `Rgb`
* `Hsv`

### Conversion

* `Hsv RgbToHsv(const Rgb& rgb)`
* `Rgb HsvToRgb(const Hsv& hsv)`

### Named Colors

There are already defined named colors listed in [color_values](https://developer.mozilla.org/ko/docs/Web/CSS/color_value). You can use like below.

```c++
color::Rgb rgb = kBlack;
```

### Gradients

#### Gradient

* `bool Colors(size_t numbers, std::vector* colors, StepMethod = STEP_METHOD_RGB) const`

#### StopColor

Members

* `Rgb color`
* `double tposition`: Should be inside between 0 and 1.

#### Gradient::StepMethod

* `STEP_METHOD_RGB`: Interpolate between stop colors by RGB step method.
* `STEP_METHOD_HSV_CW`: Interpolate between stop colors by HSV clock wise step method.
* `STEP_METHOD_HSV_CCW`: Interpolate between stop colors by HSV counter clock wise step method.

For examples,

```c++
color::Gradient gradient({kBlack, kRed});
std::vector colors;
gradient.Color(5, &colors);
```

### Colormap

For examples,

```c++
color::Colormap colormap;
std::vector colors;
colormap.Jet(24, &colors);
```

Methods

* `bool Jet(size_t numbers, std::vector* colors) const`
* `bool Hsv(size_t numbers, std::vector* colors) const`
* `bool Hot(size_t numbers, std::vector* colors) const`
* `bool Cool(size_t numbers, std::vector* colors) const`
* `bool Spring(size_t numbers, std::vector* colors) const`
* `bool Summer(size_t numbers, std::vector* colors) const`
* `bool Autumn(size_t numbers, std::vector* colors) const`
* `bool Winter(size_t numbers, std::vector* colors) const`
* `bool Bone(size_t numbers, std::vector* colors) const`
* `bool Copper(size_t numbers, std::vector* colors) const`
* `bool Greys(size_t numbers, std::vector* colors) const`
* `bool Greens(size_t numbers, std::vector* colors) const`
* `bool BlueRed(size_t numbers, std::vector* colors) const`
* `bool YIGnBu(size_t numbers, std::vector* colors) const`
* `bool YIOrRd(size_t numbers, std::vector* colors) const`
* `bool RdBu(size_t numbers, std::vector* colors) const`
* `bool Picnic(size_t numbers, std::vector* colors) const`
* `bool Rainbow(size_t numbers, std::vector* colors) const`
* `bool RainbowSoft(size_t numbers, std::vector* colors) const`
* `bool Portland(size_t numbers, std::vector* colors) const`
* `bool BlackBody(size_t numbers, std::vector* colors) const`
* `bool Earth(size_t numbers, std::vector* colors) const`
* `bool Electric(size_t numbers, std::vector* colors) const`
* `bool Alpha(size_t numbers, std::vector* colors) const`
* `bool Viridis(size_t numbers, std::vector* colors) const`
* `bool Inferno(size_t numbers, std::vector* colors) const`
* `bool Magma(size_t numbers, std::vector* colors) const`
* `bool Plasma(size_t numbers, std::vector* colors) const`
* `bool Warm(size_t numbers, std::vector* colors) const`
* `bool Bathymetry(size_t numbers, std::vector* colors) const`
* `bool CDOM(size_t numbers, std::vector* colors) const`
* `bool Chlorophyll(size_t numbers, std::vector* colors) const`
* `bool Density(size_t numbers, std::vector* colors) const`
* `bool FreeSurface_Blue(size_t numbers, std::vector* colors) const`
* `bool FreeSurface_Red(size_t numbers, std::vector* colors) const`
* `bool Oxygen(size_t numbers, std::vector* colors) const`
* `bool Par(size_t numbers, std::vector* colors) const`
* `bool Phase(size_t numbers, std::vector* colors) const`
* `bool Salinity(size_t numbers, std::vector* colors) const`
* `bool Temperature(size_t numbers, std::vector* colors) const`
* `bool Turbidity(size_t numbers, std::vector* colors) const`
* `bool Velocity_Blue(size_t numbers, std::vector* colors) const`
* `bool Velocity_Green(size_t numbers, std::vector* colors) const`
* `bool Cubehelix(size_t numbers, std::vector* colors) const`