fix: loose art nested by shape passes checkout again, and ink on ink goes to hand preparation (DTF-WEB-2B)
All checks were successful
Build and deploy / Validate source (push) Successful in 51s
Build and deploy / Integration suite on a real stack (push) Successful in 8m15s
Build and deploy / Secret scan and release gate (push) Successful in 9s
Build and deploy / Publish images (push) Successful in 1m27s

Since 27/11 (bb6fb14) the checkout refused any crossing rectangles. The Site
nests loose art by its shape (Misturado, and Automático when it saves film),
so rectangles cross where the art is clear, and honest carts were refused
with "Duas peças da montagem ficaram uma sobre a outra". The print file
composes with alpha_composite, so those layouts print right.

Loose art: two pieces in one place are still refused (the stacked-copies
price trick bb6fb14 closed); partial crossing passes. Ready sheets: any
crossing is still refused, sheets are never nested. When the film is
composed, ink landing on ink (alpha > 10 on the same pixel) raises
Unsupported, so the item goes to hand preparation with the reason instead of
printing over itself. Contract: output/revisao/contrato-encaixe-forma.md.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Cauê Faleiros
2026-12-02 09:09:25 -03:00
parent cc0db89705
commit 7af6c9797d
4 changed files with 123 additions and 17 deletions

View File

@@ -226,5 +226,70 @@ class PngRenderTests(unittest.TestCase):
self.assertEqual(detail['vector_sources'], 1)
def half_inked(color, side):
"""1 x 1 cm at 300 DPI (118 x 118 px) with ink on one half only."""
image = Image.new('RGBA', (118, 118))
box = (0, 0, 59, 118) if side == 'left' else (59, 0, 118, 118)
image.paste(color + (255,), box)
return image
class InkOverlapTests(unittest.TestCase):
"""Pieces nested by shape cross rectangles where one is clear; ink on ink
is refused when the film is composed (contrato-encaixe-forma.md P1-P3)."""
def setUp(self):
self.dir = tempfile.TemporaryDirectory()
self.addCleanup(self.dir.cleanup)
def save(self, image, name):
path = os.path.join(self.dir.name, name)
image.save(path)
return path
def render(self, spec, paths):
out = os.path.join(self.dir.name, 'out')
os.makedirs(out, exist_ok=True)
files = {i: (path, os.path.basename(path)) for i, path in enumerate(paths)}
return render(spec, files, out, 'DTF-7-item-1')
def crossing(self, first, second):
spec = item([placement(0, 0, 1, 1), placement(0.5, 0, 1, 1, index=1)],
[source(1, 1), source(1, 1)], 1)
return self.render(spec, [self.save(first, 'first.png'), self.save(second, 'second.png')])
def test_ink_crossing_where_one_is_clear_prints_both_whole(self):
parts, _ = self.crossing(half_inked(RED, 'left'), half_inked(GREEN, 'right'))
film = Image.open(parts[0][0]).convert('RGBA')
for x, y in ((10, 10), (10, 59), (50, 100)): # the first piece's left half
self.assertEqual(film.getpixel((x, y))[:3], RED, (x, y))
start = px(0.5)
for x, y in ((start + 70, 10), (start + 100, 59), (start + 110, 100)):
self.assertEqual(film.getpixel((x, y))[:3], GREEN, (x, y)) # the second's right half
# Where the rectangles cross, both are clear: no ink there.
self.assertEqual(film.getpixel((px(0.75), 10))[3], 0)
def test_ink_on_ink_is_refused(self):
art = Image.new('RGBA', (118, 118), RED + (255,))
with self.assertRaisesRegex(printpng.Unsupported, 'tinta no mesmo lugar'):
self.crossing(art, art)
def test_edges_meeting_below_the_ink_alpha_are_not_ink(self):
first = Image.new('RGBA', (118, 118))
first.paste((255, 0, 0, 8), (59, 0, 118, 118)) # meets the second at alpha 8
second = Image.new('RGBA', (118, 118))
second.paste((0, 160, 0, 8), (0, 0, 59, 118)) # meets the first at alpha 8
parts, _ = self.crossing(first, second)
self.assertEqual([name for _, name in parts], ['DTF-7-item-1.png'])
def test_ink_meets_ink_sees_only_ink_above_the_alpha(self):
band = Image.new('RGBA', (20, 20))
band.paste(RED + (255,), (0, 0, 10, 10))
rows = Image.new('RGBA', (10, 10), GREEN + (255,))
self.assertTrue(printpng.ink_meets_ink(band, rows, (5, 5)))
self.assertFalse(printpng.ink_meets_ink(band, rows, (10, 10)))
self.assertFalse(printpng.ink_meets_ink(Image.new('RGBA', (20, 20)), rows, (0, 0)))
if __name__ == '__main__':
unittest.main()

View File

@@ -59,14 +59,23 @@ class OverlapTests(unittest.TestCase):
Item.model_validate(loose([(0, 0), (20.5, 0), (0, 10.5), (20.5, 10.5)]))
Item.model_validate(loose([(0, 0), (20, 0), (0, 10)]))
def test_pieces_on_each_other_are_refused(self):
for layout in ([(0, 0), (0, 0)], [(0, 0), (10, 5)], [(0, 0), (19.9, 9.9)],
[(0, 0)] * 100):
def test_nested_rectangles_pass(self):
# The Site nests art by its shape: rectangles crossing over transparent
# parts are honest (Sentry DTF-WEB-2B, contrato-encaixe-forma.md K2).
Item.model_validate(loose([(0, 0), (10, 5)]))
Item.model_validate(loose([(0, 0), (19.9, 9.9)]))
def test_pieces_in_one_place_are_refused(self):
for layout in ([(0, 0), (0, 0)], [(0, 0)] * 100):
with self.assertRaises(ValueError) as caught:
Item.model_validate(loose(layout))
self.assertIn('uma sobre a outra', str(caught.exception))
with self.assertRaises(ValueError):
def test_ready_sheets_never_cross(self):
# Sheets go one under the other, never nested (contrato-encaixe-forma.md K4).
with self.assertRaises(ValueError) as caught:
sheet(gap=-5)
self.assertIn('uma sobre a outra', str(caught.exception))
class ClosePiecesTests(unittest.TestCase):