pencil-renderer
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChinesePencil Renderer
Pencil 渲染器
Translate aesthetic DNA codes into Pencil .pen frames via MCP.
通过MCP将美学DNA代码转换为Pencil .pen框架。
Interface
接口
Input:
- DNA code:
[layout, color, typography, motion, density, background] - Component type:
hero | card | form | nav | footer | section | button | input - Optional: Name, dimensions, parent frame ID
Output:
- Frame ID in .pen file
- Screenshot of rendered frame
输入:
- DNA代码:
[layout, color, typography, motion, density, background] - 组件类型:
hero | card | form | nav | footer | section | button | input - 可选:名称、尺寸、父框架ID
输出:
- .pen文件中的框架ID
- 渲染后框架的截图
Workflow
工作流程
1. Ensure Document Ready
1. 确保文档就绪
javascript
// Check if editor open
mcp__pencil__get_editor_state({ include_schema: false })
// If no editor, open or create
mcp__pencil__open_document({ filePathOrTemplate: "new" })javascript
// Check if editor open
mcp__pencil__get_editor_state({ include_schema: false })
// If no editor, open or create
mcp__pencil__open_document({ filePathOrTemplate: "new" })2. Get Style Foundation
2. 获取风格基础
javascript
// Get available style guide tags
mcp__pencil__get_style_guide_tags()
// Get style guide matching DNA mood
// Map DNA to relevant tags:
// - dark color → ["dark-mode", "moody"]
// - light color → ["light", "clean"]
// - spacious density → ["airy", "whitespace"]
// etc.
mcp__pencil__get_style_guide({ tags: [mapped_tags] })javascript
// Get available style guide tags
mcp__pencil__get_style_guide_tags()
// Get style guide matching DNA mood
// Map DNA to relevant tags:
// - dark color → ["dark-mode", "moody"]
// - light color → ["light", "clean"]
// - spacious density → ["airy", "whitespace"]
// etc.
mcp__pencil__get_style_guide({ tags: [mapped_tags] })3. Translate DNA to Pencil Properties
3. 将DNA转换为Pencil属性
Reference:
references/dna-to-pencil.mdDNA axis → Pencil property mapping is deterministic.
Example: layout → , symmetric padding
centeredalignItems: "center"参考:
references/dna-to-pencil.mdDNA轴与Pencil属性的映射是确定性的。例如:布局 → 、对称内边距
centeredalignItems: "center"4. Execute Design Operations
4. 执行设计操作
Reference:
references/batch-design-patterns.mdjavascript
mcp__pencil__batch_design({
filePath: "<path>.pen",
operations: `
frame=I(document, {type: "frame", name: "Hero-Brutalist", ...properties})
heading=I(frame, {type: "text", content: "Headline", ...typography})
// ... additional operations
`
})参考:
references/batch-design-patterns.mdjavascript
mcp__pencil__batch_design({
filePath: "<path>.pen",
operations: `
frame=I(document, {type: "frame", name: "Hero-Brutalist", ...properties})
heading=I(frame, {type: "text", content: "Headline", ...typography})
// ... additional operations
`
})5. Capture Result
5. 捕获结果
javascript
// Screenshot for visual verification
mcp__pencil__get_screenshot({ nodeId: "frameId" })javascript
// Screenshot for visual verification
mcp__pencil__get_screenshot({ nodeId: "frameId" })6. Return
6. 返回结果
markdown
Frame ID: [id]
DNA: [layout, color, typography, motion, density, background]Plus screenshot image.
markdown
Frame ID: [id]
DNA: [layout, color, typography, motion, density, background]外加截图图片。
Component Templates
组件模板
| Type | Structure |
|---|---|
| Container + headline + subhead + CTA buttons |
| Container + image area + content + actions |
| Container + labels + inputs + submit |
| Container + logo + links + actions |
| Container + columns + links + legal |
| Container + heading + content grid |
| Frame + text + icon slot |
| Frame + label + field + validation |
| 类型 | 结构 |
|---|---|
| 容器 + 标题 + 副标题 + CTA按钮 |
| 容器 + 图片区域 + 内容 + 操作项 |
| 容器 + 标签 + 输入框 + 提交按钮 |
| 容器 + Logo + 链接 + 操作项 |
| 容器 + 列 + 链接 + 法律声明 |
| 容器 + 标题 + 内容网格 |
| 框架 + 文本 + 图标插槽 |
| 框架 + 标签 + 输入字段 + 验证 |
DNA Translation Quick Reference
DNA转换快速参考
| DNA Axis | Key Pencil Properties |
|---|---|
| Layout: centered | |
| Layout: asymmetric | Offset positions, varied gaps |
| Layout: bento | Grid with varied spans |
| Color: dark | Dark fill, light foreground |
| Color: gradient | |
| Typography: display-heavy | Large heading sizes, high contrast |
| Typography: minimal | Restrained scale, single family |
| Density: spacious | gap: 24-48, generous padding |
| Density: compact | gap: 8-16, tight padding |
| Background: solid | Single fill color |
| Background: textured | G() for patterns/images |
| DNA轴 | 关键Pencil属性 |
|---|---|
| Layout: centered | |
| Layout: asymmetric | 偏移位置、可变间距 |
| Layout: bento | 可变跨度的网格 |
| Color: dark | 深色填充、浅色前景 |
| Color: gradient | |
| Typography: display-heavy | 大标题尺寸、高对比度 |
| Typography: minimal | 克制的比例、单一字体族 |
| Density: spacious | gap: 24-48、充足内边距 |
| Density: compact | gap: 8-16、紧凑内边距 |
| Background: solid | 单一填充色 |
| Background: textured | G() 用于图案/图片 |
Constraints
约束条件
- Single concern: Render DNA → frame. No interview, no iteration.
- Pencil MCP required: Fails fast if unavailable
- Deterministic mapping: Same DNA always produces same structure
- Composable: Called by orchestrators, not users directly
- 单一关注点:仅负责将DNA渲染为框架,不包含交互、迭代
- 需要Pencil MCP:如果不可用则快速失败
- 确定性映射:相同DNA始终生成相同结构
- 可组合:由编排器调用,而非直接由用户调用
References
参考资料
- — Complete axis mapping
references/dna-to-pencil.md - — Common operation sequences
references/batch-design-patterns.md - — DNA axis definitions
aesthetic-system/references/dna-codes.md
- — 完整轴映射
references/dna-to-pencil.md - — 常见操作序列
references/batch-design-patterns.md - — DNA轴定义
aesthetic-system/references/dna-codes.md
Integration
集成
Called by:
- orchestrator (when Pencil backend available)
design-exploration
Composes:
- (for DNA interpretation)
aesthetic-system
调用方:
- 编排器(当Pencil后端可用时)
design-exploration
组合对象:
- (用于DNA解析)
aesthetic-system