Skip to content

mjnhmd/MagicPuzzle

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

17 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

🧩 Puzzle - Photo Collage Master

Puzzle Logo

An Elegant and Powerful Android Photo Collage App

Kotlin Jetpack Compose Android License

English | 中文

✨ Create Your Unique Photo Collage ✨


📸 Screenshots

Home Template Editor Puzzle Preview
🏠 Template Gallery ✏️ Template Editor 🖼️ Collage Creator

✨ Features

🎨 Template Editor

  • 🔲 Free cell splitting (H/V)
  • 🔗 Smart cell merging
  • 📐 Custom aspect ratios
  • 🎯 Real-time preview

📷 Photo Editing

  • 🔄 Continuous rotation (0-360°)
  • 🔍 Pinch to zoom & pan
  • ↔️ Horizontal/Vertical flip
  • 🖱️ Drag to swap photos

🎭 Style Customization

  • 📏 Adjustable border width
  • ⭕ Corner radius settings
  • 🎨 Multiple border colors
  • 🖼️ 4K HD export

💾 Template Management

  • 📁 Local persistent storage
  • ♻️ Template reusability
  • 📝 Custom naming
  • 🗑️ Long press to delete

🏗️ Architecture

📦 com.mjn.puzzle
├── 📂 data                    # Data Layer
│   ├── 📂 local              # Room Database
│   ├── 📂 model              # Data Models
│   └── 📂 repository         # Repositories
├── 📂 engine                  # Core Engine
│   ├── 🔧 GridLayoutEngine   # Grid Layout Engine
│   └── 🔧 OccupancyMatrix    # Occupancy Matrix Algorithm
└── 📂 ui                      # UI Layer
    ├── 📂 home               # Home Screen
    ├── 📂 editor             # Template Editor
    ├── 📂 puzzle             # Puzzle Preview
    │   ├── 📂 components     # UI Components
    │   ├── 📂 gesture        # Gesture Handlers
    │   └── 📂 renderer       # Renderers
    └── 📂 theme              # Material3 Theme

🛠️ Tech Stack

Technology Description
Kotlin 100% Kotlin
Jetpack Compose Modern declarative UI
Material Design 3 Latest Material You
Room Database Local data persistence
Coil Image loading
Navigation Compose Navigation framework
ViewModel MVVM architecture
Coroutines + Flow Async programming

🚀 Getting Started

Requirements

  • Android Studio Hedgehog (2023.1.1) or higher
  • JDK 11+
  • Android SDK 35
  • Gradle 8.0+

Installation

1️⃣ Clone the repository

git clone https://github.com/yourusername/puzzle.git
cd puzzle

2️⃣ Open the project

studio .

3️⃣ Build

./gradlew build

4️⃣ Run

./gradlew installDebug

📱 Usage

Creating a Collage

1. 🏠 Select or create a template on home screen
2. ✏️ Split/merge cells in the editor
3. 📷 Pick photos in puzzle screen
4. 🎨 Adjust border & corner styles
5. 💾 Export HD collage to gallery

Gestures

Gesture Function
👆 Tap Select cell
👆👆 Long press + drag Swap photos
🤏 Pinch Zoom photo
✋ Two-finger rotate Rotate photo
👋 Two-finger pan Move photo

🎯 Core Algorithm

Occupancy Matrix Model

The project uses an innovative occupancy matrix algorithm for layout management:

// Each matrix cell records the owning Cell ID
// Supports arbitrary cell merging & splitting
class OccupancyMatrix {
    fun splitHorizontally(cellId: String)
    fun splitVertically(cellId: String)
    fun mergeCells(id1: String, id2: String)
}

Advantages:

  • ✅ Supports any rectangular cell combination
  • ✅ Auto-handles merge boundaries
  • ✅ O(n) space complexity
  • ✅ Unlimited split depth

📄 License

This project is licensed under the MIT License.



🧩 Puzzle - 照片拼图大师

一款优雅而强大的 Android 照片拼图应用


📸 应用截图

主页 模板编辑器 拼图预览
🏠 模板选择 ✏️ 模板编辑 🖼️ 拼图创作

✨ 功能特性

🎨 模板编辑器

  • 🔲 自由分割格子(横向/纵向)
  • 🔗 智能合并相邻格子
  • 📐 自定义宽高比
  • 🎯 实时预览效果

📷 照片编辑

  • 🔄 无极旋转 (0-360°)
  • 🔍 双指缩放平移
  • ↔️ 水平/垂直翻转
  • 🖱️ 拖拽交换位置

🎭 样式定制

  • 📏 可调节边框宽度
  • ⭕ 圆角效果设置
  • 🎨 多种边框颜色
  • 🖼️ 高清导出 (4K)

💾 模板管理

  • 📁 本地持久化存储
  • ♻️ 模板复用
  • 📝 自定义命名
  • 🗑️ 长按删除

🏗️ 项目架构

📦 com.mjn.puzzle
├── 📂 data                    # 数据层
│   ├── 📂 local              # Room 数据库
│   ├── 📂 model              # 数据模型
│   └── 📂 repository         # 数据仓库
├── 📂 engine                  # 核心引擎
│   ├── 🔧 GridLayoutEngine   # 网格布局引擎
│   └── 🔧 OccupancyMatrix    # 占用矩阵算法
└── 📂 ui                      # UI 层
    ├── 📂 home               # 主页
    ├── 📂 editor             # 模板编辑器
    ├── 📂 puzzle             # 拼图预览
    │   ├── 📂 components     # UI 组件
    │   ├── 📂 gesture        # 手势处理
    │   └── 📂 renderer       # 渲染器
    └── 📂 theme              # Material3 主题

🛠️ 技术栈

技术 说明
Kotlin 100% Kotlin 编写
Jetpack Compose 现代声明式 UI 框架
Material Design 3 最新 Material You 设计语言
Room Database 本地数据持久化
Coil 高性能图片加载库
Navigation Compose Compose 导航框架
ViewModel MVVM 架构组件
Coroutines + Flow 异步编程

🚀 快速开始

环境要求

  • Android Studio Hedgehog (2023.1.1) 或更高版本
  • JDK 11+
  • Android SDK 35
  • Gradle 8.0+

安装步骤

1️⃣ 克隆项目

git clone https://github.com/yourusername/puzzle.git
cd puzzle

2️⃣ 打开项目

studio .

3️⃣ 同步 & 构建

./gradlew build

4️⃣ 运行应用

./gradlew installDebug

📱 使用指南

创建拼图

1. 🏠 在主页选择或创建模板
2. ✏️ 在编辑器中分割/合并格子
3. 📷 进入拼图界面选择照片
4. 🎨 调整边框、圆角样式
5. 💾 导出高清拼图到相册

手势操作

手势 功能
👆 单击 选中格子
👆👆 长按拖动 交换照片位置
🤏 双指缩放 缩放照片
✋ 双指旋转 旋转照片
👋 双指平移 移动照片位置

🎯 核心算法

占用矩阵模型 (Occupancy Matrix)

项目采用独创的占用矩阵算法来管理格子布局:

// 每个矩阵单元记录所属的 Cell ID
// 支持任意形状的格子合并与分割
class OccupancyMatrix {
    fun splitHorizontally(cellId: String)  // 横向分割
    fun splitVertically(cellId: String)    // 纵向分割
    fun mergeCells(id1: String, id2: String) // 合并格子
}

优势:

  • ✅ 支持任意矩形格子组合
  • ✅ 自动处理合并边界
  • ✅ 高效的空间复杂度 O(n)
  • ✅ 支持无限层级分割

📝 更新日志

v1.0.0 (2024-12-18)

  • 🎉 首次发布
  • ✨ 模板创建与编辑
  • 📷 照片导入与编辑
  • 💾 高清导出功能

🤝 贡献指南

欢迎贡献代码!请遵循以下步骤:

  1. Fork 本仓库
  2. 创建特性分支 (git checkout -b feature/AmazingFeature)
  3. 提交更改 (git commit -m 'Add some AmazingFeature')
  4. 推送到分支 (git push origin feature/AmazingFeature)
  5. 提交 Pull Request

📄 开源许可

本项目基于 MIT License 开源。


🙏 致谢


💖 如果这个项目对你有帮助,请给个 ⭐ Star!


Made with ❤️ by MJN


⬆ Back to Top | 回到顶部

About

拼图软件。可自定义模板。市面上的拼图大多数都不支持超过12张的图片,这个可以支持任意张数,当然,也别太多

Topics

Resources

Stars

Watchers

Forks

Packages

 
 
 

Contributors

Languages