Grade 正在参加 2021 年度 OSC 中国开源项目评选,请投票支持!
Grade 在 2021 年度 OSC 中国开源项目评选 中已获得 {{ projectVoteCount }} 票,请投票支持!
2021 年度 OSC 中国开源项目评选 正在火热进行中,快来投票支持你喜欢的开源项目!
2021 年度 OSC 中国开源项目评选 >>> 中场回顾
Grade 获得 2021 年度 OSC 中国开源项目评选「最佳人气项目」 !
授权协议 MIT
操作系统 跨平台
软件类型 开源软件
开源组织
地区 不详
适用人群 未知
收录时间 2016-08-24

软件简介

Grade 是一个 JavaScript 库,作用是从图像中提取前2个主要颜色产生互补的渐变。

Demo 演示地址:http://benhowdle.im/grade/

安装

下载这个库,并从 /docs/dist 文件夹中取出 grade.js

或是使用 npm 方式安装:npm install grade-js

使用

推荐使用HTML结构:

<!--the gradients will be applied to these outer divs, as background-images-->
<div class="gradient-wrap">
    <img src="./samples/finding-dory.jpg" alt="" />
</div>
<div class="gradient-wrap">
    <img src="./samples/good-dinosaur.jpg" alt="" />
</div>

如果你的项目中有 grade.js,你可以用一个 script 标签包裹它,并且像这样去初始化:

<script src="path/to/grade.js"></script>
<script type="text/javascript">    
    window.addEventListener('load', function(){        
        /*            
            A NodeList of all your image containers (Or a single Node).            
            The library will locate an <img /> within each            
            container to create the gradient from.         
        */        
        Grade(document.querySelectorAll('.gradient-wrap'))    
    })
</script>

如果你使用 npm 方式安装,也可以像这样使用库:

import Grade from 'grade-js'
// initialise as above
展开阅读全文

代码

的 Gitee 指数为
超过 的项目

评论

点击引领话题📣 发布并加入讨论🔥
暂无内容
发表了博客
{{o.pubDate | formatDate}}

{{formatAllHtml(o.title)}}

{{parseInt(o.replyCount) | bigNumberTransform}}
{{parseInt(o.viewCount) | bigNumberTransform}}
没有更多内容
暂无内容
发表了问答
{{o.pubDate | formatDate}}

{{formatAllHtml(o.title)}}

{{parseInt(o.replyCount) | bigNumberTransform}}
{{parseInt(o.viewCount) | bigNumberTransform}}
没有更多内容
暂无内容
暂无内容
0 评论
5 收藏
分享
OSCHINA
登录后可查看更多优质内容
返回顶部
顶部