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

graphic-logic

v1.0.3

Published

A TypeScript library for graphical logic exploration and learning

Readme

graphic-logic

一个专注于图形化逻辑探讨和学习的 TypeScript 库,提供丰富的几何计算、逻辑门操作和动画生成功能。

📦 安装

使用 npm

npm install graphic-logic

使用 yarn

yarn add graphic-logic

使用 pnpm

pnpm add graphic-logic

文档

详细使用文档请查看 docs 目录:

🚀 快速开始

详细使用文档请查看 docs 目录。

基础示例

import { Point, Line, Rectangle, Circle } from 'graphic-logic';

// 创建点
const point = new Point(10, 20);
console.log(point.toString()); // Point(10, 20)

// 计算距离
const point2 = new Point(40, 60);
const distance = point.distanceTo(point2);
console.log(distance); // 50

// 创建线段
const line = new Line(point, point2);
console.log(line.length); // 50

// 创建矩形
const rectangle = new Rectangle(0, 0, 100, 200);
console.log(rectangle.contains(point)); // true

// 创建圆形
const circle = new Circle(new Point(50, 50), 30);
console.log(circle.contains(point)); // false

逻辑门操作

import { LogicGate } from 'graphic-logic';

// 创建 AND 门
const andGate = new LogicGate('AND');
andGate.setInput(0, true);
andGate.setInput(1, true);
console.log(andGate.getOutput()); // true

// 创建 OR 门
const orGate = new LogicGate('OR');
orGate.setInput(0, false);
orGate.setInput(1, true);
console.log(orGate.getOutput()); // true

// 创建 NOT 门
const notGate = new LogicGate('NOT', 1);
notGate.setInput(0, true);
console.log(notGate.getOutput()); // false

// 连接门
andGate.connectTo(orGate, 0, 0);

🛠️ 开发指南

环境设置

# 克隆仓库
git clone <repository-url>
cd graphic-logic

# 安装依赖
pnpm install

# 构建项目
pnpm build

# 运行测试
pnpm test

# 类型检查
pnpm typecheck

项目结构

graphic-logic/
├── src/
│   ├── geometry/          # 几何类实现
│   │   ├── Point.ts
│   │   ├── Line.ts
│   │   ├── Rectangle.ts
│   │   └── Circle.ts
│   ├── logic/            # 逻辑模块
│   │   └── LogicGate.ts
│   ├── animation/        # 动画模块
│   │   ├── interfaces.ts
│   │   ├── generators/   # 图形生成器
│   │   ├── transformations/ # 变换实现
│   │   └── AnimationGenerator.ts
│   ├── utils/            # 工具函数
│   │   └── math.ts
│   ├── types.ts          # 类型定义
│   └── index.ts          # 主入口
├── examples/             # 示例应用
│   ├── graph-demo/       # 图形演示(交互式图形展示)
│   └── performance-test/ # 性能测试(测试图形生成器性能表现)
├── test/                # 测试文件
├── package.json
├── tsconfig.json
├── tsup.config.ts
└── README.md

📄 许可证

LGPL-3.0 License

🤝 贡献

欢迎提交 Issue 和 Pull Request!

📧 联系方式

如有问题或建议,请通过 Issue 联系。