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,205 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* 图片框组件 - 带装饰边框的图片
|
|
3
|
-
* 使用 Paper.js API 实现
|
|
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
|
-
*/
|
|
15
|
-
function createImageFrame(project, canvas, params) {
|
|
16
|
-
const {
|
|
17
|
-
src,
|
|
18
|
-
x,
|
|
19
|
-
y,
|
|
20
|
-
width,
|
|
21
|
-
height,
|
|
22
|
-
borderColor = '#ffffff',
|
|
23
|
-
borderWidth = 3,
|
|
24
|
-
outerColor = '#1a1a2e',
|
|
25
|
-
outerWidth = 6,
|
|
26
|
-
shadowBlur = 0,
|
|
27
|
-
shadowOffsetX = 0,
|
|
28
|
-
shadowOffsetY = 0,
|
|
29
|
-
shadowColor = 'rgba(0,0,0,0.3)',
|
|
30
|
-
radius = 0,
|
|
31
|
-
overlayColor,
|
|
32
|
-
overlayOpacity = 0,
|
|
33
|
-
fit = 'cover'
|
|
34
|
-
} = params
|
|
35
|
-
|
|
36
|
-
const elements = []
|
|
37
|
-
|
|
38
|
-
// 辅助函数:创建圆角矩形路径
|
|
39
|
-
function createRoundedRectPath(x, y, w, h, r) {
|
|
40
|
-
const rect = new paper.Path.Rectangle({
|
|
41
|
-
point: [x, y],
|
|
42
|
-
size: [w, h],
|
|
43
|
-
radius: r
|
|
44
|
-
})
|
|
45
|
-
return rect
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
// 绘制阴影
|
|
49
|
-
if (shadowBlur > 0) {
|
|
50
|
-
// 使用 Paper.js 的 shadow 功能
|
|
51
|
-
// 注意:Paper.js 对阴影支持有限,这里使用简单实现
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
// 绘制外边框(装饰层)
|
|
55
|
-
if (outerWidth > 0) {
|
|
56
|
-
const outerRect = createRoundedRectPath(
|
|
57
|
-
x - outerWidth,
|
|
58
|
-
y - outerWidth,
|
|
59
|
-
width + outerWidth * 2,
|
|
60
|
-
height + outerWidth * 2,
|
|
61
|
-
radius + outerWidth
|
|
62
|
-
)
|
|
63
|
-
outerRect.fillColor = new paper.Color(outerColor)
|
|
64
|
-
if (project && project.activeLayer) {
|
|
65
|
-
project.activeLayer.addChild(outerRect)
|
|
66
|
-
}
|
|
67
|
-
elements.push({ type: 'path', id: outerRect.id })
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
// 绘制内边框
|
|
71
|
-
if (borderWidth > 0) {
|
|
72
|
-
const borderRect = createRoundedRectPath(
|
|
73
|
-
x - borderWidth,
|
|
74
|
-
y - borderWidth,
|
|
75
|
-
width + borderWidth * 2,
|
|
76
|
-
height + borderWidth * 2,
|
|
77
|
-
radius + borderWidth
|
|
78
|
-
)
|
|
79
|
-
borderRect.fillColor = new paper.Color(borderColor)
|
|
80
|
-
if (project && project.activeLayer) {
|
|
81
|
-
project.activeLayer.addChild(borderRect)
|
|
82
|
-
}
|
|
83
|
-
elements.push({ type: 'path', id: borderRect.id })
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
// 创建图片容器(裁剪区域)
|
|
87
|
-
const clipRect = createRoundedRectPath(x, y, width, height, radius)
|
|
88
|
-
|
|
89
|
-
// 创建裁剪组
|
|
90
|
-
const clipGroup = new paper.Group()
|
|
91
|
-
clipGroup.addChild(clipRect)
|
|
92
|
-
|
|
93
|
-
if (project && project.activeLayer) {
|
|
94
|
-
project.activeLayer.addChild(clipGroup)
|
|
95
|
-
}
|
|
96
|
-
elements.push({ type: 'group', id: clipGroup.id })
|
|
97
|
-
|
|
98
|
-
// 加载并添加图片
|
|
99
|
-
loadImageAsync(src).then((loadedRaster) => {
|
|
100
|
-
if (!loadedRaster) return
|
|
101
|
-
|
|
102
|
-
// loadedRaster 已经是 Raster 对象
|
|
103
|
-
const imgWidth = loadedRaster.width
|
|
104
|
-
const imgHeight = loadedRaster.height
|
|
105
|
-
const imgRatio = imgWidth / imgHeight
|
|
106
|
-
const boxRatio = width / height
|
|
107
|
-
|
|
108
|
-
let drawX = x, drawY = y, drawW = width, drawH = height
|
|
109
|
-
|
|
110
|
-
if (fit === 'cover') {
|
|
111
|
-
if (imgRatio > boxRatio) {
|
|
112
|
-
drawH = height
|
|
113
|
-
drawW = height * imgRatio
|
|
114
|
-
drawX = x - (drawW - width) / 2
|
|
115
|
-
} else {
|
|
116
|
-
drawW = width
|
|
117
|
-
drawH = width / imgRatio
|
|
118
|
-
drawY = y - (drawH - height) / 2
|
|
119
|
-
}
|
|
120
|
-
} else if (fit === 'contain') {
|
|
121
|
-
if (imgRatio > boxRatio) {
|
|
122
|
-
drawW = width
|
|
123
|
-
drawH = width / imgRatio
|
|
124
|
-
drawY = y + (height - drawH) / 2
|
|
125
|
-
} else {
|
|
126
|
-
drawH = height
|
|
127
|
-
drawW = height * imgRatio
|
|
128
|
-
drawX = x + (width - drawW) / 2
|
|
129
|
-
}
|
|
130
|
-
}
|
|
131
|
-
|
|
132
|
-
loadedRaster.bounds = new paper.Rectangle(drawX, drawY, drawW, drawH)
|
|
133
|
-
|
|
134
|
-
// 应用裁剪
|
|
135
|
-
loadedRaster.clipped = true
|
|
136
|
-
loadedRaster.clipMask = clipRect
|
|
137
|
-
|
|
138
|
-
if (project && project.activeLayer) {
|
|
139
|
-
// 将图片添加到裁剪组
|
|
140
|
-
clipGroup.addChild(loadedRaster)
|
|
141
|
-
}
|
|
142
|
-
})
|
|
143
|
-
|
|
144
|
-
// 叠加颜色
|
|
145
|
-
if (overlayColor && overlayOpacity > 0) {
|
|
146
|
-
const overlayRect = createRoundedRectPath(x, y, width, height, radius)
|
|
147
|
-
overlayRect.fillColor = new paper.Color(overlayColor)
|
|
148
|
-
overlayRect.fillColor.alpha = overlayOpacity
|
|
149
|
-
if (project && project.activeLayer) {
|
|
150
|
-
project.activeLayer.addChild(overlayRect)
|
|
151
|
-
}
|
|
152
|
-
elements.push({ type: 'path', id: overlayRect.id })
|
|
153
|
-
}
|
|
154
|
-
|
|
155
|
-
return {
|
|
156
|
-
success: true,
|
|
157
|
-
elements,
|
|
158
|
-
width: width,
|
|
159
|
-
height: height,
|
|
160
|
-
type: 'imageFrame'
|
|
161
|
-
}
|
|
162
|
-
}
|
|
163
|
-
|
|
164
|
-
// 异步加载图片
|
|
165
|
-
function loadImageAsync(src) {
|
|
166
|
-
return new Promise((resolve) => {
|
|
167
|
-
try {
|
|
168
|
-
// 尝试作为 URL 加载
|
|
169
|
-
const raster = new paper.Raster(src)
|
|
170
|
-
|
|
171
|
-
raster.onLoad = () => {
|
|
172
|
-
// Paper.js Raster 本身就可以使用,不需要 .image
|
|
173
|
-
resolve(raster)
|
|
174
|
-
}
|
|
175
|
-
|
|
176
|
-
raster.onError = () => {
|
|
177
|
-
// 尝试作为本地文件
|
|
178
|
-
const fs = require('fs')
|
|
179
|
-
const path = require('path')
|
|
180
|
-
|
|
181
|
-
if (fs.existsSync(src)) {
|
|
182
|
-
const data = fs.readFileSync(src)
|
|
183
|
-
const base64 = data.toString('base64')
|
|
184
|
-
const ext = path.extname(src).slice(1).toLowerCase()
|
|
185
|
-
const mimeType = ext === 'jpg' ? 'jpeg' : ext
|
|
186
|
-
const dataUrl = `data:image/${mimeType};base64,${base64}`
|
|
187
|
-
|
|
188
|
-
const raster2 = new paper.Raster(dataUrl)
|
|
189
|
-
raster2.onLoad = () => {
|
|
190
|
-
resolve(raster2)
|
|
191
|
-
}
|
|
192
|
-
raster2.onError = () => {
|
|
193
|
-
resolve(null)
|
|
194
|
-
}
|
|
195
|
-
} else {
|
|
196
|
-
resolve(null)
|
|
197
|
-
}
|
|
198
|
-
}
|
|
199
|
-
} catch (e) {
|
|
200
|
-
resolve(null)
|
|
201
|
-
}
|
|
202
|
-
})
|
|
203
|
-
}
|
|
204
|
-
|
|
205
|
-
module.exports = createImageFrame
|
|
@@ -1,81 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* 高级组件模块导出
|
|
3
|
-
*/
|
|
4
|
-
|
|
5
|
-
const createCard = require('./card')
|
|
6
|
-
const createBadge = require('./badge')
|
|
7
|
-
const createCTA = require('./cta')
|
|
8
|
-
const createFeature = require('./feature')
|
|
9
|
-
const createFeatureGrid = require('./featureGrid')
|
|
10
|
-
const createDivider = require('./divider')
|
|
11
|
-
const createAvatar = require('./avatar')
|
|
12
|
-
const createProgress = require('./progress')
|
|
13
|
-
const createRating = require('./rating')
|
|
14
|
-
const createQuote = require('./quote')
|
|
15
|
-
const createStatCard = require('./statCard')
|
|
16
|
-
const createTagCloud = require('./tagCloud')
|
|
17
|
-
const createStepper = require('./stepper')
|
|
18
|
-
const createTimeline = require('./timeline')
|
|
19
|
-
const { createListItem, createList } = require('./listItem')
|
|
20
|
-
const createNotification = require('./notification')
|
|
21
|
-
const createImageFrame = require('./imageFrame')
|
|
22
|
-
const createColumns = require('./columns')
|
|
23
|
-
const createGrid = require('./grid')
|
|
24
|
-
const createStar = require('./star')
|
|
25
|
-
const createArrow = require('./arrow')
|
|
26
|
-
const createProgressCircle = require('./progressCircle')
|
|
27
|
-
const createChip = require('./chip')
|
|
28
|
-
const createChart = require('./chart')
|
|
29
|
-
const createWatermark = require('./watermark')
|
|
30
|
-
const createTable = require('./table')
|
|
31
|
-
const createButton = require('./button')
|
|
32
|
-
const createIcon = require('./icon')
|
|
33
|
-
const createQRCode = require('./qrcode')
|
|
34
|
-
const createFrame = require('./frame')
|
|
35
|
-
const createBubble = require('./bubble')
|
|
36
|
-
const createRibbon = require('./ribbon')
|
|
37
|
-
const createSeal = require('./seal')
|
|
38
|
-
const createHighlightText = require('./highlightText')
|
|
39
|
-
const createBarcode = require('./barcode')
|
|
40
|
-
|
|
41
|
-
module.exports = {
|
|
42
|
-
// 原有组件
|
|
43
|
-
createCard,
|
|
44
|
-
createBadge,
|
|
45
|
-
createCTA,
|
|
46
|
-
createFeature,
|
|
47
|
-
createFeatureGrid,
|
|
48
|
-
createDivider,
|
|
49
|
-
createAvatar,
|
|
50
|
-
createProgress,
|
|
51
|
-
createRating,
|
|
52
|
-
createQuote,
|
|
53
|
-
createStatCard,
|
|
54
|
-
createTagCloud,
|
|
55
|
-
createStepper,
|
|
56
|
-
createTimeline,
|
|
57
|
-
createListItem,
|
|
58
|
-
createList,
|
|
59
|
-
createNotification,
|
|
60
|
-
createImageFrame,
|
|
61
|
-
createColumns,
|
|
62
|
-
createGrid,
|
|
63
|
-
// 新增组件
|
|
64
|
-
createStar,
|
|
65
|
-
createArrow,
|
|
66
|
-
createProgressCircle,
|
|
67
|
-
createChip,
|
|
68
|
-
createChart,
|
|
69
|
-
createWatermark,
|
|
70
|
-
createTable,
|
|
71
|
-
// 新增设计组件
|
|
72
|
-
createButton,
|
|
73
|
-
createIcon,
|
|
74
|
-
createQRCode,
|
|
75
|
-
createFrame,
|
|
76
|
-
createBubble,
|
|
77
|
-
createRibbon,
|
|
78
|
-
createSeal,
|
|
79
|
-
createHighlightText,
|
|
80
|
-
createBarcode,
|
|
81
|
-
}
|
|
@@ -1,147 +0,0 @@
|
|
|
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.width - 宽度
|
|
16
|
-
* @param {string} args.icon - 图标
|
|
17
|
-
* @param {string} args.title - 标题
|
|
18
|
-
* @param {string} args.description - 描述
|
|
19
|
-
* @param {string} args.badge - 徽章文字
|
|
20
|
-
* @param {string} args.badgeColor - 徽章颜色
|
|
21
|
-
* @param {string} args.iconColor - 图标颜色
|
|
22
|
-
* @param {string} args.background - 背景色
|
|
23
|
-
* @param {string} args.borderColor - 边框颜色
|
|
24
|
-
* @param {number} args.height - 高度
|
|
25
|
-
* @param {number} args.radius - 圆角半径
|
|
26
|
-
*/
|
|
27
|
-
function createListItem(project, canvas, args) {
|
|
28
|
-
const {
|
|
29
|
-
x = 0,
|
|
30
|
-
y = 0,
|
|
31
|
-
width = 400,
|
|
32
|
-
icon = '→',
|
|
33
|
-
title,
|
|
34
|
-
description,
|
|
35
|
-
badge,
|
|
36
|
-
badgeColor = '#6366f1',
|
|
37
|
-
iconColor = '#6366f1',
|
|
38
|
-
background = '#ffffff',
|
|
39
|
-
borderColor = '#e5e7eb',
|
|
40
|
-
height = 60,
|
|
41
|
-
radius = 8,
|
|
42
|
-
} = args
|
|
43
|
-
|
|
44
|
-
const elements = []
|
|
45
|
-
|
|
46
|
-
// 绘制背景
|
|
47
|
-
const bg = new paper.Path.Rectangle({
|
|
48
|
-
point: [x, y],
|
|
49
|
-
size: [width, height],
|
|
50
|
-
radius: radius,
|
|
51
|
-
})
|
|
52
|
-
bg.fillColor = new paper.Color(background)
|
|
53
|
-
bg.strokeColor = new paper.Color(borderColor)
|
|
54
|
-
bg.strokeWidth = 1
|
|
55
|
-
elements.push({ type: 'rectangle', id: bg.id })
|
|
56
|
-
|
|
57
|
-
// 绘制图标
|
|
58
|
-
const iconText = new paper.PointText({
|
|
59
|
-
point: [x + 15, y + height / 2 + 6],
|
|
60
|
-
content: icon,
|
|
61
|
-
fontSize: 20,
|
|
62
|
-
fillColor: new paper.Color(iconColor),
|
|
63
|
-
justification: 'center',
|
|
64
|
-
})
|
|
65
|
-
elements.push({ type: 'text', id: iconText.id })
|
|
66
|
-
|
|
67
|
-
// 绘制标题
|
|
68
|
-
const titleText = new paper.PointText({
|
|
69
|
-
point: [x + 50, y + height / 2 - 5],
|
|
70
|
-
content: title || 'List Item',
|
|
71
|
-
fontSize: 16,
|
|
72
|
-
fillColor: new paper.Color('#1e293b'),
|
|
73
|
-
justification: 'left',
|
|
74
|
-
})
|
|
75
|
-
elements.push({ type: 'text', id: titleText.id })
|
|
76
|
-
|
|
77
|
-
// 绘制描述
|
|
78
|
-
if (description) {
|
|
79
|
-
const descText = new paper.PointText({
|
|
80
|
-
point: [x + 50, y + height / 2 + 15],
|
|
81
|
-
content: description,
|
|
82
|
-
fontSize: 12,
|
|
83
|
-
fillColor: new paper.Color('#64748b'),
|
|
84
|
-
justification: 'left',
|
|
85
|
-
})
|
|
86
|
-
elements.push({ type: 'text', id: descText.id })
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
// 绘制徽章
|
|
90
|
-
if (badge) {
|
|
91
|
-
const badgeWidth = badge.length * 10 + 20
|
|
92
|
-
const badgeX = x + width - badgeWidth - 15
|
|
93
|
-
const badgeY = y + (height - 24) / 2
|
|
94
|
-
|
|
95
|
-
const badgeBg = new paper.Path.Rectangle({
|
|
96
|
-
point: [badgeX, badgeY],
|
|
97
|
-
size: [badgeWidth, 24],
|
|
98
|
-
radius: 12,
|
|
99
|
-
})
|
|
100
|
-
badgeBg.fillColor = new paper.Color(badgeColor)
|
|
101
|
-
elements.push({ type: 'rectangle', id: badgeBg.id })
|
|
102
|
-
|
|
103
|
-
const badgeText = new paper.PointText({
|
|
104
|
-
point: [badgeX + badgeWidth / 2, badgeY + 16],
|
|
105
|
-
content: badge,
|
|
106
|
-
fontSize: 12,
|
|
107
|
-
fillColor: new paper.Color('#ffffff'),
|
|
108
|
-
justification: 'center',
|
|
109
|
-
})
|
|
110
|
-
elements.push({ type: 'text', id: badgeText.id })
|
|
111
|
-
}
|
|
112
|
-
|
|
113
|
-
return { success: true, elements, type: 'listItem' }
|
|
114
|
-
}
|
|
115
|
-
|
|
116
|
-
/**
|
|
117
|
-
* 创建列表(多个列表项)
|
|
118
|
-
*/
|
|
119
|
-
function createList(project, canvas, args) {
|
|
120
|
-
const {
|
|
121
|
-
x = 0, y = 0,
|
|
122
|
-
items = [],
|
|
123
|
-
gap = 10,
|
|
124
|
-
width = 400,
|
|
125
|
-
...rest
|
|
126
|
-
} = args
|
|
127
|
-
|
|
128
|
-
const elements = []
|
|
129
|
-
let currentY = y
|
|
130
|
-
|
|
131
|
-
for (const item of items) {
|
|
132
|
-
const result = createListItem(project, canvas, {
|
|
133
|
-
x, y: currentY, width, ...item, ...rest,
|
|
134
|
-
})
|
|
135
|
-
elements.push(...result.elements)
|
|
136
|
-
currentY += 60 + gap
|
|
137
|
-
}
|
|
138
|
-
|
|
139
|
-
return {
|
|
140
|
-
success: true,
|
|
141
|
-
elements,
|
|
142
|
-
height: currentY - y,
|
|
143
|
-
type: 'list',
|
|
144
|
-
}
|
|
145
|
-
}
|
|
146
|
-
|
|
147
|
-
module.exports = { createListItem, createList }
|
|
@@ -1,123 +0,0 @@
|
|
|
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.width - 宽度
|
|
16
|
-
* @param {string} args.type - 类型: success, warning, error, info
|
|
17
|
-
* @param {string} args.title - 标题
|
|
18
|
-
* @param {string} args.message - 消息内容
|
|
19
|
-
* @param {boolean} args.showIcon - 是否显示图标
|
|
20
|
-
* @param {number} args.radius - 圆角半径
|
|
21
|
-
*/
|
|
22
|
-
function createNotification(project, canvas, args) {
|
|
23
|
-
const {
|
|
24
|
-
x, y,
|
|
25
|
-
width = 360,
|
|
26
|
-
type = 'info',
|
|
27
|
-
title,
|
|
28
|
-
message,
|
|
29
|
-
showIcon = true,
|
|
30
|
-
radius = 12,
|
|
31
|
-
} = args
|
|
32
|
-
|
|
33
|
-
// 类型配置
|
|
34
|
-
const config = {
|
|
35
|
-
success: {
|
|
36
|
-
icon: '✓',
|
|
37
|
-
bgColor: '#dcfce7',
|
|
38
|
-
iconColor: '#22c55e',
|
|
39
|
-
borderColor: '#22c55e',
|
|
40
|
-
},
|
|
41
|
-
warning: {
|
|
42
|
-
icon: '⚠',
|
|
43
|
-
bgColor: '#fef9c3',
|
|
44
|
-
iconColor: '#eab308',
|
|
45
|
-
borderColor: '#eab308',
|
|
46
|
-
},
|
|
47
|
-
error: {
|
|
48
|
-
icon: '✕',
|
|
49
|
-
bgColor: '#fee2e2',
|
|
50
|
-
iconColor: '#ef4444',
|
|
51
|
-
borderColor: '#ef4444',
|
|
52
|
-
},
|
|
53
|
-
info: {
|
|
54
|
-
icon: 'ℹ',
|
|
55
|
-
bgColor: '#dbeafe',
|
|
56
|
-
iconColor: '#3b82f6',
|
|
57
|
-
borderColor: '#3b82f6',
|
|
58
|
-
},
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
const c = config[type] || config.info
|
|
62
|
-
const padding = 16
|
|
63
|
-
const lineHeight = 22
|
|
64
|
-
const iconSize = 24
|
|
65
|
-
const height = padding * 2 + (title ? lineHeight + 8 : 0) + (message ? lineHeight : 0)
|
|
66
|
-
|
|
67
|
-
const elements = []
|
|
68
|
-
|
|
69
|
-
// 绘制背景
|
|
70
|
-
const bg = new paper.Path.Rectangle({
|
|
71
|
-
point: [x, y],
|
|
72
|
-
size: [width, height],
|
|
73
|
-
radius: radius,
|
|
74
|
-
})
|
|
75
|
-
bg.fillColor = new paper.Color(c.bgColor)
|
|
76
|
-
bg.strokeColor = new paper.Color(c.borderColor)
|
|
77
|
-
bg.strokeWidth = 1
|
|
78
|
-
elements.push({ type: 'rectangle', id: bg.id })
|
|
79
|
-
|
|
80
|
-
// 绘制图标
|
|
81
|
-
if (showIcon) {
|
|
82
|
-
const iconText = new paper.PointText({
|
|
83
|
-
point: [x + padding + iconSize / 2, y + padding + iconSize / 2 + 6],
|
|
84
|
-
content: c.icon,
|
|
85
|
-
fontSize: iconSize,
|
|
86
|
-
fillColor: new paper.Color(c.iconColor),
|
|
87
|
-
justification: 'center',
|
|
88
|
-
})
|
|
89
|
-
elements.push({ type: 'text', id: iconText.id })
|
|
90
|
-
}
|
|
91
|
-
|
|
92
|
-
const textX = showIcon ? x + padding + iconSize + 12 : x + padding
|
|
93
|
-
let currentY = y + padding
|
|
94
|
-
|
|
95
|
-
// 绘制标题
|
|
96
|
-
if (title) {
|
|
97
|
-
const titleText = new paper.PointText({
|
|
98
|
-
point: [textX, currentY + 18],
|
|
99
|
-
content: title,
|
|
100
|
-
fontSize: 16,
|
|
101
|
-
fillColor: new paper.Color('#1e293b'),
|
|
102
|
-
justification: 'left',
|
|
103
|
-
})
|
|
104
|
-
elements.push({ type: 'text', id: titleText.id })
|
|
105
|
-
currentY += lineHeight + 8
|
|
106
|
-
}
|
|
107
|
-
|
|
108
|
-
// 绘制消息
|
|
109
|
-
if (message) {
|
|
110
|
-
const msgText = new paper.PointText({
|
|
111
|
-
point: [textX, currentY + 16],
|
|
112
|
-
content: message,
|
|
113
|
-
fontSize: 14,
|
|
114
|
-
fillColor: new paper.Color('#475569'),
|
|
115
|
-
justification: 'left',
|
|
116
|
-
})
|
|
117
|
-
elements.push({ type: 'text', id: msgText.id })
|
|
118
|
-
}
|
|
119
|
-
|
|
120
|
-
return { success: true, elements }
|
|
121
|
-
}
|
|
122
|
-
|
|
123
|
-
module.exports = createNotification
|
|
@@ -1,79 +0,0 @@
|
|
|
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.width - 进度条宽度
|
|
16
|
-
* @param {number} args.height - 进度条高度
|
|
17
|
-
* @param {number} args.value - 进度值 0-100
|
|
18
|
-
* @param {string} args.trackColor - 轨道颜色
|
|
19
|
-
* @param {string} args.fillColor - 填充颜色
|
|
20
|
-
* @param {number} args.radius - 圆角半径
|
|
21
|
-
* @param {boolean} args.showLabel - 是否显示标签
|
|
22
|
-
* @param {string} args.label - 标签文字
|
|
23
|
-
*/
|
|
24
|
-
function createProgress(project, canvas, args) {
|
|
25
|
-
const {
|
|
26
|
-
x, y,
|
|
27
|
-
width = 300,
|
|
28
|
-
height = 20,
|
|
29
|
-
value = 50,
|
|
30
|
-
trackColor = '#e0e0e0',
|
|
31
|
-
fillColor = '#6366f1',
|
|
32
|
-
radius = 10,
|
|
33
|
-
showLabel = false,
|
|
34
|
-
label,
|
|
35
|
-
} = args
|
|
36
|
-
|
|
37
|
-
const elements = []
|
|
38
|
-
|
|
39
|
-
// 绘制轨道
|
|
40
|
-
const track = new paper.Path.Rectangle({
|
|
41
|
-
point: [x, y],
|
|
42
|
-
size: [width, height],
|
|
43
|
-
radius: radius,
|
|
44
|
-
})
|
|
45
|
-
track.fillColor = new paper.Color(trackColor)
|
|
46
|
-
elements.push({ type: 'rectangle', id: track.id })
|
|
47
|
-
|
|
48
|
-
// 绘制进度
|
|
49
|
-
const progressWidth = (value / 100) * width
|
|
50
|
-
if (progressWidth > 0) {
|
|
51
|
-
const fill = new paper.Path.Rectangle({
|
|
52
|
-
point: [x, y],
|
|
53
|
-
size: [progressWidth, height],
|
|
54
|
-
radius: radius,
|
|
55
|
-
})
|
|
56
|
-
fill.fillColor = new paper.Color(fillColor)
|
|
57
|
-
elements.push({ type: 'rectangle', id: fill.id })
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
// 显示标签
|
|
61
|
-
if (showLabel && label) {
|
|
62
|
-
const labelText = new paper.PointText({
|
|
63
|
-
point: [x + width / 2, y - 8],
|
|
64
|
-
content: label,
|
|
65
|
-
fontSize: 14,
|
|
66
|
-
fillColor: new paper.Color('#666666'),
|
|
67
|
-
justification: 'center',
|
|
68
|
-
})
|
|
69
|
-
elements.push({ type: 'text', id: labelText.id })
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
return {
|
|
73
|
-
success: true,
|
|
74
|
-
elements,
|
|
75
|
-
value,
|
|
76
|
-
}
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
module.exports = createProgress
|