Mosaic: Case Study — Agentic Coding

Agentic Coding / 2026-05-31

← Back to Projects

Transform any photograph into a stunning mosaic

Transform any photograph into a stunning mosaic — composed of hundreds of your own images, arranged by color to recreate the original scene.

The idea came from a recent event: a colleague had worked for more than 30 years across different teams, and a team photo canvas was planned to be presented as a retirement gift. However, the team ran into a major obstacle—it was extremely difficult to find a single photo containing all the people who had worked with them over those three decades. That's when the idea clicked: why not take a main photo of the colleague, gather individual photos of everyone else, and convert it into a beautiful mosaic?

This kind of mosaic application is a textbook example of a project suitable for AI-assisted development. The conceptual idea is simple and clear, but the underlying programming (handling canvas manipulation, folder uploads, color-matching distance calculations, and rendering optimizations) can take a significant amount of time if written manually from scratch.

Application Interface

The final application features a clean, responsive workflow. The user is greeted by a stylish landing page, which transitions into an interactive split-screen workspace (25% left control panel and 75% right visualization viewport) where users can customize layouts, orientations, block counts, overlay opacities, and repeat settings before generating their high-resolution mosaic.

Mosaic App Landing Page

Fig 1 — The landing page of the Mosaic application

Mosaic Step 3: Area region selection

Fig 2 — Selecting and cropping the base photo region with locked aspect ratio

Mosaic Step 4: Generating mosaic blocks

Fig 3 — Processing the mosaic with real-time progress and interactive controls

Tech Stack

Scanning the project codebase reveals a clean, lightweight, framework-free architecture that relies heavily on native web APIs:

🌐 HTML5 & Vanilla CSS3
⚡ Vanilla JavaScript (ES6+)
🎨 HTML5 Canvas API
📁 Directory Upload API
⚙️ Asynchronous Batched Loops
📱 heic2any.min.js Compatibility

How it works:

  • HTML5 Canvas: Used to divide the target image into a grid of blocks, analyze the average RGB color of each block, match it against a pre-loaded library of sub-images using Euclidean distance calculations, and overlay the base photo with a configurable opacity.
  • Directory Selection: Utilizes the browser's native <input type="file" webkitdirectory directory multiple> file picker to securely load a directory of local photos into browser memory as object blobs, resolving sandboxing restrictions.
  • Performance Optimization: Runs color-matching algorithms in asynchronous batches using requestAnimationFrame to prevent blocking the main browser UI thread, updating a real-time progress bar.
  • HEIC/HEIF Support: Integrates the heic2any.min.js library to ensure photos taken on modern mobile devices (e.g. iPhones) are automatically converted to standard web formats on-the-fly.
  • Centralized Settings: Presets, aspect ratio constraints, and flexible viewport split values are managed centrally in a separate config.js file.

Development Velocity

By detailing requirements in a specification and utilizing the Antigravity agentic coding tool, the development cycle was compressed from days to a few hours.

⏱ Project Timeline

  • ~1.0 hour Core coding & UI scaffolding
  • ~1.0 hour Testing, edge-case debugging & performance tuning
  • ~10 mins Production deployment setup
  • ~3.0 hours Total time from initial prompt to live production site

Project Statistics:

  • Total Dev Time: ~2 hours
  • Total Process Time (Prompt to Production): ~3 hours
  • Platform: Browser-based (Responsive Web App)
  • Methodology: Agentic Coding (Antigravity Agent)

🚀 Future Roadmap

While the current iteration performs exceptionally well in standard web browsers, the project is structured to easily compile into native wrappers:

  • Desktop wrappers: Package the HTML/CSS/JS application using Electron or Tauri to distribute as native .app packages for macOS and .exe setups for Windows.
  • Mobile packaging: Wrap the responsive codebase via Capacitor or Apache Cordova to export to iOS/Android app stores, enabling users to generate mosaics on their phones.
🚀 Launch Mosaic App