foliko 1.1.8 → 1.1.9
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/agents/code-assistant.json +17 -0
- package/.agent/agents/email-assistant.json +14 -0
- package/.agent/agents/file-assistant.json +18 -0
- package/.agent/agents/orchestrator-demo.md +53 -0
- package/.agent/agents/orchestrator.json +7 -0
- package/.agent/agents/poster-expert.md +228 -0
- package/.agent/agents/system-assistant.json +15 -0
- package/.agent/agents/web-assistant.json +12 -0
- package/.agent/data/default.json +5 -404
- package/.agent/data/email/processed-emails.json +1 -0
- package/.agent/data/plugins-state.json +173 -172
- package/.agent/data/scheduler/tasks.json +1 -0
- package/.agent/data/web/web-config.json +5 -0
- package/.agent/mcp_config.json +0 -14
- package/.agent/package.json +8 -0
- package/.agent/plugins/__pycache__/file_writer.cpython-312.pyc +0 -0
- package/.agent/plugins/daytona/README.md +89 -0
- package/.agent/plugins/daytona/index.js +377 -0
- package/.agent/plugins/daytona/package.json +12 -0
- package/.agent/plugins/marknative/README.md +134 -0
- package/.agent/plugins/marknative/fonts.zip +0 -0
- package/.agent/plugins/marknative/index.js +256 -0
- package/.agent/plugins/marknative/package.json +12 -0
- package/.agent/plugins/system-info/index.js +387 -0
- package/.agent/plugins/system-info/package.json +4 -0
- package/.agent/plugins/system-info/test.js +40 -0
- package/.agent/plugins/test-plugin.py +123 -0
- package/.agent/plugins/test_nested_plugin.py +85 -0
- package/.agent/plugins.json +11 -5
- package/.agent/python-scripts/test_sample.py +24 -0
- package/.agent/sessions/cli_default.json +96 -249
- package/.agent/sessions/weixin_o9cq80zgZqKPA2-s59PN43GdDy1w@im.wechat.json +189 -0
- package/.agent/skills/agent-browser/SKILL.md +311 -0
- package/.agent/skills/agent-browser/TEST_PLAN.md +200 -0
- package/.agent/skills/sysinfo/SKILL.md +38 -0
- package/.agent/skills/sysinfo/system-info.sh +130 -0
- package/.agent/skills/workflow/SKILL.md +324 -0
- package/.agent/test-agent.js +35 -0
- package/.agent/weixin.json +6 -0
- package/.agent/workflows/email-digest.json +50 -0
- package/.agent/workflows/file-backup.json +21 -0
- package/.agent/workflows/get-ip-notify.json +32 -0
- package/.agent/workflows/news-aggregator.json +93 -0
- package/.agent/workflows/news-dashboard-v2.json +94 -0
- package/.agent/workflows/notification-batch.json +32 -0
- package/.claude/settings.local.json +9 -1
- package/.env.example +56 -56
- package/README.md +441 -441
- package/cli/src/ui/chat-ui.js +32 -21
- package/foliko_poster.png +0 -0
- package/output/business_poster_final.png +0 -0
- package/output/emoji_test_v2.png +0 -0
- package/output/foliko-ai-launch-poster.png +0 -0
- package/output/foliko-poster.png +0 -0
- package/output/muji_style_poster.png +0 -0
- package/output/new_product_launch.png +0 -0
- package/output/news_poster_625yi_subsidy.png +0 -0
- package/output/tech_future_2026.png +0 -0
- package/output/tech_future_poster.png +0 -0
- package/package.json +1 -2
- package/plugins/default-plugins.js +58 -6
- package/plugins/extension-executor-plugin.js +8 -21
- package/plugins/python-plugin-loader.js +461 -40
- package/plugins/python-plugin-loader.js.bak +856 -0
- package/plugins/subagent-plugin.js +0 -121
- package/plugins/weixin-plugin.js +38 -29
- package/poster.png +0 -0
- package/skills/find-skills/AGENTS.md +162 -162
- package/skills/find-skills/SKILL.md +133 -133
- package/skills/foliko-dev/SKILL.md +6 -0
- package/skills/python-plugin-dev/SKILL.md +124 -2
- package/src/core/agent-chat.js +220 -281
- package/src/core/agent.js +10 -0
- package/src/utils/plugin-helpers.js +22 -4
- package/system.md +1678 -1574
- package/test-scan.js +18 -0
- package/.agent/.shared/ui-ux-pro-max/data/charts.csv +0 -26
- package/.agent/.shared/ui-ux-pro-max/data/colors.csv +0 -97
- package/.agent/.shared/ui-ux-pro-max/data/icons.csv +0 -101
- package/.agent/.shared/ui-ux-pro-max/data/landing.csv +0 -31
- package/.agent/.shared/ui-ux-pro-max/data/products.csv +0 -97
- package/.agent/.shared/ui-ux-pro-max/data/prompts.csv +0 -24
- package/.agent/.shared/ui-ux-pro-max/data/react-performance.csv +0 -45
- package/.agent/.shared/ui-ux-pro-max/data/stacks/flutter.csv +0 -53
- package/.agent/.shared/ui-ux-pro-max/data/stacks/html-tailwind.csv +0 -56
- package/.agent/.shared/ui-ux-pro-max/data/stacks/jetpack-compose.csv +0 -53
- package/.agent/.shared/ui-ux-pro-max/data/stacks/nextjs.csv +0 -53
- package/.agent/.shared/ui-ux-pro-max/data/stacks/nuxt-ui.csv +0 -51
- package/.agent/.shared/ui-ux-pro-max/data/stacks/nuxtjs.csv +0 -59
- package/.agent/.shared/ui-ux-pro-max/data/stacks/react-native.csv +0 -52
- package/.agent/.shared/ui-ux-pro-max/data/stacks/react.csv +0 -54
- package/.agent/.shared/ui-ux-pro-max/data/stacks/shadcn.csv +0 -61
- package/.agent/.shared/ui-ux-pro-max/data/stacks/svelte.csv +0 -54
- package/.agent/.shared/ui-ux-pro-max/data/stacks/swiftui.csv +0 -51
- package/.agent/.shared/ui-ux-pro-max/data/stacks/vue.csv +0 -50
- package/.agent/.shared/ui-ux-pro-max/data/styles.csv +0 -59
- package/.agent/.shared/ui-ux-pro-max/data/typography.csv +0 -58
- package/.agent/.shared/ui-ux-pro-max/data/ui-reasoning.csv +0 -101
- package/.agent/.shared/ui-ux-pro-max/data/ux-guidelines.csv +0 -100
- package/.agent/.shared/ui-ux-pro-max/data/web-interface.csv +0 -31
- 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 +0 -258
- package/.agent/.shared/ui-ux-pro-max/scripts/design_system.py +0 -1067
- package/.agent/.shared/ui-ux-pro-max/scripts/search.py +0 -106
- package/.agent/ARCHITECTURE.md +0 -288
- package/.agent/agents/ambient-agent.md +0 -57
- package/.agent/agents/debugger.md +0 -55
- package/.agent/agents/email-assistant.md +0 -49
- package/.agent/agents/file-manager.md +0 -42
- package/.agent/agents/python-developer.md +0 -60
- package/.agent/agents/scheduler.md +0 -59
- package/.agent/agents/web-developer.md +0 -45
- package/.agent/data/puppeteer-sessions/undefined.json +0 -6
- package/.agent/data/weixin-media/2026-04-08/img_1775618677512.jpg +0 -0
- package/.agent/data/weixin-media/2026-04-08/img_1775619073340.jpg +0 -0
- package/.agent/data/weixin-media/2026-04-08/img_1775619097536.jpg +0 -0
- package/.agent/data/weixin-media/2026-04-08/img_1775619209388.jpg +0 -0
- package/.agent/memory/feedback/mnrdvj5i-ca3dkd.md +0 -9
- package/.agent/memory/feedback/mnre365e-7s4zax.md +0 -9
- package/.agent/memory/feedback/mnre36jn-nkfgmp.md +0 -9
- package/.agent/memory/feedback/mnre3805-kjiq6h.md +0 -9
- package/.agent/memory/feedback/mnsf66kp-b10rcd.md +0 -9
- package/.agent/memory/feedback/mnsi3sz8-p5g2cw.md +0 -9
- package/.agent/memory/feedback/mnsibe47-sv2ni1.md +0 -9
- package/.agent/memory/feedback/mnsic89w-nn228o.md +0 -9
- package/.agent/memory/feedback/mnsj1xe9-x83ba0.md +0 -9
- package/.agent/memory/feedback/mnsj21iv-wnwelx.md +0 -9
- package/.agent/memory/feedback/mnsj2g4a-cog7a2.md +0 -9
- package/.agent/memory/feedback/mnsj4js7-lktjp6.md +0 -9
- package/.agent/memory/feedback/mnsj5d4y-uglwvp.md +0 -9
- package/.agent/memory/feedback/mnslkuo9-uous66.md +0 -24
- package/.agent/memory/feedback/mnsm3vq0-megoil.md +0 -9
- package/.agent/memory/feedback/mnsnn5x2-sxcihd.md +0 -9
- package/.agent/memory/feedback/mnsnq17s-nabrn9.md +0 -9
- package/.agent/memory/feedback/mnsnybet-wz7rn3.md +0 -9
- package/.agent/memory/feedback/mnsrw0s7-7s9e30.md +0 -9
- package/.agent/memory/feedback/mnu5hpnd-tlm16q.md +0 -9
- package/.agent/memory/feedback/mnu60uqe-xuoxp4.md +0 -9
- package/.agent/memory/project/mnqx54u5-loqtoe.md +0 -9
- package/.agent/memory/project/mnqx84cv-mx6dmd.md +0 -9
- package/.agent/memory/project/mnsacuyr-hgtk5n.md +0 -20
- package/.agent/memory/project/mnu5hy2x-bjsg7u.md +0 -9
- package/.agent/memory/reference/mnre3cww-penbo1.md +0 -9
- package/.agent/memory/reference/mns9wn48-luerua.md +0 -14
- package/.agent/memory/reference/mns9yz5c-thc2s0.md +0 -16
- package/.agent/memory/reference/mnsfy4um-910f1o.md +0 -23
- package/.agent/memory/reference/mnsg37dp-lmfj18.md +0 -32
- package/.agent/memory/reference/mnsll60q-0j911u.md +0 -36
- package/.agent/memory/reference/mnsmlb5y-nej31u.md +0 -16
- package/.agent/memory/reference/mnssle72-yrot96.md +0 -9
- package/.agent/memory/user/mnsfuon6-l416q1.md +0 -21
- package/.agent/memory/user/mnsg9kut-95m7rf.md +0 -20
- package/.agent/memory/user/mnu2eo1v-yy6fhe.md +0 -9
- package/.agent/memory/user/mnu2etuo-8u8jk8.md +0 -9
- package/.agent/plugins/poster-plugin/README.md +0 -304
- 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/Symbola_hint.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 +0 -13
- package/.agent/plugins/poster-plugin/package.json +0 -29
- package/.agent/plugins/poster-plugin/src/canvas.js +0 -232
- package/.agent/plugins/poster-plugin/src/components/arrow.js +0 -84
- package/.agent/plugins/poster-plugin/src/components/avatar.js +0 -71
- package/.agent/plugins/poster-plugin/src/components/badge.js +0 -85
- package/.agent/plugins/poster-plugin/src/components/barcode.js +0 -123
- package/.agent/plugins/poster-plugin/src/components/bubble.js +0 -154
- package/.agent/plugins/poster-plugin/src/components/button.js +0 -168
- package/.agent/plugins/poster-plugin/src/components/card.js +0 -88
- package/.agent/plugins/poster-plugin/src/components/chart.js +0 -127
- package/.agent/plugins/poster-plugin/src/components/chip.js +0 -88
- package/.agent/plugins/poster-plugin/src/components/columns.js +0 -121
- package/.agent/plugins/poster-plugin/src/components/cta.js +0 -87
- package/.agent/plugins/poster-plugin/src/components/divider.js +0 -55
- package/.agent/plugins/poster-plugin/src/components/feature.js +0 -85
- package/.agent/plugins/poster-plugin/src/components/featureGrid.js +0 -117
- package/.agent/plugins/poster-plugin/src/components/frame.js +0 -230
- package/.agent/plugins/poster-plugin/src/components/grid.js +0 -130
- package/.agent/plugins/poster-plugin/src/components/highlightText.js +0 -145
- package/.agent/plugins/poster-plugin/src/components/icon.js +0 -94
- package/.agent/plugins/poster-plugin/src/components/imageFrame.js +0 -205
- package/.agent/plugins/poster-plugin/src/components/index.js +0 -81
- package/.agent/plugins/poster-plugin/src/components/listItem.js +0 -147
- package/.agent/plugins/poster-plugin/src/components/notification.js +0 -123
- package/.agent/plugins/poster-plugin/src/components/progress.js +0 -79
- package/.agent/plugins/poster-plugin/src/components/progressCircle.js +0 -117
- package/.agent/plugins/poster-plugin/src/components/qrcode.js +0 -74
- package/.agent/plugins/poster-plugin/src/components/quote.js +0 -169
- package/.agent/plugins/poster-plugin/src/components/rating.js +0 -85
- package/.agent/plugins/poster-plugin/src/components/ribbon.js +0 -197
- package/.agent/plugins/poster-plugin/src/components/seal.js +0 -148
- package/.agent/plugins/poster-plugin/src/components/star.js +0 -70
- package/.agent/plugins/poster-plugin/src/components/statCard.js +0 -105
- package/.agent/plugins/poster-plugin/src/components/stepper.js +0 -118
- package/.agent/plugins/poster-plugin/src/components/table.js +0 -167
- package/.agent/plugins/poster-plugin/src/components/tagCloud.js +0 -85
- package/.agent/plugins/poster-plugin/src/components/timeline.js +0 -117
- package/.agent/plugins/poster-plugin/src/components/watermark.js +0 -54
- package/.agent/plugins/poster-plugin/src/composer.js +0 -2314
- package/.agent/plugins/poster-plugin/src/elements/artText.js +0 -69
- package/.agent/plugins/poster-plugin/src/elements/background.js +0 -99
- package/.agent/plugins/poster-plugin/src/elements/circle.js +0 -31
- package/.agent/plugins/poster-plugin/src/elements/image.js +0 -28
- package/.agent/plugins/poster-plugin/src/elements/index.js +0 -28
- package/.agent/plugins/poster-plugin/src/elements/line.js +0 -23
- package/.agent/plugins/poster-plugin/src/elements/polygon.js +0 -63
- package/.agent/plugins/poster-plugin/src/elements/rectangle.js +0 -32
- package/.agent/plugins/poster-plugin/src/elements/richText.js +0 -283
- package/.agent/plugins/poster-plugin/src/elements/svg.js +0 -108
- package/.agent/plugins/poster-plugin/src/elements/text.js +0 -112
- package/.agent/plugins/poster-plugin/src/fonts.js +0 -674
- package/.agent/plugins/poster-plugin/src/index.js +0 -2126
- package/.agent/plugins/poster-plugin/src/presets.js +0 -36
- package/.agent/plugins/poster-plugin/src/templates/business.js +0 -60
- package/.agent/plugins/poster-plugin/src/templates/gradient.js +0 -64
- package/.agent/plugins/poster-plugin/src/templates/index.js +0 -43
- package/.agent/plugins/poster-plugin/src/templates/modern.js +0 -69
- package/.agent/plugins/poster-plugin/src/templates/simple.js +0 -58
- package/.agent/plugins/poster-plugin/src/templates/social.js +0 -62
- package/.agent/plugins/poster-plugin/src/templates/tech.js +0 -84
- package/.agent/plugins/poster-plugin/src/utils/imageLoader.js +0 -84
- package/.agent/plugins/poster-plugin/yarn.lock +0 -837
- package/.agent/plugins/puppeteer-plugin/README.md +0 -147
- package/.agent/plugins/puppeteer-plugin/index.js +0 -1422
- package/.agent/plugins/puppeteer-plugin/package.json +0 -9
- package/.agent/rules/GEMINI.md +0 -273
- package/.agent/rules/allow-rule.md +0 -77
- package/.agent/rules/log-rule.md +0 -83
- package/.agent/rules/security-rule.md +0 -93
- package/.agent/scripts/auto_preview.py +0 -148
- package/.agent/scripts/checklist.py +0 -217
- package/.agent/scripts/session_manager.py +0 -120
- package/.agent/scripts/verify_all.py +0 -327
- package/.agent/skills/api-patterns/SKILL.md +0 -81
- package/.agent/skills/api-patterns/api-style.md +0 -42
- package/.agent/skills/api-patterns/auth.md +0 -24
- package/.agent/skills/api-patterns/documentation.md +0 -26
- package/.agent/skills/api-patterns/graphql.md +0 -41
- package/.agent/skills/api-patterns/rate-limiting.md +0 -31
- package/.agent/skills/api-patterns/response.md +0 -37
- package/.agent/skills/api-patterns/rest.md +0 -40
- package/.agent/skills/api-patterns/scripts/api_validator.py +0 -211
- package/.agent/skills/api-patterns/security-testing.md +0 -122
- package/.agent/skills/api-patterns/trpc.md +0 -41
- package/.agent/skills/api-patterns/versioning.md +0 -22
- package/.agent/skills/app-builder/SKILL.md +0 -75
- package/.agent/skills/app-builder/agent-coordination.md +0 -71
- package/.agent/skills/app-builder/feature-building.md +0 -53
- package/.agent/skills/app-builder/project-detection.md +0 -34
- package/.agent/skills/app-builder/scaffolding.md +0 -118
- package/.agent/skills/app-builder/tech-stack.md +0 -40
- package/.agent/skills/app-builder/templates/SKILL.md +0 -39
- package/.agent/skills/app-builder/templates/astro-static/TEMPLATE.md +0 -76
- package/.agent/skills/app-builder/templates/chrome-extension/TEMPLATE.md +0 -92
- package/.agent/skills/app-builder/templates/cli-tool/TEMPLATE.md +0 -88
- package/.agent/skills/app-builder/templates/electron-desktop/TEMPLATE.md +0 -88
- package/.agent/skills/app-builder/templates/express-api/TEMPLATE.md +0 -83
- package/.agent/skills/app-builder/templates/flutter-app/TEMPLATE.md +0 -90
- package/.agent/skills/app-builder/templates/monorepo-turborepo/TEMPLATE.md +0 -90
- package/.agent/skills/app-builder/templates/nextjs-fullstack/TEMPLATE.md +0 -122
- package/.agent/skills/app-builder/templates/nextjs-saas/TEMPLATE.md +0 -122
- package/.agent/skills/app-builder/templates/nextjs-static/TEMPLATE.md +0 -169
- package/.agent/skills/app-builder/templates/nuxt-app/TEMPLATE.md +0 -134
- package/.agent/skills/app-builder/templates/python-fastapi/TEMPLATE.md +0 -83
- package/.agent/skills/app-builder/templates/react-native-app/TEMPLATE.md +0 -119
- package/.agent/skills/architecture/SKILL.md +0 -55
- package/.agent/skills/architecture/context-discovery.md +0 -43
- package/.agent/skills/architecture/examples.md +0 -94
- package/.agent/skills/architecture/pattern-selection.md +0 -68
- package/.agent/skills/architecture/patterns-reference.md +0 -50
- package/.agent/skills/architecture/trade-off-analysis.md +0 -77
- package/.agent/skills/clean-code/SKILL.md +0 -201
- package/.agent/skills/doc.md +0 -177
- package/.agent/skills/frontend-design/SKILL.md +0 -418
- package/.agent/skills/frontend-design/animation-guide.md +0 -331
- package/.agent/skills/frontend-design/color-system.md +0 -311
- package/.agent/skills/frontend-design/decision-trees.md +0 -418
- package/.agent/skills/frontend-design/motion-graphics.md +0 -306
- package/.agent/skills/frontend-design/scripts/accessibility_checker.py +0 -183
- package/.agent/skills/frontend-design/scripts/ux_audit.py +0 -722
- package/.agent/skills/frontend-design/typography-system.md +0 -345
- package/.agent/skills/frontend-design/ux-psychology.md +0 -1116
- package/.agent/skills/frontend-design/visual-effects.md +0 -383
- package/.agent/skills/i18n-localization/SKILL.md +0 -154
- package/.agent/skills/i18n-localization/scripts/i18n_checker.py +0 -241
- package/.agent/skills/mcp-builder/SKILL.md +0 -176
- package/.agent/skills/poster-design/SKILL.md +0 -385
- package/.agent/skills/web-design-guidelines/SKILL.md +0 -57
- package/.agent/workflows/brainstorm.md +0 -113
- package/.agent/workflows/create.md +0 -59
- package/.agent/workflows/debug.md +0 -103
- package/.agent/workflows/deploy.md +0 -176
- package/.agent/workflows/enhance.md +0 -63
- package/.agent/workflows/orchestrate.md +0 -237
- package/.agent/workflows/plan.md +0 -89
- package/.agent/workflows/preview.md +0 -81
- package/.agent/workflows/simple-test.md +0 -42
- package/.agent/workflows/status.md +0 -86
- package/.agent/workflows/structured-orchestrate.md +0 -180
- package/.agent/workflows/test.md +0 -144
- package/.agent/workflows/ui-ux-pro-max.md +0 -296
- package/outputs/emoji-font-showcase.png +0 -0
- package/outputs/foliko-muji-style.png +0 -0
- /package/.agent/plugins/{poster-plugin → marknative}/fonts/SegoeUI Emoji.ttf +0 -0
|
@@ -1,230 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* 装饰边框组件 - 多种风格
|
|
3
|
-
*/
|
|
4
|
-
|
|
5
|
-
const paper = require('paper')
|
|
6
|
-
|
|
7
|
-
/**
|
|
8
|
-
* 创建边框
|
|
9
|
-
*/
|
|
10
|
-
function createFrame(project, args) {
|
|
11
|
-
const {
|
|
12
|
-
x = 0,
|
|
13
|
-
y = 0,
|
|
14
|
-
width = 400,
|
|
15
|
-
height = 300,
|
|
16
|
-
style = 'simple', // simple, double, dashed, dotted, corner, vintage, modern, floral
|
|
17
|
-
color = '#000000',
|
|
18
|
-
borderWidth = 2,
|
|
19
|
-
radius = 0,
|
|
20
|
-
padding = 0,
|
|
21
|
-
opacity = 1,
|
|
22
|
-
} = args
|
|
23
|
-
|
|
24
|
-
const items = []
|
|
25
|
-
const effectiveX = x + padding
|
|
26
|
-
const effectiveY = y + padding
|
|
27
|
-
const effectiveWidth = width - padding * 2
|
|
28
|
-
const effectiveHeight = height - padding * 2
|
|
29
|
-
|
|
30
|
-
const strokeOpts = {
|
|
31
|
-
strokeColor: new paper.Color(color),
|
|
32
|
-
strokeWidth: borderWidth,
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
switch (style) {
|
|
36
|
-
case 'simple':
|
|
37
|
-
// 简单矩形
|
|
38
|
-
items.push(new paper.Path.Rectangle({
|
|
39
|
-
point: [effectiveX, effectiveY],
|
|
40
|
-
size: [effectiveWidth, effectiveHeight],
|
|
41
|
-
radius: radius,
|
|
42
|
-
...strokeOpts,
|
|
43
|
-
}))
|
|
44
|
-
break
|
|
45
|
-
|
|
46
|
-
case 'double':
|
|
47
|
-
// 双线边框
|
|
48
|
-
items.push(new paper.Path.Rectangle({
|
|
49
|
-
point: [effectiveX, effectiveY],
|
|
50
|
-
size: [effectiveWidth, effectiveHeight],
|
|
51
|
-
radius: radius,
|
|
52
|
-
...strokeOpts,
|
|
53
|
-
}))
|
|
54
|
-
items.push(new paper.Path.Rectangle({
|
|
55
|
-
point: [effectiveX + 8, effectiveY + 8],
|
|
56
|
-
size: [effectiveWidth - 16, effectiveHeight - 16],
|
|
57
|
-
radius: radius,
|
|
58
|
-
...strokeOpts,
|
|
59
|
-
}))
|
|
60
|
-
break
|
|
61
|
-
|
|
62
|
-
case 'dashed':
|
|
63
|
-
// 虚线边框
|
|
64
|
-
const dashed = new paper.Path.Rectangle({
|
|
65
|
-
point: [effectiveX, effectiveY],
|
|
66
|
-
size: [effectiveWidth, effectiveHeight],
|
|
67
|
-
radius: radius,
|
|
68
|
-
...strokeOpts,
|
|
69
|
-
})
|
|
70
|
-
dashed.dashArray = [10, 5]
|
|
71
|
-
items.push(dashed)
|
|
72
|
-
break
|
|
73
|
-
|
|
74
|
-
case 'dotted':
|
|
75
|
-
// 点线边框
|
|
76
|
-
const dotted = new paper.Path.Rectangle({
|
|
77
|
-
point: [effectiveX, effectiveY],
|
|
78
|
-
size: [effectiveWidth, effectiveHeight],
|
|
79
|
-
radius: radius,
|
|
80
|
-
strokeColor: new paper.Color(color),
|
|
81
|
-
strokeWidth: borderWidth,
|
|
82
|
-
dashArray: [2, 4],
|
|
83
|
-
})
|
|
84
|
-
items.push(dotted)
|
|
85
|
-
break
|
|
86
|
-
|
|
87
|
-
case 'corner':
|
|
88
|
-
// 四角装饰
|
|
89
|
-
const cornerSize = Math.min(30, effectiveWidth / 4, effectiveHeight / 4)
|
|
90
|
-
// 左上角
|
|
91
|
-
items.push(new paper.Path.Line(
|
|
92
|
-
[effectiveX, effectiveY + cornerSize],
|
|
93
|
-
[effectiveX, effectiveY],
|
|
94
|
-
{ ...strokeOpts }
|
|
95
|
-
))
|
|
96
|
-
items.push(new paper.Path.Line(
|
|
97
|
-
[effectiveX, effectiveY],
|
|
98
|
-
[effectiveX + cornerSize, effectiveY],
|
|
99
|
-
{ ...strokeOpts }
|
|
100
|
-
))
|
|
101
|
-
// 右上角
|
|
102
|
-
items.push(new paper.Path.Line(
|
|
103
|
-
[effectiveX + effectiveWidth - cornerSize, effectiveY],
|
|
104
|
-
[effectiveX + effectiveWidth, effectiveY],
|
|
105
|
-
{ ...strokeOpts }
|
|
106
|
-
))
|
|
107
|
-
items.push(new paper.Path.Line(
|
|
108
|
-
[effectiveX + effectiveWidth, effectiveY],
|
|
109
|
-
[effectiveX + effectiveWidth, effectiveY + cornerSize],
|
|
110
|
-
{ ...strokeOpts }
|
|
111
|
-
))
|
|
112
|
-
// 左下角
|
|
113
|
-
items.push(new paper.Path.Line(
|
|
114
|
-
[effectiveX, effectiveY + effectiveHeight - cornerSize],
|
|
115
|
-
[effectiveX, effectiveY + effectiveHeight],
|
|
116
|
-
{ ...strokeOpts }
|
|
117
|
-
))
|
|
118
|
-
items.push(new paper.Path.Line(
|
|
119
|
-
[effectiveX, effectiveY + effectiveHeight],
|
|
120
|
-
[effectiveX + cornerSize, effectiveY + effectiveHeight],
|
|
121
|
-
{ ...strokeOpts }
|
|
122
|
-
))
|
|
123
|
-
// 右下角
|
|
124
|
-
items.push(new paper.Path.Line(
|
|
125
|
-
[effectiveX + effectiveWidth - cornerSize, effectiveY + effectiveHeight],
|
|
126
|
-
[effectiveX + effectiveWidth, effectiveY + effectiveHeight],
|
|
127
|
-
{ ...strokeOpts }
|
|
128
|
-
))
|
|
129
|
-
items.push(new paper.Path.Line(
|
|
130
|
-
[effectiveX + effectiveWidth, effectiveY + effectiveHeight - cornerSize],
|
|
131
|
-
[effectiveX + effectiveWidth, effectiveY + effectiveHeight],
|
|
132
|
-
{ ...strokeOpts }
|
|
133
|
-
))
|
|
134
|
-
break
|
|
135
|
-
|
|
136
|
-
case 'vintage':
|
|
137
|
-
// 复古边框 - 双线+角装饰
|
|
138
|
-
const vintageOuter = new paper.Path.Rectangle({
|
|
139
|
-
point: [effectiveX, effectiveY],
|
|
140
|
-
size: [effectiveWidth, effectiveHeight],
|
|
141
|
-
...strokeOpts,
|
|
142
|
-
})
|
|
143
|
-
items.push(vintageOuter)
|
|
144
|
-
const vintageInner = new paper.Path.Rectangle({
|
|
145
|
-
point: [effectiveX + 6, effectiveY + 6],
|
|
146
|
-
size: [effectiveWidth - 12, effectiveHeight - 12],
|
|
147
|
-
...strokeOpts,
|
|
148
|
-
})
|
|
149
|
-
items.push(vintageInner)
|
|
150
|
-
// 四角小方块
|
|
151
|
-
const cornerBlockSize = 8
|
|
152
|
-
const corners = [
|
|
153
|
-
[effectiveX, effectiveY],
|
|
154
|
-
[effectiveX + effectiveWidth - cornerBlockSize, effectiveY],
|
|
155
|
-
[effectiveX, effectiveY + effectiveHeight - cornerBlockSize],
|
|
156
|
-
[effectiveX + effectiveWidth - cornerBlockSize, effectiveY + effectiveHeight - cornerBlockSize],
|
|
157
|
-
]
|
|
158
|
-
corners.forEach(([cx, cy]) => {
|
|
159
|
-
items.push(new paper.Path.Rectangle({
|
|
160
|
-
point: [cx, cy],
|
|
161
|
-
size: [cornerBlockSize, cornerBlockSize],
|
|
162
|
-
fillColor: new paper.Color(color),
|
|
163
|
-
}))
|
|
164
|
-
})
|
|
165
|
-
break
|
|
166
|
-
|
|
167
|
-
case 'modern':
|
|
168
|
-
// 现代边框 - 粗细交替
|
|
169
|
-
const modernPath = new paper.Path.Rectangle({
|
|
170
|
-
point: [effectiveX, effectiveY],
|
|
171
|
-
size: [effectiveWidth, effectiveHeight],
|
|
172
|
-
radius: radius,
|
|
173
|
-
...strokeOpts,
|
|
174
|
-
})
|
|
175
|
-
modernPath.dashArray = [20, 5, 5, 5]
|
|
176
|
-
items.push(modernPath)
|
|
177
|
-
break
|
|
178
|
-
|
|
179
|
-
case 'floral':
|
|
180
|
-
// 花纹边框 - 角装饰+边线
|
|
181
|
-
const floral = new paper.Path.Rectangle({
|
|
182
|
-
point: [effectiveX, effectiveY],
|
|
183
|
-
size: [effectiveWidth, effectiveHeight],
|
|
184
|
-
...strokeOpts,
|
|
185
|
-
})
|
|
186
|
-
items.push(floral)
|
|
187
|
-
// 四个角的花纹
|
|
188
|
-
const fCornerSize = Math.min(25, effectiveWidth / 6, effectiveHeight / 6)
|
|
189
|
-
const fCorners = [
|
|
190
|
-
{ x: effectiveX, y: effectiveY, rotation: 0 },
|
|
191
|
-
{ x: effectiveX + effectiveWidth - fCornerSize, y: effectiveY, rotation: 90 },
|
|
192
|
-
{ x: effectiveX, y: effectiveY + effectiveHeight - fCornerSize, rotation: 270 },
|
|
193
|
-
{ x: effectiveX + effectiveWidth - fCornerSize, y: effectiveY + effectiveHeight - fCornerSize, rotation: 180 },
|
|
194
|
-
]
|
|
195
|
-
fCorners.forEach(({ x: fx, y: fy, rotation }) => {
|
|
196
|
-
const ornament = new paper.Path()
|
|
197
|
-
ornament.add(new paper.Point(fx + fCornerSize / 2, fy + fCornerSize))
|
|
198
|
-
ornament.add(new paper.Point(fx + fCornerSize, fy + fCornerSize / 2))
|
|
199
|
-
ornament.add(new paper.Point(fx + fCornerSize, fy + fCornerSize))
|
|
200
|
-
ornament.strokeColor = new paper.Color(color)
|
|
201
|
-
ornament.strokeWidth = borderWidth
|
|
202
|
-
ornament.rotate(rotation, new paper.Point(fx + fCornerSize, fy + fCornerSize))
|
|
203
|
-
items.push(ornament)
|
|
204
|
-
})
|
|
205
|
-
break
|
|
206
|
-
|
|
207
|
-
default:
|
|
208
|
-
items.push(new paper.Path.Rectangle({
|
|
209
|
-
point: [effectiveX, effectiveY],
|
|
210
|
-
size: [effectiveWidth, effectiveHeight],
|
|
211
|
-
radius: radius,
|
|
212
|
-
...strokeOpts,
|
|
213
|
-
}))
|
|
214
|
-
}
|
|
215
|
-
|
|
216
|
-
// 应用透明度
|
|
217
|
-
if (opacity !== 1) {
|
|
218
|
-
items.forEach(item => {
|
|
219
|
-
item.opacity = opacity
|
|
220
|
-
})
|
|
221
|
-
}
|
|
222
|
-
|
|
223
|
-
return {
|
|
224
|
-
success: true,
|
|
225
|
-
type: 'frame',
|
|
226
|
-
items: items.map(i => i.id),
|
|
227
|
-
}
|
|
228
|
-
}
|
|
229
|
-
|
|
230
|
-
module.exports = createFrame
|
|
@@ -1,130 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* 网格布局组件
|
|
3
|
-
* 支持任意行列的网格布局
|
|
4
|
-
*/
|
|
5
|
-
|
|
6
|
-
const paper = require('paper')
|
|
7
|
-
|
|
8
|
-
/**
|
|
9
|
-
* 创建网格布局组件
|
|
10
|
-
*
|
|
11
|
-
* @param {Object} project - Paper.js 项目
|
|
12
|
-
* @param {Object} canvas - 画布对象
|
|
13
|
-
* @param {Object} params - 组件参数
|
|
14
|
-
* @param {number} params.x - 起始X坐标
|
|
15
|
-
* @param {number} params.y - 起始Y坐标
|
|
16
|
-
* @param {number} params.width - 总宽度
|
|
17
|
-
* @param {number} params.height - 总高度
|
|
18
|
-
* @param {number} [params.columns=3] - 列数
|
|
19
|
-
* @param {number} [params.rows=2] - 行数
|
|
20
|
-
* @param {number} [params.gapX=20] - 水平间距
|
|
21
|
-
* @param {number} [params.gapY=20] - 垂直间距
|
|
22
|
-
* @param {string} [params.background] - 背景色
|
|
23
|
-
* @param {string} [params.borderColor] - 边框颜色
|
|
24
|
-
* @param {number} [params.borderWidth] - 边框宽度
|
|
25
|
-
* @param {number} [params.radius=0] - 圆角
|
|
26
|
-
* @param {string} [params.direction='row'] - 排列方向: row(行优先), column(列优先)
|
|
27
|
-
*/
|
|
28
|
-
function createGrid(project, canvas, params) {
|
|
29
|
-
const {
|
|
30
|
-
x,
|
|
31
|
-
y,
|
|
32
|
-
width,
|
|
33
|
-
height,
|
|
34
|
-
columns = 3,
|
|
35
|
-
rows = 2,
|
|
36
|
-
gapX = 20,
|
|
37
|
-
gapY = 20,
|
|
38
|
-
background,
|
|
39
|
-
borderColor,
|
|
40
|
-
borderWidth = 1,
|
|
41
|
-
radius = 0,
|
|
42
|
-
direction = 'row'
|
|
43
|
-
} = params
|
|
44
|
-
|
|
45
|
-
const elements = []
|
|
46
|
-
|
|
47
|
-
// 计算单元格尺寸
|
|
48
|
-
const totalGapX = gapX * (columns - 1)
|
|
49
|
-
const totalGapY = gapY * (rows - 1)
|
|
50
|
-
const cellWidth = (width - totalGapX) / columns
|
|
51
|
-
const cellHeight = (height - totalGapY) / rows
|
|
52
|
-
|
|
53
|
-
// 绘制背景
|
|
54
|
-
if (background) {
|
|
55
|
-
const bg = new paper.Path.Rectangle({
|
|
56
|
-
point: [x, y],
|
|
57
|
-
size: [width, height],
|
|
58
|
-
radius: radius
|
|
59
|
-
})
|
|
60
|
-
bg.fillColor = new paper.Color(background)
|
|
61
|
-
if (project && project.activeLayer) {
|
|
62
|
-
project.activeLayer.addChild(bg)
|
|
63
|
-
}
|
|
64
|
-
elements.push({ type: 'rectangle', id: bg.id })
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
// 绘制边框
|
|
68
|
-
if (borderColor && borderWidth > 0) {
|
|
69
|
-
const border = new paper.Path.Rectangle({
|
|
70
|
-
point: [x, y],
|
|
71
|
-
size: [width, height],
|
|
72
|
-
radius: radius
|
|
73
|
-
})
|
|
74
|
-
border.fillColor = new paper.Color('transparent')
|
|
75
|
-
border.strokeColor = new paper.Color(borderColor)
|
|
76
|
-
border.strokeWidth = borderWidth
|
|
77
|
-
if (project && project.activeLayer) {
|
|
78
|
-
project.activeLayer.addChild(border)
|
|
79
|
-
}
|
|
80
|
-
elements.push({ type: 'rectangle', id: border.id })
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
// 生成网格位置信息
|
|
84
|
-
const cellPositions = []
|
|
85
|
-
const totalCells = columns * rows
|
|
86
|
-
|
|
87
|
-
for (let i = 0; i < totalCells; i++) {
|
|
88
|
-
let col, row
|
|
89
|
-
|
|
90
|
-
if (direction === 'row') {
|
|
91
|
-
col = i % columns
|
|
92
|
-
row = Math.floor(i / columns)
|
|
93
|
-
} else {
|
|
94
|
-
row = i % rows
|
|
95
|
-
col = Math.floor(i / rows)
|
|
96
|
-
}
|
|
97
|
-
|
|
98
|
-
const cellX = x + col * (cellWidth + gapX)
|
|
99
|
-
const cellY = y + row * (cellHeight + gapY)
|
|
100
|
-
|
|
101
|
-
cellPositions.push({
|
|
102
|
-
index: i,
|
|
103
|
-
column: col,
|
|
104
|
-
row: row,
|
|
105
|
-
x: cellX,
|
|
106
|
-
y: cellY,
|
|
107
|
-
width: cellWidth,
|
|
108
|
-
height: cellHeight,
|
|
109
|
-
centerX: cellX + cellWidth / 2,
|
|
110
|
-
centerY: cellY + cellHeight / 2
|
|
111
|
-
})
|
|
112
|
-
}
|
|
113
|
-
|
|
114
|
-
// 返回网格布局信息
|
|
115
|
-
return {
|
|
116
|
-
success: true,
|
|
117
|
-
elements,
|
|
118
|
-
cellPositions,
|
|
119
|
-
cellWidth,
|
|
120
|
-
cellHeight,
|
|
121
|
-
columns,
|
|
122
|
-
rows,
|
|
123
|
-
totalCells,
|
|
124
|
-
totalWidth: width,
|
|
125
|
-
totalHeight: height,
|
|
126
|
-
type: 'grid'
|
|
127
|
-
}
|
|
128
|
-
}
|
|
129
|
-
|
|
130
|
-
module.exports = createGrid
|
|
@@ -1,145 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* 高亮文字组件 - 荧光笔效果
|
|
3
|
-
*/
|
|
4
|
-
|
|
5
|
-
const paper = require('paper')
|
|
6
|
-
const { getFontFallbackChain, validateFont } = require('../fonts')
|
|
7
|
-
|
|
8
|
-
/**
|
|
9
|
-
* 创建高亮文字
|
|
10
|
-
*/
|
|
11
|
-
function createHighlightText(project, args) {
|
|
12
|
-
const {
|
|
13
|
-
x = 0,
|
|
14
|
-
y = 0,
|
|
15
|
-
text = '',
|
|
16
|
-
fontSize = 48,
|
|
17
|
-
fontFamily,
|
|
18
|
-
color = '#000000',
|
|
19
|
-
highlightColor = '#ffff00',
|
|
20
|
-
highlightStyle = 'marker', // marker, underline, background, stroke
|
|
21
|
-
highlightWidth = 20,
|
|
22
|
-
strokeWidth = 2,
|
|
23
|
-
shadow,
|
|
24
|
-
opacity = 1,
|
|
25
|
-
} = args
|
|
26
|
-
|
|
27
|
-
const items = []
|
|
28
|
-
|
|
29
|
-
// 创建文字以获取尺寸
|
|
30
|
-
const textItem = new paper.PointText({
|
|
31
|
-
point: [x, y + fontSize],
|
|
32
|
-
content: text,
|
|
33
|
-
fontSize,
|
|
34
|
-
fontFamily: getFontFallbackChain(fontFamily, text).join(', '),
|
|
35
|
-
fillColor: new paper.Color(color),
|
|
36
|
-
justification: 'left',
|
|
37
|
-
})
|
|
38
|
-
|
|
39
|
-
const textBounds = textItem.bounds
|
|
40
|
-
|
|
41
|
-
// 根据样式添加高亮
|
|
42
|
-
switch (highlightStyle) {
|
|
43
|
-
case 'marker':
|
|
44
|
-
// 荧光笔效果 - 倾斜的矩形
|
|
45
|
-
const markerHeight = fontSize * 0.8
|
|
46
|
-
const marker = new paper.Path.Rectangle({
|
|
47
|
-
point: [textBounds.x - 5, textBounds.y + fontSize * 0.3],
|
|
48
|
-
size: [textBounds.width + 10, markerHeight],
|
|
49
|
-
})
|
|
50
|
-
marker.fillColor = new paper.Color(highlightColor)
|
|
51
|
-
marker.opacity = 0.5
|
|
52
|
-
marker.rotate(-5, marker.bounds.center)
|
|
53
|
-
if (shadow) {
|
|
54
|
-
marker.shadowColor = new paper.Color(shadow.color || '#000000')
|
|
55
|
-
marker.shadowBlur = shadow.blur || 5
|
|
56
|
-
marker.shadowOffset = new paper.Point(shadow.offsetX || 2, shadow.offsetY || 2)
|
|
57
|
-
}
|
|
58
|
-
if (opacity !== 1) marker.opacity *= opacity
|
|
59
|
-
items.push(marker)
|
|
60
|
-
break
|
|
61
|
-
|
|
62
|
-
case 'underline':
|
|
63
|
-
// 下划线
|
|
64
|
-
const underlineY = textBounds.y + fontSize + 5
|
|
65
|
-
const underline = new paper.Path.Line(
|
|
66
|
-
[textBounds.x, underlineY],
|
|
67
|
-
[textBounds.x + textBounds.width, underlineY]
|
|
68
|
-
)
|
|
69
|
-
underline.strokeColor = new paper.Color(highlightColor)
|
|
70
|
-
underline.strokeWidth = highlightWidth
|
|
71
|
-
underline.strokeCap = 'round'
|
|
72
|
-
if (shadow) {
|
|
73
|
-
underline.shadowColor = new paper.Color(shadow.color || '#000000')
|
|
74
|
-
underline.shadowBlur = shadow.blur || 5
|
|
75
|
-
underline.shadowOffset = new paper.Point(shadow.offsetX || 2, shadow.offsetY || 2)
|
|
76
|
-
}
|
|
77
|
-
if (opacity !== 1) underline.opacity = opacity
|
|
78
|
-
items.push(underline)
|
|
79
|
-
break
|
|
80
|
-
|
|
81
|
-
case 'background':
|
|
82
|
-
// 背景色块
|
|
83
|
-
const padding = 8
|
|
84
|
-
const bg = new paper.Path.Rectangle({
|
|
85
|
-
point: [textBounds.x - padding, textBounds.y - 5],
|
|
86
|
-
size: [textBounds.width + padding * 2, fontSize + 10],
|
|
87
|
-
radius: 4,
|
|
88
|
-
})
|
|
89
|
-
bg.fillColor = new paper.Color(highlightColor)
|
|
90
|
-
bg.opacity = 0.6
|
|
91
|
-
if (shadow) {
|
|
92
|
-
bg.shadowColor = new paper.Color(shadow.color || '#000000')
|
|
93
|
-
bg.shadowBlur = shadow.blur || 5
|
|
94
|
-
bg.shadowOffset = new paper.Point(shadow.offsetX || 2, shadow.offsetY || 2)
|
|
95
|
-
}
|
|
96
|
-
if (opacity !== 1) bg.opacity *= opacity
|
|
97
|
-
items.push(bg)
|
|
98
|
-
break
|
|
99
|
-
|
|
100
|
-
case 'stroke':
|
|
101
|
-
// 描边效果
|
|
102
|
-
textItem.strokeColor = new paper.Color(highlightColor)
|
|
103
|
-
textItem.strokeWidth = strokeWidth
|
|
104
|
-
if (shadow) {
|
|
105
|
-
textItem.shadowColor = new paper.Color(shadow.color || '#000000')
|
|
106
|
-
textItem.shadowBlur = shadow.blur || 5
|
|
107
|
-
textItem.shadowOffset = new paper.Point(shadow.offsetX || 2, shadow.offsetY || 2)
|
|
108
|
-
}
|
|
109
|
-
if (opacity !== 1) textItem.opacity = opacity
|
|
110
|
-
items.push(textItem)
|
|
111
|
-
break
|
|
112
|
-
|
|
113
|
-
case 'neon':
|
|
114
|
-
// 霓虹效果
|
|
115
|
-
textItem.strokeColor = new paper.Color(highlightColor)
|
|
116
|
-
textItem.strokeWidth = strokeWidth * 2
|
|
117
|
-
const neonClone = textItem.clone()
|
|
118
|
-
neonClone.strokeWidth = strokeWidth * 4
|
|
119
|
-
neonClone.strokeColor = new paper.Color(highlightColor)
|
|
120
|
-
neonClone.fillColor = null
|
|
121
|
-
neonClone.opacity = 0.3
|
|
122
|
-
if (opacity !== 1) {
|
|
123
|
-
textItem.opacity = opacity
|
|
124
|
-
neonClone.opacity *= opacity
|
|
125
|
-
}
|
|
126
|
-
items.push(neonClone)
|
|
127
|
-
items.push(textItem)
|
|
128
|
-
break
|
|
129
|
-
}
|
|
130
|
-
|
|
131
|
-
// 如果不是 stroke 样式,需要重新添加文字
|
|
132
|
-
if (highlightStyle !== 'stroke' && highlightStyle !== 'neon') {
|
|
133
|
-
if (opacity !== 1) textItem.opacity = opacity
|
|
134
|
-
items.push(textItem)
|
|
135
|
-
}
|
|
136
|
-
|
|
137
|
-
return {
|
|
138
|
-
success: true,
|
|
139
|
-
type: 'highlightText',
|
|
140
|
-
items: items.map(i => i.id),
|
|
141
|
-
bounds: textBounds,
|
|
142
|
-
}
|
|
143
|
-
}
|
|
144
|
-
|
|
145
|
-
module.exports = createHighlightText
|
|
@@ -1,94 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* 图标组件 - 支持 emoji、图片图标
|
|
3
|
-
*/
|
|
4
|
-
|
|
5
|
-
const paper = require('paper')
|
|
6
|
-
const { loadImageAsRaster } = require('../utils/imageLoader')
|
|
7
|
-
|
|
8
|
-
/**
|
|
9
|
-
* 创建图标
|
|
10
|
-
*/
|
|
11
|
-
async function createIcon(project, args) {
|
|
12
|
-
const {
|
|
13
|
-
x = 0,
|
|
14
|
-
y = 0,
|
|
15
|
-
size = 64,
|
|
16
|
-
icon, // emoji 或 图片URL
|
|
17
|
-
color,
|
|
18
|
-
backgroundColor,
|
|
19
|
-
borderColor,
|
|
20
|
-
borderWidth = 0,
|
|
21
|
-
radius = 0,
|
|
22
|
-
shadow,
|
|
23
|
-
opacity = 1,
|
|
24
|
-
} = args
|
|
25
|
-
|
|
26
|
-
const items = []
|
|
27
|
-
|
|
28
|
-
// 背景
|
|
29
|
-
if (backgroundColor || borderColor) {
|
|
30
|
-
const bg = new paper.Path.Rectangle({
|
|
31
|
-
point: [x, y],
|
|
32
|
-
size: [size, size],
|
|
33
|
-
radius: radius,
|
|
34
|
-
})
|
|
35
|
-
|
|
36
|
-
if (backgroundColor) {
|
|
37
|
-
bg.fillColor = new paper.Color(backgroundColor)
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
if (borderColor) {
|
|
41
|
-
bg.strokeColor = new paper.Color(borderColor)
|
|
42
|
-
bg.strokeWidth = borderWidth
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
if (shadow) {
|
|
46
|
-
bg.shadowColor = new paper.Color(shadow.color || '#000000')
|
|
47
|
-
bg.shadowBlur = shadow.blur || 5
|
|
48
|
-
bg.shadowOffset = new paper.Point(shadow.offsetX || 2, shadow.offsetY || 2)
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
if (opacity !== 1) {
|
|
52
|
-
bg.opacity = opacity
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
items.push(bg)
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
// 图标内容
|
|
59
|
-
if (icon) {
|
|
60
|
-
// 判断是否为图片路径(本地文件、http、data URL)
|
|
61
|
-
const isImagePath = icon.startsWith('http') || icon.startsWith('data:') ||
|
|
62
|
-
(icon.match(/\.(png|jpg|jpeg|gif|svg|webp|bmp)$/i) && !icon.match(/[\u4e00-\u9fa5]/))
|
|
63
|
-
|
|
64
|
-
if (isImagePath) {
|
|
65
|
-
// 图片图标 - 使用 imageLoader
|
|
66
|
-
const padding = backgroundColor ? 8 : 0
|
|
67
|
-
const iconSize = size - padding * 2
|
|
68
|
-
const { raster } = await loadImageAsRaster(project, icon, { x: x + padding, y: y + padding, width: iconSize, height: iconSize }, opacity)
|
|
69
|
-
items.push(raster)
|
|
70
|
-
} else {
|
|
71
|
-
// Emoji 或文字图标
|
|
72
|
-
const fontSize = Math.min(size * 0.6, 64)
|
|
73
|
-
const textItem = new paper.PointText({
|
|
74
|
-
point: [x + size / 2, y + size / 2 + fontSize / 3],
|
|
75
|
-
content: icon,
|
|
76
|
-
fontSize,
|
|
77
|
-
justification: 'center',
|
|
78
|
-
})
|
|
79
|
-
if (color) {
|
|
80
|
-
textItem.fillColor = new paper.Color(color)
|
|
81
|
-
}
|
|
82
|
-
if (opacity !== 1) textItem.opacity = opacity
|
|
83
|
-
items.push(textItem)
|
|
84
|
-
}
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
return {
|
|
88
|
-
success: true,
|
|
89
|
-
type: 'icon',
|
|
90
|
-
items: items.map(i => i.id),
|
|
91
|
-
}
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
module.exports = createIcon
|