New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details →
Socket
Book a DemoSign in
Socket

lightordark

Package Overview
Dependencies
Maintainers
1
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

lightordark

Determine if a color is light or dark

latest
npmnpm
Version
0.1.1
Version published
Maintainers
1
Created
Source

Lightordark

install

npm install lightordark

在文件中引入:

var lightordark = require('lightordark');

Usage

getLuminance

获取亮度

lightordark.getLuminance('#cdf'); // 0.7177027204456372

getContrast

获取对比度

lightordark.getContrast('#666', '#fff'); // 5.74183648145415
lightordark.getContrast(lightordark.mixColor('rgba(0,0,0,.6)', '#fff'), '#fff'); // 5.74183648145415

mixColor

Alpha 混合 支持前景色半透明

lightordark.mixColor('rgba(0,0,0,.6)', '#fff'); // #666666
lightordark.mixColor('#666', '#fff'); // #666666

contrast

判断是浅色还是暗色 支持调节最小对比度

lightordark.contrast('#888'); // dark
lightordark.contrast('#888', 7); // light

FAQs

Package last updated on 26 Sep 2018

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts