diff --git a/README.md b/README.md
index 78a6b7e..3542250 100644
--- a/README.md
+++ b/README.md
@@ -1,6 +1,7 @@
@@ -9,52 +10,52 @@
[](https://badge.fury.io/js/@cs-open%2Freact-fabric)
[](https://opensource.org/licenses/MIT)
-一个基于 Fabric.js 构建的现代化 React Canvas 绘图组件库,提供强大的 2D 图形绘制、交互和动画功能。
+A modern React Canvas drawing component library built on Fabric.js, providing powerful 2D graphics rendering, interaction, and animation capabilities.
-## ✨ 核心特性
+## ✨ Core Features
-### 🎯 丰富的图形组件
+### 🎯 Rich Graphic Components
-- **基础图形**: 矩形、圆形、椭圆、线条、多边形、路径
-- **文本组件**: 文本、可编辑文本、文本框
-- **图像组件**: 背景图片、普通图片
-- **组合组件**: 分组、对象集合
-- **自定义控件**: 可拖拽控制点、工具栏
+- **Basic Shapes**: Rectangle, Circle, Ellipse, Line, Polygon, Path
+- **Text Components**: Text, Editable Text, Textbox
+- **Image Components**: Background Image, Regular Image
+- **Group Components**: Group, Object Collection
+- **Custom Controls**: Draggable Control Points, Toolbar
-### 🖱️ 强大的交互功能
+### 🖱️ Powerful Interaction Features
-- **自动缩放**: 支持鼠标滚轮缩放,自动适应容器大小
-- **平移操作**: 支持拖拽平移画布视图
-- **触摸支持**: 完整的触摸设备支持,包括双指缩放和拖拽
-- **选择系统**: 多选、框选、键盘快捷键支持
-- **拖拽操作**: 对象拖拽、批量操作
+- **Auto Zoom**: Supports mouse wheel zooming, automatically adapts to container size
+- **Pan Operation**: Supports drag to pan canvas view
+- **Touch Support**: Full touch device support, including pinch zoom and drag
+- **Selection System**: Multi-select, box selection, keyboard shortcut support
+- **Drag Operation**: Object dragging, batch operations
-### 📦 响应式设计
+### 📦 Responsive Design
-- **自动适配**: 画布自动撑满父容器,响应式调整
-- **触摸优化**: 专为移动设备优化的触摸交互
-- **跨平台**: 支持桌面端和移动端浏览器
+- **Auto Adapt**: Canvas automatically fills parent container, responsive adjustment
+- **Touch Optimization**: Touch interactions optimized for mobile devices
+- **Cross-platform**: Supports desktop and mobile browsers
-### 💻 开发者友好
+### 💻 Developer Friendly
-- **TypeScript**: 完整的 TypeScript 类型支持
-- **React 风格**: 声明式 API,符合 React 开发习惯
-- **事件系统**: 完整的事件回调,支持所有 Fabric.js 事件
-- **状态管理**: 内置状态管理,支持受控和非受控模式
+- **TypeScript**: Full TypeScript type support
+- **React Style**: Declarative API, conforms to React development practices
+- **Event System**: Complete event callbacks, supports all Fabric.js events
+- **State Management**: Built-in state management, supports controlled and uncontrolled modes
-## ✨ 快速开始
+## ✨ Quick Start
-### 安装
+### Installation
```bash
npm install @cs-open/react-fabric
-# 或者
+# or
yarn add @cs-open/react-fabric
-# 或者
+# or
pnpm add @cs-open/react-fabric
```
-### 基础用法
+### Basic Usage
```tsx
import React from 'react'
@@ -75,9 +76,9 @@ function App() {
export default App
```
-## 🎯 核心功能
+## 🎯 Core Features
-### 自动缩放与平移
+### Auto Zoom and Pan
```tsx
import { ReactFabric, useReactFabric } from '@cs-open/react-fabric'
@@ -88,21 +89,21 @@ function CanvasWithControls() {
return (
- 放大
- 缩小
- resetViewport()}>重置
- 缩放: {Math.round(zoom * 100)}%
+ Zoom In
+ Zoom Out
+ resetViewport()}>Reset
+ Zoom: {Math.round(zoom * 100)}%
- {/* 你的画布内容 */}
+ {/* Your canvas content */}
)
}
```
-### 触摸设备支持
+### Touch Device Support
```tsx
import { ReactFabric, PluginPinch } from '@cs-open/react-fabric'
@@ -111,14 +112,14 @@ import { PluginPinch } from '@cs-open/react-fabric/plugins'
function TouchCanvas() {
return (
- {/* 你的画布内容 */}
+ {/* Your canvas content */}
)
}
```
-### 背景图片
+### Background Image
```tsx
import { ReactFabric, BackgroundImage } from '@cs-open/react-fabric'
@@ -127,26 +128,26 @@ function CanvasWithBackground() {
return (
- {/* 其他图形元素 */}
+ {/* Other graphic elements */}
)
}
```
-## 🔌 插件系统
+## 🔌 Plugin System
-### 内置插件
+### Built-in Plugins
-| 插件 | 功能 | 描述 |
-| ---------------- | -------- | ---------------------- |
-| `PluginPinch` | 触摸缩放 | 支持双指缩放和拖拽操作 |
-| `PluginFreeDraw` | 自由绘制 | 手绘路径和涂鸦功能 |
-| `PluginFreeRect` | 矩形绘制 | 交互式矩形绘制工具 |
-| `PluginFreeText` | 文本工具 | 点击添加可编辑文本 |
-| `PluginGridLine` | 网格辅助 | 显示网格线辅助对齐 |
-| `PluginMask` | 遮罩效果 | 创建遮罩和裁剪效果 |
+| Plugin | Function | Description |
+| ---------------- | -------------- | ------------------------------------------- |
+| `PluginPinch` | Touch Zoom | Supports pinch zoom and drag operations |
+| `PluginFreeDraw` | Free Draw | Hand-drawn paths and doodle features |
+| `PluginFreeRect` | Rectangle Draw | Interactive rectangle drawing tool |
+| `PluginFreeText` | Text Tool | Click to add editable text |
+| `PluginGridLine` | Grid Guide | Display grid lines for alignment assistance |
+| `PluginMask` | Mask Effect | Create mask and crop effects |
-### 使用插件
+### Using Plugins
```tsx
import { ReactFabric } from '@cs-open/react-fabric'
@@ -155,59 +156,59 @@ import { PluginPinch, PluginFreeDraw, PluginFreeRect, PluginGridLine } from '@cs
function AdvancedCanvas() {
return (
- {/* 触摸支持 */}
+ {/* Touch support */}
- {/* 自由绘制 */}
+ {/* Free draw */}
{
- console.log('绘制完成:', path)
+ console.log('Drawing completed:', path)
}}
/>
- {/* 矩形绘制工具 */}
+ {/* Rectangle drawing tool */}
{
- console.log('矩形绘制完成:', rect)
+ console.log('Rectangle drawing completed:', rect)
}}
/>
- {/* 网格线 */}
+ {/* Grid lines */}
)
}
```
-## 📦 组件 API
+## 📦 Component API
-### ReactFabric 组件
+### ReactFabric Component
-主要的画布容器组件,支持以下属性:
+The main canvas container component, supports the following properties:
```tsx
interface ReactFabricProps {
- // 基础属性
+ // Basic Properties
width?: number
height?: number
className?: string
style?: CSSProperties
- // 交互控制
- zoomable?: boolean // 是否可缩放
- panAble?: boolean // 是否可平移
- selection?: boolean // 是否可选择
- defaultSelection?: boolean // 默认选择状态
- defaultDraggable?: boolean // 默认拖拽状态
+ // Interaction Control
+ zoomable?: boolean // Whether zoomable
+ panAble?: boolean // Whether panable
+ selection?: boolean // Whether selectable
+ defaultSelection?: boolean // Default selection state
+ defaultDraggable?: boolean // Default draggable state
- // 缩放控制
- manualZoom?: number // 手动缩放倍数
- minManualZoom?: number // 最小缩放倍数
- maxManualZoom?: number // 最大缩放倍数
- defaultCentered?: boolean // 背景图是否居中
+ // Zoom Control
+ manualZoom?: number // Manual zoom level
+ minManualZoom?: number // Minimum zoom level
+ maxManualZoom?: number // Maximum zoom level
+ defaultCentered?: boolean // Whether background image is centered
- // 事件回调
+ // Event Callbacks
onMouseDown?: (e: FabricPublicEvent) => void
onMouseMove?: (e: FabricPublicEvent) => void
onMouseUp?: (e: FabricPublicEvent) => void
@@ -215,12 +216,12 @@ interface ReactFabricProps {
}
```
-### 图形组件
+### Graphic Components
-所有图形组件都支持对应的 Fabric.js 对象的所有属性和事件:
+All graphic components support all properties and events of the corresponding Fabric.js objects:
```tsx
-// 矩形
+// Rectangle
console.log('矩形被修改', e.target)}
+ onModified={(e) => console.log('Rectangle modified', e.target)}
/>
-// 圆形
+// Circle
console.log('圆形被选中')}
+ onSelected={() => console.log('Circle selected')}
/>
-// 文本
+// Text
-// 图片
+// Image
```
-## 🎮 状态管理
+## 🎮 State Management
### useReactFabric Hook
@@ -270,14 +271,14 @@ import { useReactFabric } from '@cs-open/react-fabric'
function Toolbar() {
const {
- // 状态
+ // State
canvas,
zoom,
manualZoom,
isDragging,
selection,
- // 方法
+ // Methods
zoomIn,
zoomOut,
resetViewport,
@@ -288,19 +289,19 @@ function Toolbar() {
return (
- 放大
- 缩小
- resetViewport()}>重置
- 缩放: {Math.round(zoom * 100)}%
+ Zoom In
+ Zoom Out
+ resetViewport()}>Reset
+ Zoom: {Math.round(zoom * 100)}%
)
}
```
-### 跨组件状态访问
+### Cross-component State Access
-ReactFabricProvider 是一个上下文提供程序,允许您从组件树中的任何位置访问流的内部状态,例如子组件,甚至在 ReactFabric 之外 元件。它通常用于应用程序的顶层。
-在这种情况下,您可能需要使用 ReactFabricProvider 组件
+ReactFabricProvider is a context provider that allows you to access the internal state of the flow from anywhere in the component tree, such as child components, or even outside the ReactFabric component. It is typically used at the top level of the application.
+In this case, you may need to use the ReactFabricProvider component
```tsx
import { ReactFabricProvider, useReactFabric } from '@cs-open/react-fabric'
@@ -309,20 +310,20 @@ function App() {
return (
- {/* 画布内容 */}
+ {/* Canvas content */}
)
}
function Toolbar() {
const { zoomIn, zoomOut, resetViewport } = useReactFabric()
- // 可以在 ReactFabric 外部访问状态
+ // Can access state outside ReactFabric
}
```
-## 🎨 高级用法
+## 🎨 Advanced Usage
-### 受控模式
+### Controlled Mode
```tsx
import { useState } from 'react'
@@ -345,7 +346,7 @@ function ControlledCanvas() {
}
```
-### 非受控模式
+### Uncontrolled Mode
```tsx
import { ReactFabric, Rect, Group } from '@cs-open/react-fabric'
@@ -361,7 +362,7 @@ function UncontrolledCanvas() {
}
```
-### DOM 集成
+### DOM Integration
```tsx
import { ReactFabric, Rect } from '@cs-open/react-fabric'
@@ -370,16 +371,16 @@ function CanvasWithDOM() {
return (
- 这是一个提示框
+ This is a tooltip
)
}
```
-## 📋 依赖要求
+## 📋 Dependency Requirements
-### 必需依赖
+### Required Dependencies
```json
{
@@ -390,39 +391,39 @@ function CanvasWithDOM() {
}
```
-### 可选依赖
+### Optional Dependencies
-某些插件需要额外的依赖:
+Some plugins require additional dependencies:
```bash
-# 触摸手势支持
+# Touch gesture support
npm install hammerjs
-npm install @types/hammerjs # TypeScript 用户
+npm install @types/hammerjs # TypeScript users
-# 浮动 UI 支持(用于 DOM 集成)
+# Floating UI support (for DOM integration)
npm install @floating-ui/react
```
-## 🤝 贡献
+## 🤝 Contributing
-欢迎提交 Issue 和 Pull Request!
+Welcome to submit Issues and Pull Requests!
-1. Fork 本仓库
-2. 创建特性分支 (`git checkout -b feature/AmazingFeature`)
-3. 提交更改 (`git commit -m 'Add some AmazingFeature'`)
-4. 推送到分支 (`git push origin feature/AmazingFeature`)
-5. 开启 Pull Request
+1. Fork this repository
+2. Create feature branch (`git checkout -b feature/AmazingFeature`)
+3. Commit changes (`git commit -m 'Add some AmazingFeature'`)
+4. Push to branch (`git push origin feature/AmazingFeature`)
+5. Open Pull Request
-## 📄 许可证
+## 📄 License
-本项目基于 [MIT](LICENSE) 许可证开源。
+This project is open source under the [MIT](LICENSE) license.
-## 🔗 相关链接
+## 🔗 Related Links
-- [Fabric.js 官方文档](http://fabricjs.com/)
-- [React 官方文档](https://reactjs.org/)
-- [项目主页](https://cs-open.github.io/react-fabric/)
-- [GitHub 仓库](https://github.com/cs-open/react-fabric)
+- [Fabric.js Official Documentation](http://fabricjs.com/)
+- [React Official Documentation](https://reactjs.org/)
+- [Project Homepage](https://cs-open.github.io/react-fabric/)
+- [GitHub Repository](https://github.com/cs-open/react-fabric)
---