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

react-polybrush-2d

v1.1.1

Published

![version](https://img.shields.io/badge/version-1.1.0-blue.svg)

Downloads

5

Readme

react-polybrush-2d

version

基于 Zrender 的标记工具,可以用于图片的区域绘制,并获得相应的绘制点坐标。

如何使用

yarn add react-polybrush-2d
import React from "react";
import ReactDOM from "react-dom";
import PolyBrush2D from "react-polybrush-2d";

const App = () => {
  return (
    <PolyBrush2D
      width={500}
      height={300}
      background={"#666"}
      errorColor={"#ff4d4f"}
      type={type}
      color={color}
      logging={true}
      onComplete={handleComplete}
      onBeforeDraw={handleOnBeforeDraw}
      onUndo={handleUndo}
    />
  );
};

const root = document.getElementById("root");
ReactDOM.render(<App />, root);

绘制多边形,右键自动闭合

成功

线段交叉则不能自动闭合

失败

绘制线段

绘制线段

Props

| 参数 | 类型 | 说明 | 默认值 | 必填 | | ---------- | ------------------------------- | -------------------------------------------------- | ------- | ---- | | background | string | 绘制区域背景色 | #000000 | / | | beforeDraw | (event: MouseEvent) => boolean; | 生命周期,开始绘制前,true 开始绘制 false 停止绘制 | - | / | | color | string | 当前线段颜色,可以动态修改,仅支持 hex 格式 | #1890ff | / | | errorColor | string | 两条线段相交时的提示颜色 | #f5222d | / | | height | string | number | 绘制区域高度 | - | / | | logging | boolean | 是否显示绘制日志 | false | / | | onComplete | (group: Group) => void | 生命周期,绘制完成 | - | / | | onMove | (event: MouseEvent) => void | 生命周期,绘制中 | - | / | | onUndo | (group: Group) => void | 生命周期,撤销 | - | / | | type | string | 绘制的形状 polygon 多边形 line 线段 | polygon | / | | width | string | number | 绘制区域宽度 | - | / |

Events

| 参数 | 说明 | 返回值 | | ------------- | -------------------------------------- | ------- | | undo | 撤销前一个绘制的图形 | void | | getDataSource | 获取全部绘制的图形数据,查看控制台输出 | Group[] |

更新日志

1.1.1

  • 🐞 修复声明文件

1.1.0

  • 🐞 修复组件销毁后未解除已绑定的事件
  • 🐞 修改 zrender 定义文件
  • 🐞 修复绘制过程中可以动态修改绘图类型的问题
  • 🐞 修复已绘线段无法撤销的问题
  • 🌟 添加详细的 demo 演示
  • 🌟 添加控制台绘制日志功能
  • 🌟 添加自定义交叉线提示颜色
  • 🌟 修改 api beforeDrawonBeforeDraw
  • 🌟 优化文档