百科.dev
全部条目AI 编程趋势榜开源项目技术资讯提交条目
登录
< 返回工具列表
R

ruler

> 编程语言
开源

一种可以绘制网格并无限滚动的尺子组件。

365 stars0 点赞0 次浏览
访问官网GitHub

工具介绍

一种可以绘制网格并无限滚动的尺子组件。

Ruler

A Ruler component that can draw grids and scroll infinitely.

Demo /
API /
Guides /
Main Project

⚙️ Installation

npm

bash
$ npm i @scena/ruler

scripts

xml

How to use

typescript
import Ruler from "@scena/ruler";

const ruler = new Ruler(document.body, {
    type: "horizontal",
});

window.addEventListener("resize", () => {
    ruler.resize();
});

export interface RulerInterface {
    scroll(scrollPos: number): any;
    resize(): any;
}
export interface RulerProps {
    type?: "horizontal" | "vertical";
    width?: number;
    height?: number;
    unit?: number;
    zoom?: number;
    direction?: "start" | "end";
    style?: IObject;
    backgroundColor?: string;
    lineColor?: string;
    textColor?: string;
    textFormat?: (scale: number) => string;
}

Ruler Units

The default unit is px, and a line is drawn every 50px. If you want to use a different unit instead of the px unit, use it like this:

  • 1px (Default)
    • zoom: 1
    • unit: 50 (every 50px)
  • 1cm = 37.7952px
    • zoom: 37.7952
    • unit: 1 (every 1cm)
  • 1in = 96px = 2.54cm
    • zoom: 96
    • unit: 1 (every 1in)

⚙️ Developments

The ruler repo is managed as a monorepo with yarn.

bash
yarn config set registry https://registry.npmjs.org/

⭐️ Show Your Support

Please give a ⭐️ if this project helped you!

Contributing

If you have any questions or requests or want to contribute to ruler or other packages, please write the issue or give me a Pull Request freely.

Bug Report

If you find a bug, please report to us opening a new Issue on GitHub.

License

This project is MIT licensed.

…

Issues· 0 开放

查看全部 Issues在 GitHub 打开

暂无开放 Issues,或尚未同步最近议题。

> 标签

TypeScript

暂无评论,来聊聊你的看法吧

> 工具信息

发布日期2026年8月1日
最后更新2026年9月17日
分类编程语言
定价开源

> 相关工具

T
TypeScript
JavaScript 的超集,为前端与全栈提供静态类型
P
Python
通用编程语言,广泛用于 Web、数据与 AI
G
Go
Google 推出的简洁高效系统语言