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 🙏

© 2026 – Pkg Stats / Ryan Hefner

leafer-x-dotwuxian

v0.0.3

Published

轻量的 `DotMatrix` 插件,为 `@leafer-ui` 提供可缩放、对齐的点/线网格背景,用于增强画布/画板类应用的视觉参考。

Readme

leafer-x-dotwuxian

轻量的 DotMatrix 插件,为 @leafer-ui 提供可缩放、对齐的点/线网格背景,用于增强画布/画板类应用的视觉参考。

特点

  • 支持 dotslines 两种网格样式
  • 根据 zoom 动态计算多层网格,平滑过渡
  • 对齐主次网格,避免重复绘制(性能优化)
  • 支持多种颜色格式:#rgb#rrggbbrgb(a)
  • 可开启/关闭与销毁(enableDotMatrix / destroy

安装

使用 pnpm / npm / yarn 安装(本包为纯插件,需配合 leafer/@leafer-ui 等使用):

pnpm add leafer-x-dotwuxian
# or
npm install leafer-x-dotwuxian

快速开始

在你的 Leafer 应用初始化后,创建并挂载 DotMatrix

import { App } from 'leafer'
import { DotMatrix } from 'leafer-x-dotwuxian'

const app = App({ /* ... */ })

// 可选配置
const dot = new DotMatrix(app, {
	dotColor: '#D2D4D7',
	gridGap: 45,
	gridType: 'dots', // 'dots' | 'lines'
	maxSize: 10,
	minSize: 0.1,
})

// 启用/禁用
dot.enableDotMatrix(true)

// 销毁
dot.destroy()

API

  • new DotMatrix(app: IApp, config?: IDotMatrixConfig)

    • app: 来自 @leafer-ui/interfaceIApp 实例(必须为 App)
    • config:
      • dotColor?: string - 点/线颜色,支持 #rgb / #rrggbb / rgb(a),默认 #D2D4D7
      • gridGap?: number - 基础网格像素间距,默认 45
      • gridType?: 'dots' | 'lines' - 网格类型,默认 dots
      • maxSize?: number - 最大点/线宽,默认 10
      • minSize?: number - 最小点/线宽,默认 0.1
  • enableDotMatrix(enable: boolean) - 启用或禁用网格渲染(会添加/移除内置事件监听)。

  • destroy() - 卸载并销毁插件实例,清理引用和绘制层。

内部实现要点

  • 根据 zoomLayer.scale 计算多层可见网格,并基于对数尺度平滑过渡。
  • 在 canvas 像素空间中绘制,自动处理设备像素比和视口平移。
  • 对齐跳过策略:当较粗网格可见时,会跳过细网格上与之对齐的点/线,减少重复绘制。

打包与构建

本项目使用 TypeScript + Rollup 打包,入口位于 src/index.ts,导出 DotMatrix

常用命令:

pnpm install
pnpm run build

贡献

欢迎提交 issue 或 PR。请参阅项目根目录的 package.json 以了解脚本与构建细节。

许可证

MIT