npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2025 – Pkg Stats / Ryan Hefner

clip-js

v0.2.0

Published

一个抠图工具, 支持桌面/移动端

Readme

clip

:zap: 一个抠图工具

安装

npm i --save clip-js

CDN

https://unpkg.com/clip-js/dist/clip.umd.js
https://unpkg.com/clip-js/dist/clip.common.js
https://unpkg.com/clip-js/dist/clip.es.js

基本使用

const pc = new Clip(document.getElementById('c'), '../5.jpg');
pc.on('loaded', ()=>{
    // 截图生成base64
    const dataURL = pc.clip();
});

API

构造函数参数

|属性|说明|数据类型|默认值| |---|---|---|---| |simplify|线段简化系数|Number|30| |circleRadius|画笔端点的圆的半径|Number|48| |circleColor|画笔端点的圆的颜色|String|rgba(0,0,0,0.6)| |lineWidth|画笔线条宽度|Number|32| |lineColor|画笔线条颜色|String|rgba(201,91,96,.9)| |magnifierWidth|放大镜宽度|Number|200| |magnifierHeight|放大镜高度|Number|200|

方法

set:

签名: (options)=>void

初始化后, 修改参数, 参数同构造函数参数.

toggleMode

签名: ()=>void

切换"画笔"和"移动画布"模式.

zoomIn

签名: ()=>void

背景放大

zoomOut

签名: ()=>void

背景缩小

back

签名: ()=>void

后退.

reset

签名: ()=>void

撤销所有画笔的操作.

clip

签名: ()=>string

生成切图的base64

changeImage

签名: (string)=>void

切换背景图

destroy

签名: ()=>void

销毁

isClosed

签名: ()=>boolean

路径是否闭合

属性

mode 当前模式

钩子

loaded

图片加载成功

clipJS.on('loaded', ()=>{
    // 图片加载成功后
});

pen-start

落笔

pen-move

移动笔

pen-end

笔离开

drag-border-start

拖拽闭合边框开始

drag-border-move

拖拽闭合边框中

drag-border-end

触点离开闭合边框