foliko 1.0.87 → 1.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.agent/.shared/ui-ux-pro-max/data/charts.csv +26 -0
- package/.agent/.shared/ui-ux-pro-max/data/colors.csv +97 -0
- package/.agent/.shared/ui-ux-pro-max/data/icons.csv +101 -0
- package/.agent/.shared/ui-ux-pro-max/data/landing.csv +31 -0
- package/.agent/.shared/ui-ux-pro-max/data/products.csv +97 -0
- package/.agent/.shared/ui-ux-pro-max/data/prompts.csv +24 -0
- package/.agent/.shared/ui-ux-pro-max/data/react-performance.csv +45 -0
- package/.agent/.shared/ui-ux-pro-max/data/stacks/flutter.csv +53 -0
- package/.agent/.shared/ui-ux-pro-max/data/stacks/html-tailwind.csv +56 -0
- package/.agent/.shared/ui-ux-pro-max/data/stacks/jetpack-compose.csv +53 -0
- package/.agent/.shared/ui-ux-pro-max/data/stacks/nextjs.csv +53 -0
- package/.agent/.shared/ui-ux-pro-max/data/stacks/nuxt-ui.csv +51 -0
- package/.agent/.shared/ui-ux-pro-max/data/stacks/nuxtjs.csv +59 -0
- package/.agent/.shared/ui-ux-pro-max/data/stacks/react-native.csv +52 -0
- package/.agent/.shared/ui-ux-pro-max/data/stacks/react.csv +54 -0
- package/.agent/.shared/ui-ux-pro-max/data/stacks/shadcn.csv +61 -0
- package/.agent/.shared/ui-ux-pro-max/data/stacks/svelte.csv +54 -0
- package/.agent/.shared/ui-ux-pro-max/data/stacks/swiftui.csv +51 -0
- package/.agent/.shared/ui-ux-pro-max/data/stacks/vue.csv +50 -0
- package/.agent/.shared/ui-ux-pro-max/data/styles.csv +59 -0
- package/.agent/.shared/ui-ux-pro-max/data/typography.csv +58 -0
- package/.agent/.shared/ui-ux-pro-max/data/ui-reasoning.csv +101 -0
- package/.agent/.shared/ui-ux-pro-max/data/ux-guidelines.csv +100 -0
- package/.agent/.shared/ui-ux-pro-max/data/web-interface.csv +31 -0
- package/.agent/.shared/ui-ux-pro-max/scripts/__pycache__/core.cpython-313.pyc +0 -0
- package/.agent/.shared/ui-ux-pro-max/scripts/__pycache__/design_system.cpython-313.pyc +0 -0
- package/.agent/.shared/ui-ux-pro-max/scripts/core.py +258 -0
- package/.agent/.shared/ui-ux-pro-max/scripts/design_system.py +1067 -0
- package/.agent/.shared/ui-ux-pro-max/scripts/search.py +106 -0
- package/.agent/ARCHITECTURE.md +288 -0
- package/.agent/agents/ambient-agent.md +57 -0
- package/.agent/agents/debugger.md +55 -0
- package/.agent/agents/email-assistant.md +49 -0
- package/.agent/agents/file-manager.md +42 -0
- package/.agent/agents/python-developer.md +60 -0
- package/.agent/agents/scheduler.md +59 -0
- package/.agent/agents/web-developer.md +45 -0
- package/.agent/data/default.json +325 -21
- package/.agent/data/plugins-state.json +194 -162
- package/.agent/data/puppeteer-sessions/undefined.json +6 -0
- package/.agent/mcp_config.json +0 -1
- package/.agent/mcp_config_updated.json +12 -0
- package/.agent/plugins/poster-plugin/README.md +304 -0
- package/.agent/plugins/poster-plugin/fonts/NotoColorEmoji-Regular.ttf +0 -0
- package/.agent/plugins/poster-plugin/fonts/PatuaOne-Regular.ttf +0 -0
- package/.agent/plugins/poster-plugin/fonts//345/276/256/350/275/257/351/233/205/351/273/221.ttf +0 -0
- package/.agent/plugins/poster-plugin/fonts//345/276/256/350/275/257/351/233/205/351/273/221/347/262/227/344/275/223.ttf +0 -0
- package/.agent/plugins/poster-plugin/index.js +13 -0
- package/.agent/plugins/poster-plugin/package.json +28 -0
- package/.agent/plugins/poster-plugin/src/canvas.js +161 -0
- package/.agent/plugins/poster-plugin/src/components/arrow.js +84 -0
- package/.agent/plugins/poster-plugin/src/components/avatar.js +71 -0
- package/.agent/plugins/poster-plugin/src/components/badge.js +85 -0
- package/.agent/plugins/poster-plugin/src/components/card.js +88 -0
- package/.agent/plugins/poster-plugin/src/components/chart.js +127 -0
- package/.agent/plugins/poster-plugin/src/components/chip.js +88 -0
- package/.agent/plugins/poster-plugin/src/components/columns.js +107 -0
- package/.agent/plugins/poster-plugin/src/components/cta.js +85 -0
- package/.agent/plugins/poster-plugin/src/components/divider.js +55 -0
- package/.agent/plugins/poster-plugin/src/components/feature.js +85 -0
- package/.agent/plugins/poster-plugin/src/components/featureGrid.js +112 -0
- package/.agent/plugins/poster-plugin/src/components/grid.js +118 -0
- package/.agent/plugins/poster-plugin/src/components/imageFrame.js +155 -0
- package/.agent/plugins/poster-plugin/src/components/index.js +62 -0
- package/.agent/plugins/poster-plugin/src/components/listItem.js +146 -0
- package/.agent/plugins/poster-plugin/src/components/notification.js +123 -0
- package/.agent/plugins/poster-plugin/src/components/progress.js +79 -0
- package/.agent/plugins/poster-plugin/src/components/progressCircle.js +117 -0
- package/.agent/plugins/poster-plugin/src/components/quote.js +97 -0
- package/.agent/plugins/poster-plugin/src/components/rating.js +85 -0
- package/.agent/plugins/poster-plugin/src/components/star.js +70 -0
- package/.agent/plugins/poster-plugin/src/components/statCard.js +105 -0
- package/.agent/plugins/poster-plugin/src/components/stepper.js +118 -0
- package/.agent/plugins/poster-plugin/src/components/table.js +159 -0
- package/.agent/plugins/poster-plugin/src/components/tagCloud.js +78 -0
- package/.agent/plugins/poster-plugin/src/components/timeline.js +105 -0
- package/.agent/plugins/poster-plugin/src/components/watermark.js +52 -0
- package/.agent/plugins/poster-plugin/src/composer.js +1904 -0
- package/.agent/plugins/poster-plugin/src/elements/artText.js +60 -0
- package/.agent/plugins/poster-plugin/src/elements/background.js +52 -0
- package/.agent/plugins/poster-plugin/src/elements/circle.js +31 -0
- package/.agent/plugins/poster-plugin/src/elements/image.js +71 -0
- package/.agent/plugins/poster-plugin/src/elements/index.js +26 -0
- package/.agent/plugins/poster-plugin/src/elements/line.js +23 -0
- package/.agent/plugins/poster-plugin/src/elements/polygon.js +63 -0
- package/.agent/plugins/poster-plugin/src/elements/rectangle.js +32 -0
- package/.agent/plugins/poster-plugin/src/elements/svg.js +92 -0
- package/.agent/plugins/poster-plugin/src/elements/text.js +107 -0
- package/.agent/plugins/poster-plugin/src/fonts.js +233 -0
- package/.agent/plugins/poster-plugin/src/index.js +1658 -0
- package/.agent/plugins/poster-plugin/src/presets.js +36 -0
- package/.agent/plugins/poster-plugin/src/templates/business.js +60 -0
- package/.agent/plugins/poster-plugin/src/templates/gradient.js +64 -0
- package/.agent/plugins/poster-plugin/src/templates/index.js +43 -0
- package/.agent/plugins/poster-plugin/src/templates/modern.js +69 -0
- package/.agent/plugins/poster-plugin/src/templates/simple.js +58 -0
- package/.agent/plugins/poster-plugin/src/templates/social.js +62 -0
- package/.agent/plugins/poster-plugin/src/templates/tech.js +84 -0
- package/.agent/plugins/{temp-repo/puppeteer-plugin → puppeteer-plugin}/index.js +1 -1
- package/.agent/plugins.json +5 -11
- package/.agent/rules/GEMINI.md +273 -0
- package/.agent/rules/allow-rule.md +77 -0
- package/.agent/rules/log-rule.md +83 -0
- package/.agent/rules/security-rule.md +93 -0
- package/.agent/scripts/auto_preview.py +148 -0
- package/.agent/scripts/checklist.py +217 -0
- package/.agent/scripts/session_manager.py +120 -0
- package/.agent/scripts/verify_all.py +327 -0
- package/.agent/sessions/cli_default.json +419 -0
- package/.agent/sessions/weixin_o9cq80zgZqKPA2-s59PN43GdDy1w@im.wechat.json +2195 -0
- package/.agent/skills/api-patterns/SKILL.md +81 -0
- package/.agent/skills/api-patterns/api-style.md +42 -0
- package/.agent/skills/api-patterns/auth.md +24 -0
- package/.agent/skills/api-patterns/documentation.md +26 -0
- package/.agent/skills/api-patterns/graphql.md +41 -0
- package/.agent/skills/api-patterns/rate-limiting.md +31 -0
- package/.agent/skills/api-patterns/response.md +37 -0
- package/.agent/skills/api-patterns/rest.md +40 -0
- package/.agent/skills/api-patterns/scripts/api_validator.py +211 -0
- package/.agent/skills/api-patterns/security-testing.md +122 -0
- package/.agent/skills/api-patterns/trpc.md +41 -0
- package/.agent/skills/api-patterns/versioning.md +22 -0
- package/.agent/skills/app-builder/SKILL.md +75 -0
- package/.agent/skills/app-builder/agent-coordination.md +71 -0
- package/.agent/skills/app-builder/feature-building.md +53 -0
- package/.agent/skills/app-builder/project-detection.md +34 -0
- package/.agent/skills/app-builder/scaffolding.md +118 -0
- package/.agent/skills/app-builder/tech-stack.md +40 -0
- package/.agent/skills/app-builder/templates/SKILL.md +39 -0
- package/.agent/skills/app-builder/templates/astro-static/TEMPLATE.md +76 -0
- package/.agent/skills/app-builder/templates/chrome-extension/TEMPLATE.md +92 -0
- package/.agent/skills/app-builder/templates/cli-tool/TEMPLATE.md +88 -0
- package/.agent/skills/app-builder/templates/electron-desktop/TEMPLATE.md +88 -0
- package/.agent/skills/app-builder/templates/express-api/TEMPLATE.md +83 -0
- package/.agent/skills/app-builder/templates/flutter-app/TEMPLATE.md +90 -0
- package/.agent/skills/app-builder/templates/monorepo-turborepo/TEMPLATE.md +90 -0
- package/.agent/skills/app-builder/templates/nextjs-fullstack/TEMPLATE.md +122 -0
- package/.agent/skills/app-builder/templates/nextjs-saas/TEMPLATE.md +122 -0
- package/.agent/skills/app-builder/templates/nextjs-static/TEMPLATE.md +169 -0
- package/.agent/skills/app-builder/templates/nuxt-app/TEMPLATE.md +134 -0
- package/.agent/skills/app-builder/templates/python-fastapi/TEMPLATE.md +83 -0
- package/.agent/skills/app-builder/templates/react-native-app/TEMPLATE.md +119 -0
- package/.agent/skills/architecture/SKILL.md +55 -0
- package/.agent/skills/architecture/context-discovery.md +43 -0
- package/.agent/skills/architecture/examples.md +94 -0
- package/.agent/skills/architecture/pattern-selection.md +68 -0
- package/.agent/skills/architecture/patterns-reference.md +50 -0
- package/.agent/skills/architecture/trade-off-analysis.md +77 -0
- package/.agent/skills/clean-code/SKILL.md +201 -0
- package/.agent/skills/doc.md +177 -0
- package/.agent/skills/frontend-design/SKILL.md +418 -0
- package/.agent/skills/frontend-design/animation-guide.md +331 -0
- package/.agent/skills/frontend-design/color-system.md +311 -0
- package/.agent/skills/frontend-design/decision-trees.md +418 -0
- package/.agent/skills/frontend-design/motion-graphics.md +306 -0
- package/.agent/skills/frontend-design/scripts/accessibility_checker.py +183 -0
- package/.agent/skills/frontend-design/scripts/ux_audit.py +722 -0
- package/.agent/skills/frontend-design/typography-system.md +345 -0
- package/.agent/skills/frontend-design/ux-psychology.md +1116 -0
- package/.agent/skills/frontend-design/visual-effects.md +383 -0
- package/.agent/skills/i18n-localization/SKILL.md +154 -0
- package/.agent/skills/i18n-localization/scripts/i18n_checker.py +241 -0
- package/.agent/skills/mcp-builder/SKILL.md +176 -0
- package/.agent/skills/web-design-guidelines/SKILL.md +57 -0
- package/.agent/workflows/brainstorm.md +113 -0
- package/.agent/workflows/create.md +59 -0
- package/.agent/workflows/debug.md +103 -0
- package/.agent/workflows/deploy.md +176 -0
- package/.agent/workflows/enhance.md +63 -0
- package/.agent/workflows/orchestrate.md +237 -0
- package/.agent/workflows/plan.md +89 -0
- package/.agent/workflows/preview.md +81 -0
- package/.agent/workflows/simple-test.md +42 -0
- package/.agent/workflows/status.md +86 -0
- package/.agent/workflows/structured-orchestrate.md +180 -0
- package/.agent/workflows/test.md +144 -0
- package/.agent/workflows/ui-ux-pro-max.md +296 -0
- package/.claude/settings.local.json +20 -8
- package/.env.example +56 -56
- package/CLAUDE.md +144 -108
- package/README.md +441 -441
- package/calc_tokens_weixin.js +81 -0
- package/cli/src/commands/chat.js +2 -1
- package/docs/CONTEXT_DESIGN.md +1596 -0
- package/examples/test-concurrent-chat.js +60 -60
- package/foliko-creative-3.png +0 -0
- package/foliko-creative-4.png +0 -0
- package/foliko-creative-5.png +0 -0
- package/package.json +2 -2
- package/plugins/default-plugins.js +2 -1
- package/plugins/extension-executor-plugin.js +91 -2
- package/plugins/file-system-plugin.js +2 -2
- package/plugins/memory-plugin.js +984 -0
- package/plugins/session-plugin.js +57 -1
- package/plugins/weixin-plugin.js +33 -23
- package/skills/find-skills/AGENTS.md +162 -162
- package/skills/find-skills/SKILL.md +133 -133
- package/skills/poster-guide/SKILL.md +1059 -0
- package/skills/python-plugin-dev/SKILL.md +238 -238
- package/skills/skill-guide/SKILL.md +130 -108
- package/src/capabilities/skill-manager.js +99 -0
- package/src/core/agent-chat.js +620 -141
- package/src/core/agent-context.js +188 -0
- package/src/core/agent.js +6 -2
- package/src/core/context-manager.js +283 -0
- package/src/core/framework.js +264 -3
- package/src/core/plugin-manager.js +79 -2
- package/src/core/request-context.js +98 -0
- package/src/core/session-context.js +341 -0
- package/src/core/session-storage.js +274 -0
- package/src/executors/mcp-executor.js +2 -2
- package/src/utils/index.js +239 -67
- package/src/utils/plugin-helpers.js +17 -0
- package/story-cover-book-v2.png +0 -0
- package/story-cover-japanese-1.png +0 -0
- package/story-cover-japanese-2.png +0 -0
- package/story-cover-japanese-3.png +0 -0
- package/story-cover-moran.png +0 -0
- package/undefined.png +0 -0
- package//346/265/267/346/212/245/346/217/222/344/273/266.md +621 -0
- package/.agent/agents/code-assistant.json +0 -14
- package/.agent/agents/email-assistant.json +0 -14
- package/.agent/agents/file-assistant.json +0 -15
- package/.agent/agents/system-assistant.json +0 -15
- package/.agent/agents/web-assistant.json +0 -12
- package/.agent/data/ambient/goals.json +0 -50
- package/.agent/data/ambient/memories.json +0 -7
- package/.agent/data/scheduler/tasks.json +0 -1
- package/.agent/package.json +0 -8
- package/.agent/plugins/__pycache__/test_plugin.cpython-312.pyc +0 -0
- package/.agent/plugins/daytona/README.md +0 -89
- package/.agent/plugins/daytona/index.js +0 -377
- package/.agent/plugins/daytona/package.json +0 -12
- package/.agent/plugins/marknative/README.md +0 -134
- package/.agent/plugins/marknative/index.js +0 -228
- package/.agent/plugins/marknative/package.json +0 -12
- package/.agent/plugins/marknative/update-readme.js +0 -134
- package/.agent/plugins/system-info/index.js +0 -387
- package/.agent/plugins/system-info/package.json +0 -4
- package/.agent/plugins/system-info/test.js +0 -40
- package/.agent/plugins/temp-repo/LICENSE +0 -201
- package/.agent/plugins/test_plugin.py +0 -304
- package/.agent/python-scripts/test_sample.py +0 -24
- package/.agent/skills/agent-browser/SKILL.md +0 -311
- package/.agent/skills/agent-browser/TEST_PLAN.md +0 -200
- package/.agent/skills/sysinfo/SKILL.md +0 -38
- package/.agent/skills/sysinfo/system-info.sh +0 -130
- package/.agent/skills/workflow/SKILL.md +0 -324
- package/.agent/workflows/email-digest.json +0 -50
- package/.agent/workflows/file-backup.json +0 -21
- package/.agent/workflows/get-ip-notify.json +0 -32
- package/.agent/workflows/news-aggregator.json +0 -93
- package/.agent/workflows/news-dashboard-v2.json +0 -94
- package/.agent/workflows/notification-batch.json +0 -32
- package/examples/test-chat-debug.js +0 -102
- package/examples/test-chat-result.js +0 -76
- package/examples/test-chat-stream-diff.js +0 -63
- /package/.agent/plugins/{temp-repo/puppeteer-plugin → puppeteer-plugin}/README.md +0 -0
- /package/.agent/plugins/{temp-repo/puppeteer-plugin → puppeteer-plugin}/package.json +0 -0
|
@@ -0,0 +1,304 @@
|
|
|
1
|
+
# Poster Plugin - 海报制作插件
|
|
2
|
+
|
|
3
|
+
基于 Paper.js 的海报/Banner 设计插件,支持**组件化**海报生成。
|
|
4
|
+
|
|
5
|
+
## 功能特性
|
|
6
|
+
|
|
7
|
+
- **预设尺寸**:20+ 常用尺寸(海报、Banner、社交媒体)
|
|
8
|
+
- **基础元素**:矩形、圆形、线条、多边形、图片、文字、艺术文字、图片框
|
|
9
|
+
- **布局组件**:分栏布局、网格布局
|
|
10
|
+
- **装饰组件**:星形、箭头、环形进度条、标签、图表、水印、表格
|
|
11
|
+
- **高级组件**:卡片、徽章、CTA按钮、特性展示、特性网格、分隔线、头像、进度条、评分、引用、统计卡、标签云、步骤条、时间线、列表项、通知
|
|
12
|
+
- **组件化生成**:通过 JSON 配置一次性生成完整海报
|
|
13
|
+
- **模板系统**:modern、business、social、simple、tech、gradient 六种预设模板
|
|
14
|
+
|
|
15
|
+
## 工具列表(共 35 个组件)
|
|
16
|
+
|
|
17
|
+
### 画布管理
|
|
18
|
+
| 工具 | 描述 |
|
|
19
|
+
|------|------|
|
|
20
|
+
| `list_poster_presets` | 列出所有预设尺寸 |
|
|
21
|
+
| `create_poster_canvas` | 创建新画布 |
|
|
22
|
+
| `get_poster_canvas_info` | 获取画布信息 |
|
|
23
|
+
| `clear_poster_canvas` | 清除画布 |
|
|
24
|
+
| `export_poster_canvas` | 导出为 PNG 文件 |
|
|
25
|
+
| `export_poster_svg` | 导出为 SVG 矢量图 |
|
|
26
|
+
| `export_poster_base64` | 导出为 Base64 |
|
|
27
|
+
|
|
28
|
+
### 基础元素 (10)
|
|
29
|
+
| 工具 | 描述 |
|
|
30
|
+
|------|------|
|
|
31
|
+
| `add_poster_background` | 添加纯色/渐变背景 |
|
|
32
|
+
| `add_poster_rectangle` | 添加矩形 |
|
|
33
|
+
| `add_poster_circle` | 添加圆形/椭圆 |
|
|
34
|
+
| `add_poster_line` | 添加线条 |
|
|
35
|
+
| `add_poster_polygon` | 添加多边形 |
|
|
36
|
+
| `add_poster_text` | 添加文字 |
|
|
37
|
+
| `add_poster_art_text` | 添加艺术文字(渐变/描边) |
|
|
38
|
+
| `add_poster_image` | 添加图片 |
|
|
39
|
+
| `add_poster_svg` | 添加 SVG 矢量图 |
|
|
40
|
+
| `add_poster_image_frame` | 添加图片框(带装饰边框) |
|
|
41
|
+
|
|
42
|
+
### 布局组件 (2)
|
|
43
|
+
| 工具 | 描述 |
|
|
44
|
+
|------|------|
|
|
45
|
+
| `add_poster_columns` | 分栏布局(左右分栏、多栏) |
|
|
46
|
+
| `add_poster_grid` | 网格布局(任意行列) |
|
|
47
|
+
|
|
48
|
+
### 装饰组件 (7)
|
|
49
|
+
| 工具 | 描述 |
|
|
50
|
+
|------|------|
|
|
51
|
+
| `add_poster_star` | 星形/多角形装饰 |
|
|
52
|
+
| `add_poster_arrow` | 箭头指示 |
|
|
53
|
+
| `add_poster_progress_circle` | 环形进度条 |
|
|
54
|
+
| `add_poster_chip` | 小型标签 |
|
|
55
|
+
| `add_poster_chart` | 图表(柱状图、饼图) |
|
|
56
|
+
| `add_poster_watermark` | 水印文字 |
|
|
57
|
+
| `add_poster_table` | 数据表格 |
|
|
58
|
+
|
|
59
|
+
### 高级组件 (16)
|
|
60
|
+
| 工具 | 描述 |
|
|
61
|
+
|------|------|
|
|
62
|
+
| `add_poster_card` | 卡片组件 |
|
|
63
|
+
| `add_poster_badge` | 徽章/标签 |
|
|
64
|
+
| `add_poster_cta` | CTA 行动号召按钮 |
|
|
65
|
+
| `add_poster_feature` | 特性展示块 |
|
|
66
|
+
| `add_poster_feature_grid` | 特性网格布局 |
|
|
67
|
+
| `add_poster_divider` | 分隔线 |
|
|
68
|
+
| `add_poster_avatar` | 用户头像 |
|
|
69
|
+
| `add_poster_progress` | 线性进度条 |
|
|
70
|
+
| `add_poster_rating` | 星级评分 |
|
|
71
|
+
| `add_poster_quote` | 引用块 |
|
|
72
|
+
| `add_poster_stat_card` | 统计卡片 |
|
|
73
|
+
| `add_poster_tag_cloud` | 标签云 |
|
|
74
|
+
| `add_poster_stepper` | 步骤指示器 |
|
|
75
|
+
| `add_poster_timeline` | 时间线 |
|
|
76
|
+
| `add_poster_list_item` | 列表项 |
|
|
77
|
+
| `add_poster_notification` | 通知提示 |
|
|
78
|
+
|
|
79
|
+
### 组件化生成 & 模板
|
|
80
|
+
| 工具 | 描述 |
|
|
81
|
+
|------|------|
|
|
82
|
+
| `compose_poster` | 使用组件配置生成海报 |
|
|
83
|
+
| `list_poster_components` | 列出可用组件类型 |
|
|
84
|
+
| `generate_poster` | 一键生成海报(6种模板) |
|
|
85
|
+
| `list_poster_templates` | 列出可用模板 |
|
|
86
|
+
|
|
87
|
+
## 预设尺寸
|
|
88
|
+
|
|
89
|
+
| Key | 尺寸 | 名称 |
|
|
90
|
+
|-----|------|------|
|
|
91
|
+
| `poster_a4` | 2480×3508 | A4海报 (300dpi) |
|
|
92
|
+
| `poster_square` | 2000×2000 | 方形海报 |
|
|
93
|
+
| `poster_16_9` | 1920×1080 | 16:9海报 |
|
|
94
|
+
| `poster_9_16` | 1080×1920 | 9:16竖版海报 |
|
|
95
|
+
| `banner_1920x500` | 1920×500 | 网站Banner |
|
|
96
|
+
| `banner_twitter` | 1500×500 | Twitter封面 |
|
|
97
|
+
| `social_instagram` | 1080×1080 | Instagram正方形 |
|
|
98
|
+
| `social_story` | 1080×1920 | Instagram Story |
|
|
99
|
+
| `social_facebook` | 1200×630 | Facebook封面 |
|
|
100
|
+
| `social_linkedin` | 1200×627 | LinkedIn封面 |
|
|
101
|
+
| `social_youtube` | 2560×1440 | YouTube封面 |
|
|
102
|
+
|
|
103
|
+
## 使用示例
|
|
104
|
+
|
|
105
|
+
### 1. 组件化生成(推荐)
|
|
106
|
+
|
|
107
|
+
```javascript
|
|
108
|
+
compose_poster({
|
|
109
|
+
components: [
|
|
110
|
+
// 背景
|
|
111
|
+
{ type: 'background', color: '#1a1a2e' },
|
|
112
|
+
|
|
113
|
+
// 装饰圆形
|
|
114
|
+
{ type: 'circle', cx: 1600, cy: 200, rx: 200, fill: '#00d9ff', opacity: 0.3 },
|
|
115
|
+
|
|
116
|
+
// 星形装饰
|
|
117
|
+
{ type: 'star', cx: 200, cy: 200, points: 5, outerRadius: 60, fill: '#fbbf24' },
|
|
118
|
+
|
|
119
|
+
// 主标题
|
|
120
|
+
{ type: 'artText', text: 'VB-Agent', x: 960, y: 400, fontSize: 120,
|
|
121
|
+
gradient: { colors: ['#00d9ff', '#00ff88'] } },
|
|
122
|
+
|
|
123
|
+
// 环形进度条
|
|
124
|
+
{ type: 'progressCircle', cx: 400, cy: 600, radius: 80, value: 85,
|
|
125
|
+
strokeWidth: 15, fillColor: '#3b82f6', showLabel: true },
|
|
126
|
+
{ type: 'progressCircle', cx: 700, cy: 600, radius: 80, value: 92,
|
|
127
|
+
strokeWidth: 15, fillColor: '#10b981', showLabel: true },
|
|
128
|
+
|
|
129
|
+
// 图表
|
|
130
|
+
{ type: 'chart', type: 'bar', x: 1100, y: 450, width: 400, height: 250,
|
|
131
|
+
data: [
|
|
132
|
+
{ label: '一月', value: 120, color: '#3b82f6' },
|
|
133
|
+
{ label: '二月', value: 90, color: '#10b981' },
|
|
134
|
+
{ label: '三月', value: 150, color: '#f59e0b' }
|
|
135
|
+
],
|
|
136
|
+
showLabels: true, showValues: true },
|
|
137
|
+
|
|
138
|
+
// 数据表格
|
|
139
|
+
{ type: 'table', x: 100, y: 700, width: 800,
|
|
140
|
+
columns: [
|
|
141
|
+
{ title: '功能', width: 300, align: 'left' },
|
|
142
|
+
{ title: '状态', width: 200 },
|
|
143
|
+
{ title: '价格', width: 150 }
|
|
144
|
+
],
|
|
145
|
+
rows: [
|
|
146
|
+
['智能对话', '可用', '免费'],
|
|
147
|
+
['图片生成', '可用', '$29'],
|
|
148
|
+
['代码助手', 'Beta', '免费']
|
|
149
|
+
],
|
|
150
|
+
headerBg: '#1e293b', headerColor: '#ffffff', striped: true },
|
|
151
|
+
|
|
152
|
+
// 标签
|
|
153
|
+
{ type: 'chip', x: 400, y: 850, text: 'AI驱动', background: '#3b82f6', color: '#ffffff' },
|
|
154
|
+
{ type: 'chip', x: 550, y: 850, text: '开源', background: '#10b981', color: '#ffffff' },
|
|
155
|
+
|
|
156
|
+
// 水印
|
|
157
|
+
{ type: 'watermark', text: 'VB-Agent', cx: 960, cy: 1000, fontSize: 200,
|
|
158
|
+
color: 'rgba(255,255,255,0.03)', rotation: -15 },
|
|
159
|
+
|
|
160
|
+
// CTA 按钮
|
|
161
|
+
{ type: 'cta', x: 960, y: 950, text: '立即体验 →',
|
|
162
|
+
background: '#00d9ff', color: '#0a0a0f', fontSize: 24, radius: 30 }
|
|
163
|
+
]
|
|
164
|
+
})
|
|
165
|
+
export_poster_canvas({ filename: 'my-poster', outputDir: '.' })
|
|
166
|
+
```
|
|
167
|
+
|
|
168
|
+
### 2. 基础使用
|
|
169
|
+
|
|
170
|
+
```javascript
|
|
171
|
+
// 创建画布
|
|
172
|
+
create_poster_canvas({ preset: 'poster_square', background: '#1a1a2e' })
|
|
173
|
+
|
|
174
|
+
// 添加元素
|
|
175
|
+
add_poster_circle({ cx: 500, cy: 500, rx: 100, fill: '#00d9ff' })
|
|
176
|
+
add_poster_text({ text: 'Hello Foliko', x: 500, y: 600, fontSize: 48, color: '#ffffff', align: 'center' })
|
|
177
|
+
|
|
178
|
+
// 导出
|
|
179
|
+
export_poster_canvas({ filename: 'my-poster' })
|
|
180
|
+
```
|
|
181
|
+
|
|
182
|
+
## 新增组件详解
|
|
183
|
+
|
|
184
|
+
### 星形 (star)
|
|
185
|
+
```javascript
|
|
186
|
+
add_poster_star({
|
|
187
|
+
cx: 200, cy: 200, // 中心坐标
|
|
188
|
+
points: 5, // 星形点数
|
|
189
|
+
outerRadius: 60, // 外半径
|
|
190
|
+
fill: '#fbbf24', // 填充颜色
|
|
191
|
+
rotation: 0 // 旋转角度
|
|
192
|
+
})
|
|
193
|
+
```
|
|
194
|
+
|
|
195
|
+
### 环形进度条 (progressCircle)
|
|
196
|
+
```javascript
|
|
197
|
+
add_poster_progress_circle({
|
|
198
|
+
cx: 200, cy: 200, // 圆心坐标
|
|
199
|
+
radius: 80, // 圆环半径
|
|
200
|
+
value: 75, // 进度值 0-100
|
|
201
|
+
strokeWidth: 15, // 环宽度
|
|
202
|
+
trackColor: '#e5e7eb', // 轨道颜色
|
|
203
|
+
fillColor: '#3b82f6', // 进度颜色
|
|
204
|
+
backgroundColor: '#ffffff', // 背景填充
|
|
205
|
+
showLabel: true // 显示百分比
|
|
206
|
+
})
|
|
207
|
+
```
|
|
208
|
+
|
|
209
|
+
### 图表 (chart)
|
|
210
|
+
```javascript
|
|
211
|
+
// 柱状图
|
|
212
|
+
add_poster_chart({
|
|
213
|
+
type: 'bar', // bar 或 pie
|
|
214
|
+
x: 100, y: 300,
|
|
215
|
+
width: 500, height: 250,
|
|
216
|
+
data: [
|
|
217
|
+
{ label: '一月', value: 120, color: '#3b82f6' },
|
|
218
|
+
{ label: '二月', value: 90, color: '#10b981' }
|
|
219
|
+
],
|
|
220
|
+
showLabels: true,
|
|
221
|
+
showValues: true
|
|
222
|
+
})
|
|
223
|
+
|
|
224
|
+
// 饼图
|
|
225
|
+
add_poster_chart({
|
|
226
|
+
type: 'pie',
|
|
227
|
+
x: 700, y: 300,
|
|
228
|
+
width: 250, height: 250,
|
|
229
|
+
data: [
|
|
230
|
+
{ label: 'A', value: 45, color: '#3b82f6' },
|
|
231
|
+
{ label: 'B', value: 35, color: '#10b981' },
|
|
232
|
+
{ label: 'C', value: 20, color: '#f59e0b' }
|
|
233
|
+
],
|
|
234
|
+
showLabels: true
|
|
235
|
+
})
|
|
236
|
+
```
|
|
237
|
+
|
|
238
|
+
### 表格 (table)
|
|
239
|
+
```javascript
|
|
240
|
+
add_poster_table({
|
|
241
|
+
x: 100, y: 400,
|
|
242
|
+
width: 800,
|
|
243
|
+
columns: [
|
|
244
|
+
{ title: '功能', width: 300, align: 'left' },
|
|
245
|
+
{ title: '状态', width: 200 }
|
|
246
|
+
],
|
|
247
|
+
rows: [
|
|
248
|
+
['智能对话', '可用'],
|
|
249
|
+
['代码助手', 'Beta']
|
|
250
|
+
],
|
|
251
|
+
headerBg: '#1e293b',
|
|
252
|
+
headerColor: '#ffffff',
|
|
253
|
+
striped: true
|
|
254
|
+
})
|
|
255
|
+
```
|
|
256
|
+
|
|
257
|
+
### 标签 (chip)
|
|
258
|
+
```javascript
|
|
259
|
+
add_poster_chip({
|
|
260
|
+
x: 200, y: 300,
|
|
261
|
+
text: 'NEW', // 标签文字
|
|
262
|
+
background: '#ef4444', // 背景色
|
|
263
|
+
color: '#ffffff', // 文字颜色
|
|
264
|
+
fontSize: 14,
|
|
265
|
+
radius: 16, // 圆角
|
|
266
|
+
icon: '⭐' // 前置图标(可选)
|
|
267
|
+
})
|
|
268
|
+
```
|
|
269
|
+
|
|
270
|
+
## 项目结构
|
|
271
|
+
|
|
272
|
+
```
|
|
273
|
+
poster-plugin/
|
|
274
|
+
├── index.js # 插件入口
|
|
275
|
+
├── package.json # 包配置
|
|
276
|
+
├── README.md # 文档
|
|
277
|
+
├── src/
|
|
278
|
+
│ ├── index.js # 主模块
|
|
279
|
+
│ ├── canvas.js # 画布管理器
|
|
280
|
+
│ ├── presets.js # 预设尺寸
|
|
281
|
+
│ ├── fonts.js # 字体管理
|
|
282
|
+
│ ├── composer.js # 组件化生成器
|
|
283
|
+
│ ├── elements/ # 基础元素
|
|
284
|
+
│ ├── components/ # 高级组件
|
|
285
|
+
│ └── templates/ # 模板
|
|
286
|
+
└── fonts/ # 字体文件
|
|
287
|
+
```
|
|
288
|
+
|
|
289
|
+
## 更新日志
|
|
290
|
+
|
|
291
|
+
### v1.2.0
|
|
292
|
+
- 新增布局组件:columns(分栏)、grid(网格)
|
|
293
|
+
- 新增装饰组件:star(星形)、arrow(箭头)、progressCircle(环形进度条)
|
|
294
|
+
- 新增 chip(标签)、chart(图表)、watermark(水印)、table(表格)
|
|
295
|
+
- 新增 imageFrame(图片框)
|
|
296
|
+
- 组件总数达到 **35 个**
|
|
297
|
+
- 模板新增 tech(科技)、gradient(渐变)
|
|
298
|
+
- 修复环形进度条绘制逻辑
|
|
299
|
+
|
|
300
|
+
### v1.1.0
|
|
301
|
+
- 重构为模块化架构
|
|
302
|
+
- 新增组件化海报生成(compose_poster)
|
|
303
|
+
- 新增高级组件:card, badge, cta, feature, featureGrid, divider
|
|
304
|
+
- 新增组件:avatar, progress, rating, quote, statCard, tagCloud, stepper, timeline, listItem, notification
|
|
Binary file
|
|
Binary file
|
package/.agent/plugins/poster-plugin/fonts//345/276/256/350/275/257/351/233/205/351/273/221.ttf
ADDED
|
Binary file
|
|
Binary file
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Poster Plugin - 海报制作插件
|
|
3
|
+
*
|
|
4
|
+
* 模块化架构,支持组件化海报生成
|
|
5
|
+
*
|
|
6
|
+
* 使用方法:
|
|
7
|
+
* 1. 基础元素:add_poster_rectangle, add_poster_circle, add_poster_text 等
|
|
8
|
+
* 2. 高级组件:add_poster_card, add_poster_badge, add_poster_cta 等
|
|
9
|
+
* 3. 组件化生成:compose_poster - 通过配置 JSON 一次性生成海报
|
|
10
|
+
* 4. 模板生成:generate_poster - 一键使用预设模板
|
|
11
|
+
*/
|
|
12
|
+
|
|
13
|
+
module.exports = require('./src/index.js')
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "poster-plugin",
|
|
3
|
+
"version": "1.2.0",
|
|
4
|
+
"description": "海报/Banner 设计插件 - 基于 Paper.js 实现,支持 35 个组件",
|
|
5
|
+
"main": "index.js",
|
|
6
|
+
"dependencies": {
|
|
7
|
+
"canvas": "^3.2.0",
|
|
8
|
+
"fontkit": "^2.0.4",
|
|
9
|
+
"jsdom": "^16.2.2",
|
|
10
|
+
"paper": "^0.12.18"
|
|
11
|
+
},
|
|
12
|
+
"overrides": {
|
|
13
|
+
"canvas": "^3.2.0"
|
|
14
|
+
},
|
|
15
|
+
"resolutions": {
|
|
16
|
+
"**/canvas": "^3.2.0"
|
|
17
|
+
},
|
|
18
|
+
"author": "",
|
|
19
|
+
"license": "MIT",
|
|
20
|
+
"keywords": [
|
|
21
|
+
"poster",
|
|
22
|
+
"banner",
|
|
23
|
+
"design",
|
|
24
|
+
"canvas",
|
|
25
|
+
"paper.js",
|
|
26
|
+
"foliko"
|
|
27
|
+
]
|
|
28
|
+
}
|
|
@@ -0,0 +1,161 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 画布管理模块
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
const paper = require('paper')
|
|
6
|
+
const PRESETS = require('./presets')
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* 画布管理器类
|
|
10
|
+
*/
|
|
11
|
+
class CanvasManager {
|
|
12
|
+
constructor() {
|
|
13
|
+
this._canvas = null
|
|
14
|
+
this._project = null
|
|
15
|
+
this._paper = null
|
|
16
|
+
this._width = 0
|
|
17
|
+
this._height = 0
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* 创建画布
|
|
22
|
+
*/
|
|
23
|
+
create({ preset, width, height, background }) {
|
|
24
|
+
let w, h
|
|
25
|
+
|
|
26
|
+
if (preset) {
|
|
27
|
+
const presetConfig = PRESETS[preset]
|
|
28
|
+
if (!presetConfig) {
|
|
29
|
+
throw new Error(`Unknown preset: ${preset}. Available: ${Object.keys(PRESETS).join(', ')}`)
|
|
30
|
+
}
|
|
31
|
+
w = presetConfig.width
|
|
32
|
+
h = presetConfig.height
|
|
33
|
+
} else if (width && height) {
|
|
34
|
+
w = width
|
|
35
|
+
h = height
|
|
36
|
+
} else {
|
|
37
|
+
throw new Error('Must provide preset or width/height')
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
this._canvas = paper.createCanvas(w, h)
|
|
41
|
+
this._project = new paper.Project(this._canvas)
|
|
42
|
+
// 确保活动层存在
|
|
43
|
+
if (!paper.project || !paper.project.activeLayer) {
|
|
44
|
+
paper.setup(this._canvas)
|
|
45
|
+
}
|
|
46
|
+
this._paper = paper
|
|
47
|
+
this._width = w
|
|
48
|
+
this._height = h
|
|
49
|
+
|
|
50
|
+
// 添加背景
|
|
51
|
+
if (background) {
|
|
52
|
+
const bg = new paper.Path.Rectangle({
|
|
53
|
+
point: [0, 0],
|
|
54
|
+
size: [w, h],
|
|
55
|
+
fillColor: background,
|
|
56
|
+
})
|
|
57
|
+
bg.sendToBack()
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
return {
|
|
61
|
+
width: w,
|
|
62
|
+
height: h,
|
|
63
|
+
preset: preset || 'custom',
|
|
64
|
+
background: background || null,
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
/**
|
|
69
|
+
* 获取画布
|
|
70
|
+
*/
|
|
71
|
+
getCanvas() {
|
|
72
|
+
return this._canvas
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
/**
|
|
76
|
+
* 获取 Paper.js 项目
|
|
77
|
+
*/
|
|
78
|
+
getProject() {
|
|
79
|
+
return this._project
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
/**
|
|
83
|
+
* 获取画布尺寸
|
|
84
|
+
*/
|
|
85
|
+
getSize() {
|
|
86
|
+
return { width: this._width, height: this._height }
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
/**
|
|
90
|
+
* 获取中心点
|
|
91
|
+
*/
|
|
92
|
+
getCenter() {
|
|
93
|
+
return { x: this._width / 2, y: this._height / 2 }
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
/**
|
|
97
|
+
* 清除画布
|
|
98
|
+
*/
|
|
99
|
+
clear() {
|
|
100
|
+
if (this._project) {
|
|
101
|
+
this._project.activeLayer.removeChildren()
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
/**
|
|
106
|
+
* 获取元素数量
|
|
107
|
+
*/
|
|
108
|
+
getElementCount() {
|
|
109
|
+
return this._project ? this._project.activeLayer.children.length : 0
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
/**
|
|
113
|
+
* 导出为 Buffer
|
|
114
|
+
*/
|
|
115
|
+
toBuffer(format = 'png', quality) {
|
|
116
|
+
if (!this._canvas) {
|
|
117
|
+
throw new Error('No canvas created')
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
this._project.view.update()
|
|
121
|
+
this._project.view.draw()
|
|
122
|
+
|
|
123
|
+
const mimeType = format === 'jpg' ? 'image/jpeg' : 'image/png'
|
|
124
|
+
return this._canvas.toBuffer(mimeType, quality)
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
/**
|
|
128
|
+
* 导出为 Base64
|
|
129
|
+
*/
|
|
130
|
+
toBase64(format = 'png', quality) {
|
|
131
|
+
if (!this._canvas) {
|
|
132
|
+
throw new Error('No canvas created')
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
this._project.view.update()
|
|
136
|
+
this._project.view.draw()
|
|
137
|
+
|
|
138
|
+
const mimeType = format === 'jpg' ? 'image/jpeg' : 'image/png'
|
|
139
|
+
return this._canvas.toDataURL(mimeType, quality)
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
/**
|
|
143
|
+
* 检查画布是否已创建
|
|
144
|
+
*/
|
|
145
|
+
isCreated() {
|
|
146
|
+
return this._canvas !== null
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
/**
|
|
150
|
+
* 重置画布
|
|
151
|
+
*/
|
|
152
|
+
reset() {
|
|
153
|
+
this._canvas = null
|
|
154
|
+
this._project = null
|
|
155
|
+
this._paper = null
|
|
156
|
+
this._width = 0
|
|
157
|
+
this._height = 0
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
module.exports = CanvasManager
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 箭头组件
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
const paper = require('paper')
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* 创建箭头组件
|
|
9
|
+
*/
|
|
10
|
+
function createArrow(project, canvas, params) {
|
|
11
|
+
const {
|
|
12
|
+
x1, y1, x2, y2,
|
|
13
|
+
color = '#333333',
|
|
14
|
+
strokeWidth = 2,
|
|
15
|
+
headSize = 12,
|
|
16
|
+
style = 'solid',
|
|
17
|
+
direction = 'end'
|
|
18
|
+
} = params
|
|
19
|
+
|
|
20
|
+
const elements = []
|
|
21
|
+
|
|
22
|
+
// 创建主线
|
|
23
|
+
const line = new paper.Path.Line({
|
|
24
|
+
from: [x1, y1],
|
|
25
|
+
to: [x2, y2]
|
|
26
|
+
})
|
|
27
|
+
line.strokeColor = new paper.Color(color)
|
|
28
|
+
line.strokeWidth = strokeWidth
|
|
29
|
+
if (style === 'dashed') {
|
|
30
|
+
line.dashArray = [10, 5]
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
if (project && project.activeLayer) {
|
|
34
|
+
project.activeLayer.addChild(line)
|
|
35
|
+
}
|
|
36
|
+
elements.push({ type: 'line', id: line.id })
|
|
37
|
+
|
|
38
|
+
// 创建箭头头部
|
|
39
|
+
function createArrowHead(x, y, angle) {
|
|
40
|
+
const path = new paper.Path()
|
|
41
|
+
const angle1 = angle + Math.PI * 0.8
|
|
42
|
+
const angle2 = angle - Math.PI * 0.8
|
|
43
|
+
|
|
44
|
+
path.moveTo(x, y)
|
|
45
|
+
path.lineTo(
|
|
46
|
+
x + headSize * Math.cos(angle1),
|
|
47
|
+
y + headSize * Math.sin(angle1)
|
|
48
|
+
)
|
|
49
|
+
path.moveTo(x, y)
|
|
50
|
+
path.lineTo(
|
|
51
|
+
x + headSize * Math.cos(angle2),
|
|
52
|
+
y + headSize * Math.sin(angle2)
|
|
53
|
+
)
|
|
54
|
+
|
|
55
|
+
path.strokeColor = new paper.Color(color)
|
|
56
|
+
path.strokeWidth = strokeWidth
|
|
57
|
+
path.strokeCap = 'round'
|
|
58
|
+
|
|
59
|
+
if (project && project.activeLayer) {
|
|
60
|
+
project.activeLayer.addChild(path)
|
|
61
|
+
}
|
|
62
|
+
return path
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
const angle = Math.atan2(y2 - y1, x2 - x1)
|
|
66
|
+
|
|
67
|
+
if (direction === 'end' || direction === 'both') {
|
|
68
|
+
const head = createArrowHead(x2, y2, angle)
|
|
69
|
+
elements.push({ type: 'path', id: head.id })
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
if (direction === 'start' || direction === 'both') {
|
|
73
|
+
const head = createArrowHead(x1, y1, angle + Math.PI)
|
|
74
|
+
elements.push({ type: 'path', id: head.id })
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
return {
|
|
78
|
+
success: true,
|
|
79
|
+
elements,
|
|
80
|
+
type: 'arrow'
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
module.exports = createArrow
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 头像组件
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
const paper = require('paper')
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* 创建头像
|
|
9
|
+
*
|
|
10
|
+
* @param {Object} project - Paper.js 项目
|
|
11
|
+
* @param {Object} canvas - 画布对象
|
|
12
|
+
* @param {Object} args - 组件参数
|
|
13
|
+
* @param {number} args.x - 圆心X坐标
|
|
14
|
+
* @param {number} args.y - 圆心Y坐标
|
|
15
|
+
* @param {number} args.size - 头像大小
|
|
16
|
+
* @param {string} args.src - 图片路径(可选,不提供则显示首字母)
|
|
17
|
+
* @param {string} args.initials - 首字母(无图片时显示)
|
|
18
|
+
* @param {string} args.background - 背景色
|
|
19
|
+
* @param {string} args.border - 边框颜色
|
|
20
|
+
* @param {number} args.borderWidth - 边框宽度
|
|
21
|
+
* @param {string} args.color - 文字颜色
|
|
22
|
+
*/
|
|
23
|
+
function createAvatar(project, canvas, args) {
|
|
24
|
+
const {
|
|
25
|
+
x, y,
|
|
26
|
+
size = 80,
|
|
27
|
+
src,
|
|
28
|
+
initials,
|
|
29
|
+
background = '#6366f1',
|
|
30
|
+
border,
|
|
31
|
+
borderWidth = 0,
|
|
32
|
+
color = '#ffffff',
|
|
33
|
+
} = args
|
|
34
|
+
|
|
35
|
+
const elements = []
|
|
36
|
+
const radius = size / 2
|
|
37
|
+
|
|
38
|
+
// 绘制圆形背景
|
|
39
|
+
const circle = new paper.Path.Circle({
|
|
40
|
+
center: [x, y],
|
|
41
|
+
radius: radius,
|
|
42
|
+
})
|
|
43
|
+
circle.fillColor = new paper.Color(background)
|
|
44
|
+
|
|
45
|
+
if (border) {
|
|
46
|
+
circle.strokeColor = new paper.Color(border)
|
|
47
|
+
circle.strokeWidth = borderWidth
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
elements.push({ type: 'circle', id: circle.id })
|
|
51
|
+
|
|
52
|
+
// 如果没有图片,显示首字母
|
|
53
|
+
if (!src && initials) {
|
|
54
|
+
const text = new paper.PointText({
|
|
55
|
+
point: [x, y + size / 6],
|
|
56
|
+
content: initials.charAt(0).toUpperCase(),
|
|
57
|
+
fontSize: size * 0.4,
|
|
58
|
+
fillColor: new paper.Color(color),
|
|
59
|
+
justification: 'center',
|
|
60
|
+
})
|
|
61
|
+
elements.push({ type: 'text', id: text.id })
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
return {
|
|
65
|
+
success: true,
|
|
66
|
+
elements,
|
|
67
|
+
size,
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
module.exports = createAvatar
|