White Was the Background. It Was Also the Part I Wanted to Paint.

I wanted a colored drawing to appear without a white rectangle around it. My first rule sounded sufficient: make nearly white pixels transparent.

It wasn’t sufficient for a coloring tool. White outside the outline and white inside the outline had the same color. They didn’t have the same job.

In my September 21, 2026 notes, that distinction became a visible bug: color could spill outside the drawing. I’d treated a color test as if it described where painting was allowed. The cost was a canvas that couldn’t enforce its own boundary.

The correction used a mask built from the edge of the image. No image-generation service was involved. This was a pixel-classification problem inside a browser canvas.

My white test had thrown away useful information

The input was black line art on a light background. Inside a closed outline, the white area was supposed to remain available for coloring. Outside it, the white margin wasn’t part of the drawing.

A near-white threshold could identify both areas as light. It couldn’t tell whether a light pixel was enclosed by a line or connected to the canvas edge.

That’s the information I needed. Changing the threshold alone wouldn’t add it.

My revised rule started with the border and followed connected background pixels inward. Those reachable pixels became the outside region. Light pixels enclosed by the outline stayed inside the paintable region, along with the line itself.

Pixel location Color-only classification Border-connected classification
White outer margin White Outside if reachable from the edge
White inside a closed outline White Interior if the outline blocks the path
Dark outline Not white Boundary retained in the mask
Interior behind a gap in the outline White Can become reachable from outside

This is a rule table, not a measured accuracy score. I didn’t record a full-corpus pass rate.

The mask and the visible drawing had different jobs

The implementation added a paint mask and clipped the color layer with it. It used destination-in compositing after strokes so that paint outside the retained region didn’t survive.

MDN’s canvas compositing reference describes destination-in as retaining existing content where it overlaps the new shape. Here the new shape was the mask.

That operation didn’t discover the outline. It only applied the mask I’d already built. A bad mask would still clip the wrong pixels perfectly.

I kept that distinction in the review because the compositing call was the easy part to recognize in the AI-assisted implementation. Seeing the expected API in the code wasn’t enough to establish that the geometry was right.

What the September check actually established

The recorded verification used real template assets in a Python reproduction of the pixel logic. It checked outer corners as outside and found the center paintable in most of the sampled cases. The JavaScript syntax check also passed.

The record didn’t preserve a sample count or a per-template result table. It explicitly left physical pointer interaction unverified at that stage.

So I can’t turn it into “all 68 templates passed.” Sixty-eight was the asset set mentioned for further checking, not a success count. I also can’t call the Python check a completed tablet-to-display test.

Those limits reduce the headline, but they keep the story honest. I had a corrected geometric rule and an implementation check. I still needed to validate the drawing experience.

The input can break the assumption

A border fill assumes something useful about the artwork: the outside is reachable from the edge, and the intended inside is separated from it.

A gap in an outline can connect those regions. Artwork that touches the canvas boundary can complicate the classification too. My notes called out edge-touching templates as a remaining risk.

I wouldn’t try to hide those failures by endlessly tuning a whiteness threshold. I’d inspect the input shape first. A threshold controls which pixels are considered background; it doesn’t repair every broken contour.

For another verification run, I’d use a closed outline, a deliberately open outline, a shape touching the edge, and a pale antialiased boundary. I’d keep the resulting masks beside the input images. That’s the next test set I’d use, not a batch I’m claiming to have completed today.

Don’t use one transparency rule for every stage

Removing a background for display and restricting a brush while editing are separate operations. They can share data, but they don’t automatically share the same definition of “white means removable.”

I also wouldn’t call this general background removal. It was built for line art with a simple background. Photographs, shadows, gradients, and open sketches weren’t validated by this incident.

My useful correction was to stop asking a color value to explain the shape. The outside wasn’t merely white. It was white that the edge could reach.

That changed what I reviewed in the next patch: the mask itself, then the stroke, then the displayed result. I had already seen how a click test could pass while the visible UI stayed broken. Here, a correct canvas call could have hidden the same gap between code and behavior.

Similar Posts