Skip to content

Commit e93cd9b

Browse files
committed
docs: update AGENTS.md and README.md to reflect new components
- Add CustomDraw and Transform components to documentation - Update component lists and feature descriptions - Add new example references for transform and customdraw
1 parent 9441449 commit e93cd9b

File tree

2 files changed

+52
-4
lines changed

2 files changed

+52
-4
lines changed

AGENTS.md

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,12 @@
77
### 核心特性
88

99
- **Flexbox 布局引擎**: 支持完整的 Flexbox 布局,包括方向、对齐、间距等
10-
- **组件化渲染**: 提供 Box、Text、RichText、Image、Svg、Stack 等组件
10+
- **组件化渲染**: 提供 Box、Text、RichText、Image、Svg、Stack、CustomDraw、Transform 等组件
1111
- **丰富的样式支持**: 渐变、阴影、边框、圆角等
1212
- **文本排版**: 自动换行、省略号、行高控制、富文本支持等
1313
- **SVG 图形**: 支持矩形、圆形、椭圆、路径等 SVG 图形
14+
- **2D 变换**: 支持旋转、倾斜等 2D 变换操作
15+
- **自定义绘制**: 支持自定义 Canvas 绘制逻辑
1416
- **跨平台**: 支持浏览器和 Node.js 环境(通过 @napi-rs/canvas
1517

1618
## 项目结构
@@ -25,14 +27,17 @@ src/
2527
│ ├── Text.ts # Text 文本组件
2628
│ ├── RichText.ts # RichText 富文本组件
2729
│ ├── Image.ts # Image 图片组件
28-
│ └── Svg.ts # SVG 图形组件
30+
│ ├── Svg.ts # SVG 图形组件
31+
│ ├── Transform.ts # Transform 2D 变换组件
32+
│ └── CustomDraw.ts # CustomDraw 自定义绘制组件
2933
├── layout/ # 布局引擎
3034
│ ├── engine.ts # 布局计算核心
3135
│ ├── components/ # 组件固有尺寸测量
3236
│ └── utils/ # 布局工具函数
3337
├── render/ # 渲染引擎
3438
│ ├── components/ # 组件渲染实现
3539
│ └── utils/ # 渲染工具函数
40+
├── __tests__/ # 集成测试
3641
├── types/ # 类型定义
3742
│ ├── base.ts # 基础类型(颜色、尺寸、样式等)
3843
│ ├── components.ts # 组件类型

README.md

Lines changed: 45 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,12 @@
55
## ✨ 特性
66

77
- **Flexbox 布局引擎** - 支持完整的 Flexbox 布局,包括方向、对齐、间距等
8-
- **组件化渲染** - 提供 Box、Text、Image、Svg、Stack 等组件
8+
- **组件化渲染** - 提供 Box、Text、Image、Svg、Stack、RichText、CustomDraw、Transform 等组件
99
- **丰富的样式支持** - 渐变、阴影、边框、圆角等
10-
- **文本排版** - 自动换行、省略号、行高控制等
10+
- **文本排版** - 自动换行、省略号、行高控制、富文本支持等
1111
- **SVG 图形** - 支持矩形、圆形、椭圆、路径等 SVG 图形
12+
- **2D 变换** - 支持旋转、倾斜等 2D 变换操作
13+
- **自定义绘制** - 支持自定义 Canvas 绘制逻辑
1214
- **跨平台** - 支持浏览器和 Node.js 环境
1315
- **TypeScript** - 完整的类型支持
1416

@@ -222,6 +224,44 @@ Stack({
222224
});
223225
```
224226

227+
### Transform
228+
229+
2D 变换组件,支持旋转、倾斜等变换操作。
230+
231+
```typescript
232+
Transform({
233+
children: Box({
234+
width: 100,
235+
height: 100,
236+
background: "#667eea",
237+
}),
238+
transform: {
239+
rotate: Math.PI / 4, // 旋转 45 度
240+
},
241+
transformOrigin: ["50%", "50%"], // 变换原点
242+
});
243+
```
244+
245+
### CustomDraw
246+
247+
自定义绘制组件,提供原生 Canvas 上下文进行自定义绘制。
248+
249+
```typescript
250+
CustomDraw({
251+
width: 200,
252+
height: 100,
253+
draw: (ctx, options) => {
254+
// 使用原生 Canvas API 进行绘制
255+
ctx.fillStyle = "#667eea";
256+
ctx.fillRect(10, 10, 180, 80);
257+
ctx.fillStyle = "#ffffff";
258+
ctx.font = "bold 16px sans-serif";
259+
ctx.textAlign = "center";
260+
ctx.fillText("Custom Draw", 100, 60);
261+
},
262+
});
263+
```
264+
225265
## 🎨 样式
226266

227267
### 尺寸
@@ -373,6 +413,9 @@ console.log(layoutNode.layout.y); // 0
373413

374414
- [demo.ts](examples/demo.ts) - 浏览器环境演示
375415
- [card.ts](examples/card.ts) - Node.js 环境卡片示例
416+
- [richtext.ts](examples/richtext.ts) - 富文本示例
417+
- [transform.ts](examples/transform.ts) - 2D 变换示例
418+
- [customdraw.ts](examples/customdraw.ts) - 自定义绘制示例
376419

377420
## 🤝 贡献
378421

0 commit comments

Comments
 (0)