1.1.3 • Published 6 months ago

canvas-color-disc v1.1.3

Weekly downloads
-
License
MIT
Repository
github
Last release
6 months ago

production

一个Vue的canvas色盘选择组件,支持移动端和PC端

avatar

Build Setup

# install dependencies
npm i canvas-color-disc --save

yarn

# install dependencies
yarn add canvas-color-disc

main.js添加组件

import CanvasColorDisc from 'canvas-color-disc'
Vue.use(CanvasColorDisc)
<template>
    <div id="app">
        <p>RGB: {{RGB}}</p>
        <p>Hex: {{Hex}}</p>
        <CanvasColorDisc
            id="0"
            :color="RGB"
            :width="300"
            :height="240"
            @change="changeColor"></CanvasColorDisc>
    </div>
</template>

<script>
export default {
    name: 'App',
    data() {
        return {
            // RGB: { r: 255, g:255, b:255 },
            RGB: '#ff0000',
            Hex: '',
        }
    },
    methods: {
        changeColor(newRgb, utils) {
            this.RGB = newRgb
            this.Hex = `#${utils.RGBToHex(`(${newRgb.r}, ${newRgb.g}, ${newRgb.b})`)}`.toUpperCase()
        },
    },
}
</script>

<style>
    html {
        font-family: "Microsoft Sans Serif", Arial, Helvetica, sans-serif
    }
</style>
参数说明类型默认值
idcanvas id拼接String"0"
color默认颜色Object | String(如:"#FF0000"){"r": 255, "g": 255, "b": 255}
widthcanvas画板宽度Numberwindow.innerWidth * 0.7
heightcanvas画板高度Numberwindow.innerWidth * 0.78
事件说明回调参数
change选择结束回调rgb: 颜色, Util: 内置util,可以转换颜色(Util.hvsToRGB、Util.RGBToHvs、Util.RGBToHex、Util.hexToRGB、Util.RGBToHsv、Util.hsvToRgb)
1.1.1

6 months ago

1.1.0

6 months ago

1.1.3

6 months ago

1.1.2

6 months ago

1.0.14

6 months ago

1.0.13

6 months ago

1.0.12

6 months ago

1.0.11

3 years ago

1.0.10

3 years ago

1.0.9

3 years ago

1.0.8

3 years ago

1.0.7

3 years ago

1.0.6

3 years ago

1.0.5

3 years ago

1.0.4

3 years ago

1.0.3

3 years ago

1.0.2

3 years ago

1.0.1

3 years ago

1.0.0

3 years ago