# circular-color-picker

> 圆环颜色选择器

Latest version **1.0.14** (published 2020-06-02) · ISC license · 0 weekly downloads

## Install

```sh
npm install circular-color-picker
pnpm add circular-color-picker
yarn add circular-color-picker
bun add circular-color-picker
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.14 |
| Published | 2020-06-02 |
| First published | 2020-06-01 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 44.4 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 2 |
| Author | wei.jialiu |
| Maintainers | weijialiu |
| Keywords | color picker, circular color picker |

## Links

- npm: https://www.npmjs.com/package/circular-color-picker
- Repository: https://github.com/weijialiu06/color-picker
- Homepage: https://github.com/weijialiu06/color-picker#readme
- Issues: https://github.com/weijialiu06/color-picker/issues
- npm.io page: https://npm.io/package/circular-color-picker

## Alternatives

- [postcss-color-hex-alpha](https://npm.io/package/postcss-color-hex-alpha.md) — 6.4M weekly downloads
- [randomcolor](https://npm.io/package/randomcolor.md) — 348.0K weekly downloads
- [bows](https://npm.io/package/bows.md) — 1.3K weekly downloads
- [ep_prefer_color_scheme](https://npm.io/package/ep_prefer_color_scheme.md) — 260 weekly downloads
- [coc-yank](https://npm.io/package/coc-yank.md) — 61 weekly downloads

## Recent versions

- 1.0.14 (latest) — 2020-06-02
- 1.0.13 — 2020-06-01
- 1.0.12 — 2020-06-01
- 1.0.11 — 2020-06-01
- 1.0.10 — 2020-06-01

## README

# circular-color-picker

圆环颜色选择器

## 安装

```
npm i circular-color-picker --save-dev
```

## 使用

```js
const colorWheel = new ColorWheel(config);
// 通过监听colorChange 事件获取但前的颜色值
interface IColorValue {
  // rgb颜色
  rgb: {
    r: number,
    g: number,
    b: number,
  };
  // 十六进制颜色
  hex: string;
  // 滑块的位置信息
  dotPosition: {
    left: number,
    top: number,
  };
}
colorWheel.addListener('colorChange', (data: IColorValue) => {
  console.log(data);
});
```

## config options

| config         | 说明                                        | 是否必须 |
| -------------- | ------------------------------------------- | -------- |
| containerId    | canvas 色环需要挂载的父元素 id              | 是       |
| size           | 颜色画板圆的直径大小                        | 否       |
| dotClass       | 滑块的 class 样式，需加上!important 覆盖    | 否       |
| pipeCircleSize | 中间镂空部分圆的直径大小                    | 否       |
| dotPosition    | {left: number, top: number } 滑块默认的位置 | 否       |

## Events

### colorChange

每次拖拽都会触发 colorChange 事件，事件的返回值是一个包含了当前位置颜色信息的对象；

```js
colorPicker.addListener('colorChange', (data: IColorValue) => {
  console.log(data);
});
```

## Events

### setDotPosition(left: number, y: number)

设置滑块的位置

## demo

**html template**

```html
<div>
  <div class="picker-container" id="color-picker"></div>
</div>
```

**js**

```js
@Component
export default class App extends Vue {
  mounted() {
    const colorWheel = new ColorWheel({
      size: 535,
      containerId: 'color-picker',
      pipeCircleSize: 100,
      dotClass: 'dot-class',
      dotPositon: {
        left: 100,
        top: 400,
      },
    });

    colorWheel.addListener('colorChange', (data: IColorValue) => {
      console.log(data);
    });

    setTimeout(() => {
      colorWheel.setDotPosition(300, 400);
    }, 3000);
  }
}
```

---
_Source: https://npm.io/package/circular-color-picker · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
