Optional extract — not used by the main PaintCRM Vite app.
The production UI lives inpaint-preview-app/script.js+src/. Use this folder only if you are embedding the canvas in a separate React/Next project.
This folder includes a client-side canvas component that combines:
- Color-based region selection from clicked seed pixels
- Edge-aware flood fill to avoid crossing sharp boundaries
- Optional ML wall assist using DeepLab (TensorFlow.js)
WallRecolorCanvas.tsxpixelUtils.tsnext-app-router-example/page.tsxnext-pages-router-example/index.tsx
In your React/Next.js project:
npm install @tensorflow/tfjs @tensorflow-models/deeplab- Copy
WallRecolorCanvas.tsxandpixelUtils.tsinto a components folder (example:src/components/wall-recolor/). - Copy the example page from
next-app-router-example/page.tsx.
- Copy
WallRecolorCanvas.tsxandpixelUtils.tsinto your components folder. - Copy the example page from
next-pages-router-example/index.tsx.
- Component is marked with
"use client"and must run on client side. - For large images, model inference is downscaled for performance.
- If ML model load fails, the component still works in edge + color mode.