Skip to content

Comments

refactor: replace excavateModules with visual layering approach#404

Closed
scopewu wants to merge 1 commit intozpao:trunkfrom
scopewu:feature/border-mask-excavate
Closed

refactor: replace excavateModules with visual layering approach#404
scopewu wants to merge 1 commit intozpao:trunkfrom
scopewu:feature/border-mask-excavate

Conversation

@scopewu
Copy link

@scopewu scopewu commented Feb 6, 2026

Changes:

  • Remove excavateModules() function that copied and mutated modules
  • Render background rect in SVG using element
  • Draw background fillRect in Canvas before rendering image

Changes:
- Remove excavateModules() function that copied and mutated modules
@scopewu
Copy link
Author

scopewu commented Feb 6, 2026

Replace data-mutation based excavation with visual layering using background-colored rectangles. This eliminates the need to copy and modify the modules array, improving performance.

@zpao
Copy link
Owner

zpao commented Feb 7, 2026

Thanks for taking the time to send this!

I thought about doing it this way when we added the embedded image, however because it is possible to have transparency for the background color & the embedded image, we can't just layer like this.

Here are a few screenshots, 2 sets of 2 to show what happens, before & after you changes. For these, I changed the background of the example page and then in code (because most browsers don't support alpha transparency in the color picker), used a background color with transparency. These are just the SVGs but canvas looked the same.

Code changes
diff --git a/examples/full.tsx b/examples/full.tsx
index 854eb42..1248a23 100644
--- a/examples/full.tsx
+++ b/examples/full.tsx
@@ -10,7 +10,7 @@ function FullDemo() {
   );
   const [size, setSize] = useState(128);
   const [fgColor, setFgColor] = useState('#000000');
-  const [bgColor, setBgColor] = useState('#ffffff');
+  const [bgColor, setBgColor] = useState('#ffffff88');
   const [level, setLevel] = useState<ErrorCorrectionLevel>('L');
   const [boostLevel, setBoostLevel] = useState<boolean>(true);
   const [minVersion, setMinVersion] = useState(1);
diff --git a/examples/index.html b/examples/index.html
index 33050b7..fe9f247 100644
--- a/examples/index.html
+++ b/examples/index.html
@@ -11,6 +11,7 @@
       }
       .output {
         margin-left: 1rem;
+        background-color: #c66;
       }
       @media only screen and (max-width: 600px) {
         .container {
  1. No other changes, embedded image at 100% opacity
before after
  1. Adjusted image opacity in the example UI
before after

So, while I appreciate the time spent and care to dig in and attempt this, I'm going to have to close this out.

@zpao zpao closed this Feb 7, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants