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

@leolee9086/my-pat-loader

v1.0.0

Published

AutoCAD PAT(填充图案)文件解析和线段生成工具

Readme

My PAT Loader

一个用于解析和处理AutoCAD .PAT(填充图案)文件的JavaScript模块。

特性

  • ✅ 支持带角度、原点、delta值和虚线定义的完整PAT规则
  • ✅ 高精度计算PAT图案的矢量线段表示
  • ✅ 支持缩放、旋转和偏移图案
  • ✅ 轻量级实现,无外部依赖
  • ✅ 包含Vue.js示例应用

安装

# 尚未发布到NPM,目前可通过Git仓库直接使用
git clone <repository-url>
cd my-pat-loader
# 如果需要依赖安装
npm install

主要API

这个库导出三个主要函数:

parsePatContent(patTextString)

解析PAT文件文本内容为结构化数据。

import { parsePatContent } from 'my-pat-loader';

const patContent = `*STARS,Stars pattern
45, 0, 0, 0, 20, 0, -20
135, 0, 0, 0, 20, 0, -20`;

const parsedPat = parsePatContent(patContent);
// 返回: { name: "STARS", linesDefs: [...], description: "Stars pattern" }

computePatternLines(parsedPatData, boundary, scale, rotation, offset)

根据解析后的PAT数据,计算指定边界内的矢量线段。

import { parsePatContent, computePatternLines } from 'my-pat-loader';

// 解析PAT数据
const parsedPat = parsePatContent(patContent);

// 计算线段
const lines = computePatternLines(
  parsedPat,
  { minX: 0, minY: 0, maxX: 100, maxY: 100 }, // 边界
  1.0, // 缩放
  0.0, // 旋转角度
  [0, 0] // 偏移
);

// 返回:[{start: {x, y}, end: {x, y}}, ...]

checkPatternContinuity(parsedPatData, boundary, scale, rotation, offset)

检查图案在当前设置下是否在边界上形成连续的模式。

import { parsePatContent, checkPatternContinuity } from 'my-pat-loader';

// 解析PAT数据
const parsedPat = parsePatContent(patContent);

// 检查连续性
const continuity = checkPatternContinuity(
  parsedPat,
  { minX: 0, minY: 0, maxX: 100, maxY: 100 }, // 边界
  1.0, // 缩放
  0.0, // 旋转角度
  [0, 0] // 偏移
);

// 返回:{ isContinuous: true, continuityScore: 0.95, edgeContinuity: {...}, details: "..." }

示例应用

项目包含一个基于Vue.js的完整示例应用,演示如何使用这个库来可视化PAT文件:

cd example
npm install
npm run dev

PAT文件格式参考

AutoCAD PAT文件格式的基本结构如下:

*图案名称[,描述]
角度, 原点X, 原点Y, 增量X, 增量Y[, 虚线定义...]
  • 每个图案以*开头,后跟图案名称
  • 后续每行定义一组平行线族
  • 正数虚线定义表示绘制线段,负数表示不绘制(空白)
  • 零长度虚线表示点

许可

AGPL-3.0