color thief利用Javascript和canvas标签是怎样的
color thief利用Javascript和canvas标签是怎样的,很多新手对此不是很清楚,为了帮助大家解决这个难题,下面小编将为大家详细讲解,有这方面需求的人可以来学习下,希望你能有所收获。
Color Thief 是用于提取图片的主要颜色或者代表性颜色调色板的工具. 其使用是基于 javascript 和 canvas 的.color-thief-py 是基于 Python 和 Pillow 的实现.
color thief利用 Javascript 和 canvas 标签
获取一张图片的主要颜色
var colorThief = new ColorThief();
colorThief.getColor(sourceImage);
getColor(sourceImage[, quality])
returns {r: num, g: num, b: num}
从一张图片中创建调色板
在这个示例中,我们创建一个包含8个颜色的调色板。
var colorThief = new ColorThief();
colorThief.getPalette(sourceImage, 8);
getPalette(sourceImage[, colorCount, quality])
returns [ [num, num, num], [num, num, num], ... ]
color thief特点
Getting started
The Color Thief package includes multiple distribution files to support different environments and build processes. Here is the list of all the files in the /dist folder and what formats they support:
color-thief.js - CommonJS module for use in Node.
color-thief.mjs - ES6 module. For modern browsers as well as Webpack and Rollup.
color-thief.umd.js - UMD module. For simple script tag loading that exposes a global variable or for RequireJS AMD support.
color-thief.min.js - Duplicate of color-thief.umd.js. Kept around to maintain backwards compatibility.
看完上述内容是否对您有帮助呢?如果还想对相关知识有进一步的了解或阅读更多相关文章,请关注行业资讯频道,感谢您对的支持。