Community影像github.com

截圖轉Compose

將應用設計截圖(JPG/PNG,常為AI生成)或Figma幀轉換為與之匹配的原生Kotlin Jetpack Compose UI,以設計為優先。測量像素和顏色(px轉dp),撰寫螢幕/素材清單,並建立設計系統來記錄觀測值與推斷值,將Iconify圖示構建成VectorDrawable,生成美術圖而非裁剪截圖,實作MVI螢幕,最後將模擬器或Roborazzi渲染結果與參考圖比較。

截圖轉Compose 是什麼?

此技能專用於將頁面設計截圖或 Figma 設計稿精確轉換為 Kotlin Jetpack Compose UI。核心原則是「以設計為輸入,以比對為驗證」:它會測量參考圖上的像素尺寸與顏色,自動換算 dp 值,建立包含觀測值與推斷值的設計系統,再利用 Iconify 圖示庫生成 VectorDrawable,並產生美術圖而非直接裁剪截圖。最終產出採用 MVI 架構的 Compose 畫面,並透過 emulator 截圖或 Roborazzi 渲染與原始設計進行並排比對,確保視覺一致性。支援 Jetpack Compose、Android 開發,以及 Figma 設計協作流程。適合開發者將設計稿「一次到位」轉為可運行的 Compose 程式碼,避免靠肉眼猜測尺寸或顏色,大幅減少設計與實作之間的落差。

相容平台~Claude Code~Codex CLI~Cursor
npx skills add https://github.com/zohaibmushwani/agent-skills/tree/HEAD/skills/screenshot-to-compose

Installed? Explore more 影像 skills: steipete/songsee, affaan-m/frontend-design, mattpocock/improve-codebase-architecture · View all 6 →

在你喜歡的 AI 中提問

開啟一個已預先載入此 Agent Skill 的新對話。

說明文件

截圖轉Compose 是做什麼的?

在 Compose 中忠實重現設計,無需靠目測。參考圖就是驗收測試,因此你使用的每個數值要不是觀測值(從圖像上測量得出),就是推斷值(你聲明是猜測),最終完成的畫面會與參考圖進行比對。

當設計是輸入時

  • 僅有截圖/示意稿:按照以下所有階段進行。
  • 有 Figma 框架可用:跳過測量(從 Figma 讀取值),其餘步驟保留。
  • 尚無設計:先使用 app-design-studio 技能,再回到此處。

工作流程

在檔案中工作(docs/design/),一次處理一個螢幕,共用基礎設施建立完成後再進行。在理解整個螢幕清單之前,不要實作任何東西。

  1. 檢查。 先閱讀儲存庫(架構、主題、共用元件、現有畫面)。保留可行的部分。記錄假設。
  2. 清單。 將參考圖完整複製到 docs/design/reference/(使用 kebab-case 命名)。撰寫 SCREEN_INVENTORY.md:每個圖像對應一個畫面 + 狀態、畫面之間的連結、缺失的參考(有連結但未顯示的畫面)、像素尺寸和長寬比。包含所有狀態:載入中、空白、錯誤、離線、權限、付費。
  3. 測量。 執行 scripts/measure_image.py shot.png --frame-dp 390 --sample x,y ... 取得 px 轉 dp 的比例和顏色樣本(references/measuring.md)。像素不等於 dp:除非另有說明,否則假設一個 390 dp 的框架,dp = px / (imageWidthPx / 390)。在單獨的欄位中記錄觀測值和推斷值。
  4. 設計系統。 將測量到的顏色映射到 Material 3 角色、字型比例、形狀、間距主題。畫面只使用主題代號(畫面中沒有十六進位顏色、尺寸或圓角)。定義淺色和深色;如果只有淺色,則推導深色而不改變佈局。
  5. 素材(references/assets.md)。圖示:一個系列,從 Iconify 獲取,使用 scripts/svg_to_vectordrawable.py 轉換。美術圖:生成它,絕不從截圖中裁剪。文字、按鈕、卡片、環形圖和圖表始終使用 Compose,絕不使用圖像。在 ASSET_INVENTORY.md 中記錄來源、授權、模型和提示詞。
  6. 計劃。 預先為每個畫面決定:返回行為、網路/離線類別、權限、小螢幕上的滾動或適配、動畫。撰寫 SCREEN_IMPLEMENTATION_PLAN.md 並指定建置順序。(這些品質規則位於 android-compose-quality-gate 技能中。)
  7. 實作,首先建立共用基礎,然後是畫面:無狀態可組合項搭配不可變的 UI 狀態、帶有意圖的 ViewModel、每個檔案一個可組合項、所有文字使用字串資源。僅對具有不相關檔案的獨立模組進行平行化。在建立卡片、瓷磚或緊湊文字之前,先閱讀 references/compose-lessons.md。
  8. 比較(references/verification.md)。渲染畫面(模擬器截圖或 Roborazzi),使用 scripts/compare_side_by_side.py 將它與參考圖以相同寬度並排放置,列出佈局、間距、字型、顏色、形狀和素材的差異,修正,重複。然後檢查小裝置(360 x 526 dp)、長文字/德文、RTL、深色、字型縮放 1.3。絕不為了像素匹配而犧牲功能或響應性。
  9. 交付。 保持參考圖、附提示詞的素材、圖示來源/授權、清單和比較註記是最新的。一個畫面只有在它能運作並且通過視覺比較時才算完成。按主題提交。

防止常見失敗的規則

  • 絕不從參考截圖中裁剪圖像(低解析度、壓縮、內嵌 UI)。
  • 絕不用圖片代替原生 UI。
  • 當參考圖不明確時,不要憑空發明設計:做出最合理的推斷,將其寫入推斷欄,保持貼近參考圖。
  • 在畫面經過執行和比較之前,不要宣稱完成。
  • 儲存庫或文件中沒有秘密(API 金鑰);圖像服務金鑰來自環境變數。

檔案

  • references/measuring.md - px 轉 dp、顏色取樣、觀測值與推斷值表格。
  • references/assets.md - Iconify 轉 VectorDrawable、圖片生成順序與審查、匯出尺寸、其他來源。
  • references/compose-lessons.md - 耗費實際時間的缺陷:同級卡片比例、內建測量崩潰、寬度閾值、自動調整文字大小。
  • references/verification.md - 模擬器與 Roborazzi 比較循環及裝置矩陣。
  • scripts/measure_image.py, scripts/svg_to_vectordrawable.py, scripts/compare_side_by_side.py(Python 3 + Pillow)。

Individual skills in this repo

This repo contains 2 individual skills — each has its own dedicated page.

app-design-studio

Turn an app name or a website / web-app idea into a complete high-fidelity UI design repository - pages or screens, every state (loading, empty, error, offline), dialogs, sheets, components, interactions - with a locked design system and measurable usability gates. Three targets, each with its own profile and wording - mobile app (portrait screens: splash, onboarding, auth, home, settings), website (landscape desktop pages plus a narrow responsive layout), web app / portal / dashboard. Use whenever the user gives an app name or idea and wants screens, pages, UI design, a design repo, mockups, a screen inventory, or a design to hand to developers/designers, even if they never say "skill" or "Figma". Also use to audit or fix an existing set of generated screens for usability (contrast, targets, states) while keeping them beautiful.

store-screenshots

Create App Store and Google Play marketing screenshot sets that look like top-chart apps - a headline-led story of 5-8 frames with a poster-style first frame, zoomed real UI fragments, a dominant brand colour, panoramic links between frames, social proof and human touches - generated frame by frame with Codex (GPT Image) using the app's real screens as reference images, text-checked and edit-passed, then fitted to the exact store sizes. Use whenever the user wants store screenshots, "App Store screenshots", "Play Store images", listing graphics, a screenshot redesign or "before/after" for a store page, or wants their app's store page to convert better, even if they only say "screenshots" for an app. Takes real app screens (for example from app-design-studio) as input.

相關技能