# tui-color-analysis 颜色分析器

介绍

color analysis,图片颜色分析,传入图片获取图片主颜色。

# 引入

//根据实际路径引入
import ColorAnalysis from '../../../components/common/tui-color-analysis/tui-color-analysis.js';

# 代码演示

部分功能演示,具体可参考示例程序以及文档API。

//tui-color-palette 为canvas id
let colorAnalysis = new ColorAnalysis('tui-color-palette');

colorAnalysis.getPalette({
		width: canvasWidth,
		height: canvasHeight,
		imgPath: res.tempFilePaths[0],
		maxColors: this.maxColors,
		step: 1
	},
	colorArr => {
		if (colorArr) {
			console.log(colorArr);
		}
	}
);

# Methods

方法名 说明 传入参数
getPalette 获取主要色调 {width:width,height...},callback
getPalette方法传入参数说明

{ } :类型 Object,各参数说明:width 画布宽度,height 画布高度,imgPath 图片路径,maxColors 最大颜色数 。

callback :回调函数,返回颜色信息。

👇

# 预览

# 线上程序扫码预览

ThorUI组件库 H5二维码 ThorUI示例
ThorUI组件库小程序码 H5二维码 ThorUI示例小程序码