
Product
Introducing Tier 1 Reachability: Precision CVE Triage for Enterprise Teams
Socket’s new Tier 1 Reachability filters out up to 80% of irrelevant CVEs, so security teams can focus on the vulnerabilities that matter.
color-insight
Advanced tools
获取图片颜色均值,并返回rgba数组
安装 npm i color-insight
import { colorInsight } from 'color-insight';
(async () => {
const imgSrc = './src/assets/img/test.jpg'
const rgba = await colorInsight(src);
// return [255,255,255,1]
})()
如果图片域和当前域不同时,需要配置CORS,否则无法获取到图片颜色
轮播图由swiper实现,此插件不包含轮播图代码,可以参考./src/main.ts
import {colorInsight} from './utils/index'
(function() {
const bgColor = new Array(5);
new Swiper('.swiper', {
autoplay: true,
loop: true,
speed: 100,
delay: 1000,
pagination: {
el: '.swiper-pagination',
},
navigation: {
nextEl: '.swiper-button-next',
prevEl: '.swiper-button-prev',
},
on: {
init: async () => {
const src = document.getElementById(`slide_1`)?.src;
const rgba = bgColor[0] || await colorInsight(src);
document.getElementById('app').style.background = `rgba(${rgba.join(",")})`;
const titleMaskColor = [...rgba];
titleMaskColor[titleMaskColor.length - 1] = 0.7;
document.getElementById('slide_title_1').style.background = `rgba(${titleMaskColor.join(",")})`;
bgColor[0] = rgba;
},
slideChangeTransitionStart: async ({realIndex}) => {
const src = document.getElementById(`slide_${realIndex + 1}`)?.src;
const rgba = bgColor[realIndex] || await colorInsight(src);
bgColor[realIndex] = rgba;
setTimeout(() => {
document.getElementById('app').style.background = `rgba(${rgba.join(",")})`;
const titleMaskColor = [...rgba];
titleMaskColor[titleMaskColor.length - 1] = 0.7;
document.getElementById(`slide_title_${realIndex + 1}`).style.background = `rgba(${titleMaskColor.join(",")})`;
}, 10)
}
}
});
})()
npm i
npm run dev
FAQs
We found that color-insight demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 0 open source maintainers collaborating on the project.
Did you know?
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.
Product
Socket’s new Tier 1 Reachability filters out up to 80% of irrelevant CVEs, so security teams can focus on the vulnerabilities that matter.
Research
/Security News
Ongoing npm supply chain attack spreads to DuckDB: multiple packages compromised with the same wallet-drainer malware.
Security News
The MCP Steering Committee has launched the official MCP Registry in preview, a central hub for discovering and publishing MCP servers.