colorify.js图片主色提取及背景跟随换色插件

colorify.js图片主色提取及背景跟随换色插件

colorify.js图片主色提取及背景跟随换色插件

使用 Colorify.js,,你可以:
从图像中提取主导颜色
根据图像的颜色生成渐变
隔离颜色并在页面中的任何地方操纵它们
为你的图像创建一个懒惰的revealer系统
动态加载图像

<script type="text/javascript">
    const imgs = document.getElementById('imgs');

    // Make sure image is finished loading
    if (imgs.complete) {
        console.log(colorThief.getColor(imgs));
    } else {
        imgs.addEventListener('load', function() {
            colorify({
                id: 1,
                container: 'colorify',
                images: false,
                accuracy: 100,
                gradient: false,
                gradientDirection: false,
                padding: 10,
                lazyReveal: false,
                give: false,
                revealOn: false
            });

            var span = document.getElementById('span');
            span.style.background = "rgb(" +color[0] + "," + color[1]+ "," + color[2] + ")"
        });
    }
</script>

在线查看demo http://editor.bfw.wiki/Editor/Open.html?projectid=15748222447089740088&file=demo2.html

github地址https://github.com/LukyVj/Colorify.js


立即下载colorify.js查看所有js插件

网友评论0

程序员在线工具箱