← Back to Skills Marketplace
xtoyun

雄韬书法AI应用 - 汉字重心

by xtoyun · GitHub ↗ · v1.0.1 · MIT-0
cross-platform ✓ Security Clean
36
Downloads
1
Stars
0
Active Installs
2
Versions
Install in OpenClaw
/install hanzi-center
Description
雄韬汉字视觉重心分析引擎——基于"分量·距离·斜度"三要素模型,融合启功结字黄金律与阿恩海姆视知觉理论,对任意汉字进行像素级视觉重心计算。当用户问及汉字重心、书法结构、字体平衡、"这个字为什么看起来歪"、中宫收紧、结字法则、不同字体的重心差异时使用。支持楷/宋/黑/仿/明/思源6种字体切换、多字对比、中宫热力分析...
README (SKILL.md)

雄韬汉字视觉重心

雄韬出品的汉字视觉重心智能分析工具。基于分量 · 距离 · 斜度三要素模型,融合启功"结字黄金律"和阿恩海姆视知觉理论,对任意汉字进行像素级分析,输出数据报告与可视化图片。

🌐 在线演示http://shufa.xtocn.com/汉字视觉重心.html 📂 开源地址https://github.com/xtoyun/zhishufa

何时使用

  • 用户输入单个汉字,询问其重心/结构/平衡
  • 用户想对比多个汉字的视觉重心差异
  • 用户询问某个字为什么"看起来歪"或"写得不对"
  • 用户提到"中宫"、"重心"、"结字"等书法术语
  • 用户想在不同字体下分析同一个字

分析引擎

核心脚本:{baseDir}/scripts/analyze.js,基于 node-canvas 无头渲染 + 像素级分析。

依赖已在 {baseDir}/package.json 声明(npm install 后即可使用)。首次使用前确保依赖已安装。

默认行为:运行后同时输出文字报告和一张可视化 PNG 图片(hanzi_\x3C字>_\x3C字体>.png),图片包含汉字渲染 + 视觉重心/物理质心/几何中心标注。可用 --no-png 关闭。

基本调用

cd "{baseDir}" && node scripts/analyze.js \x3C汉字> [选项]

常用场景

场景 1:单个字分析 — 用户问"永字的重心在哪"

cd "{baseDir}" && node scripts/analyze.js 永

场景 2:多字对比 — 用户问"对比 重、飞、不、中 的重心"

cd "{baseDir}" && node scripts/analyze.js 重 --compare 飞,不,中

场景 3:切换字体 — 用户问"用宋体分析'我'字"

cd "{baseDir}" && node scripts/analyze.js 我 --font=song

场景 4:调参探究 — 用户问"中宫收紧调到最大看'家'字"

cd "{baseDir}" && node scripts/analyze.js 家 --density=100

场景 5:JSON 导出 — 用户问"把'龙'的数据导出来"

cd "{baseDir}" && node scripts/analyze.js 龙 --json

完整选项

选项 说明 默认
-f, --font kai / song / hei / fangsong / ming / noto kai
-w, --weight 分量权重 0–100 70
-d, --density 中宫收紧 0–100 60
-s, --slant 斜度影响 0–100 40
-u, --upbias 偏上偏差 0–15 6.0
-r, --rightbias 偏右偏差 -5–10 2.5
-c, --compare 对比字(逗号分隔)
-j, --json JSON 输出
--png 生成可视化图片 默认开启
--no-png 不生成图片
--fonts 列出字体

报告字段解读

把输出结果用自然语言解释给用户:

  • 视觉重心 vs 几何中心 vs 物理质心:三者差异越大,说明字的结构张力越强
  • 偏移方向:偏上=符合"上紧下松"审美;偏左/偏右=笔画天然分布不对称
  • 上:下 / 左:右 比例:偏离 50:50 越远,该方向的笔画分布越不均匀
  • 解读:结合偏移量自动生成,引用启功、姜夔等书论

字体说明

key 名称 说明
kai 楷书 最接近手写,默认字体
song 宋体 横细竖粗,印刷正体
hei 黑体 笔画均匀,现代风格
fangsong 仿宋 楷体骨架宋体笔形
ming 明体 台湾标准印刷体
noto 思源宋 Google 开源,跨平台

依赖系统字体。如果渲染异常,提示用户换一种字体试试。

算法简述(面向用户的解释)

按顺序告诉用户(不要堆砌术语):

  1. Canvas 画出汉字 → 逐像素提取墨色
  2. 算出物理质心(纯数学平均)
  3. 密度网格重新加权 → 笔画密集区"吸附"重心(模拟中宫)
  4. 笔画方向检测 → 横竖撇捺的"拉力"微调重心
  5. 加上人眼偏好(偏上看约 6%)→ 得到最终视觉重心

注意

  • 每次只分析一个主汉字,对比模式最多附带 4 个
  • 默认参数是经验优化值,一般无需调整
  • 分析纯本地计算,不联网
Usage Guidance
Install this if you want a local Hanzi visual-center analysis helper. Be aware it requires npm dependencies including the native canvas package, and by default it saves PNG files in the working directory; use --no-png or run it in a scratch workspace if you do not want generated images retained.
Capability Assessment
Purpose & Capability
The Node script renders Hanzi with canvas, computes visual center metrics, prints reports, and can generate a PNG; these capabilities match the stated calligraphy-analysis purpose.
Instruction Scope
The routing language is somewhat broad for Chinese characters and calligraphy questions, but the documented use cases remain aligned with character structure, balance, fonts, and visual-center analysis.
Install Mechanism
The skill declares a normal npm dependency on canvas; canvas has a native install script via its package, which is expected for that library, and the skill itself does not define install, postinstall, or background execution hooks.
Credentials
Runtime behavior is local: it uses node-canvas, checks a small set of system font paths, and writes analysis output; no runtime network calls, subprocess execution, credential access, or broad local indexing were found.
Persistence & Privilege
By default the script writes a predictable PNG file such as hanzi_<char>_<font>.png in the current directory, which is disclosed and purpose-aligned but can leave local artifacts or overwrite an existing file with the same name.
How to Use
  1. Make sure OpenClaw is installed (local or Docker)
  2. Run the install command in chat: /install hanzi-center
  3. After installation, invoke the skill by name or use /hanzi-center
  4. Provide required inputs per the skill's parameter spec and get structured output
Version History
v1.0.1
- Updated skill name and description to "雄韬汉字视觉重心分析引擎", emphasizing the "雄韬" branding and technical highlights. - Clarified context of use to match real-world calligraphy/visual center inquiries. - No code or functional changes; documentation and metadata improvements only. - All analysis features, options, and usage remain unchanged.
v1.0.0
Initial release – analyze the visual center of gravity for Chinese characters (hanzi): - Supports single-character analysis and multi-character visual center comparison. - Provides detailed, pixel-level gravity reports and annotated PNG visualizations. - Supports six major Chinese fonts: 楷, 宋, 黑, 仿, 明, 思源(kai, song, hei, fangsong, ming, noto). - Offers a variety of options, including font switching, density/weight adjustment, JSON export, and image toggling. - Explains results in natural language with reference to calligraphy theory and historical literature. - Requires Node.js environment with documented dependencies; analyzes characters fully offline.
Metadata
Slug hanzi-center
Version 1.0.1
License MIT-0
All-time Installs 0
Active Installs 0
Total Versions 2
Frequently Asked Questions

What is 雄韬书法AI应用 - 汉字重心?

雄韬汉字视觉重心分析引擎——基于"分量·距离·斜度"三要素模型,融合启功结字黄金律与阿恩海姆视知觉理论,对任意汉字进行像素级视觉重心计算。当用户问及汉字重心、书法结构、字体平衡、"这个字为什么看起来歪"、中宫收紧、结字法则、不同字体的重心差异时使用。支持楷/宋/黑/仿/明/思源6种字体切换、多字对比、中宫热力分析... It is an AI Agent Skill for Claude Code / OpenClaw, with 36 downloads so far.

How do I install 雄韬书法AI应用 - 汉字重心?

Run "/install hanzi-center" in the OpenClaw or Claude Code chat to install it in one step — no extra setup required.

Is 雄韬书法AI应用 - 汉字重心 free?

Yes, 雄韬书法AI应用 - 汉字重心 is completely free, licensed under MIT-0. You can download, install and use it at no cost.

Which platforms does 雄韬书法AI应用 - 汉字重心 support?

雄韬书法AI应用 - 汉字重心 is cross-platform and runs anywhere OpenClaw / Claude Code is available (cross-platform).

Who created 雄韬书法AI应用 - 汉字重心?

It is built and maintained by xtoyun (@xtoyun); the current version is v1.0.1.

💬 Comments