feat: Dropstar's 03/11 answers on residue and item 16; wide areas count in the stroke
All checks were successful
Build and deploy / Validate source (push) Successful in 11s
Build and deploy / Integration suite on a real stack (push) Successful in 5m25s
Build and deploy / Secret scan and release gate (push) Successful in 8s
Build and deploy / Publish images (push) Successful in 1m20s

- Residue: the acceptance stays on loose artwork only ("arquivo
  fracionado"), with their text. A ready sheet with residue goes back,
  as the designer cannot clean a closed sheet.
- Item 16, new rule, all three at once: thinnest stroke up to 4 px, at
  least 60% of the ink in areas 20 px or wider, at most 10% of the ink in
  strokes up to 4 px. One pop-up per file, on ready sheets and loose art,
  that does not block: "Imprimir assim mesmo (C1)" (default) or "Quero
  subir em dois arquivos". The ready sheet's three options are gone; the
  card notes that the customer was warned and printed as C1.
- The stroke reader counts the ink in wide areas with their edges and the
  ink in strokes up to 4 px, and areas wider than the measured distance now
  add axis samples: two edge pixels no longer make a solid art C1 ("Salmo
  91" was C1 at 3 px, now C3). The four test sheets still give 2, 5, 20
  and 4 px; the new rule triggers on 4 of the 9 real arts.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Cauê Faleiros
2026-11-03 14:56:35 -03:00
parent a17f5fc08d
commit bd1e1772a7
8 changed files with 85 additions and 60 deletions

View File

@@ -71,6 +71,21 @@ function novoMapa(wPx,hPx,larguraCm){
// A folha passa em faixas, linha a linha: cada faixa guarda 20 linhas antes e
// depois, o alcance da distância, e nada maior que uma faixa fica na memória.
const ALFA_TRACO=40, TRACO_D=20, TRACO_FAIXA=256, TRACO_CISCO=30;
// Quanta tinta das linhas medidas fica a até r px (num quadrado) de um pixel a
// lim ou mais do fundo. Com lim de 10 px e r de 10 px, é a tinta das áreas de
// 20 px ou mais, bordas incluídas; com 3 px e 2 px, a que não é traço fino.
function tintaPerto(t,lim,r,de,ate){
const {w,n,dist}=t, h=t.rot, prox=t.prox; // os rótulos já serviram
for(let y=0;y<n;y++){ const o=y*w;
let ult=-1e9; for(let x=0;x<w;x++){ if(dist[o+x]>=lim) ult=x; h[o+x]=x-ult<=r?1:0; }
ult=1e9; for(let x=w-1;x>=0;x--){ if(dist[o+x]>=lim) ult=x; if(ult-x<=r) h[o+x]=1; } }
let c=0;
for(let x=0;x<w;x++){
let ult=1e9; for(let y=n-1;y>=0;y--){ if(h[y*w+x]) ult=y; prox[y]=ult; }
ult=-1e9; for(let y=0;y<ate;y++){ const p=y*w+x; if(h[p]) ult=y;
if(y>=de&&dist[p]&&(y-ult<=r||prox[y]-y<=r)) c++; } }
return c;
}
// O contexto de cada faixa: as linhas acima e abaixo que ela lê sem medir. Um
// cisco (menos de 30 px de tinta a 300 DPI) tem menos linhas que isso, então
// a faixa sempre o vê inteiro; o que encosta na borda cortada é traço.
@@ -79,7 +94,8 @@ function novoTraco(wPx,dpi){
const linhas=TRACO_FAIXA+2*ctx;
return {w:wPx,dpi,linhas,ctx,cisco,tinta:new Uint8Array(wPx*linhas),dist:new Uint16Array(wPx*linhas),
rot:new Int32Array(wPx*linhas),pai:new Int32Array((wPx*linhas>>1)+2),area:new Int32Array((wPx*linhas>>1)+2),
n:0,inicio:0,hist:new Float64Array(2*TRACO_D+2),total:0,tintaPx:0,largosPx:0};
prox:new Int32Array(TRACO_FAIXA+2*ctx),
n:0,inicio:0,hist:new Float64Array(2*TRACO_D+2),total:0,tintaPx:0,largosPx:0,finosPx:0};
}
// Como a sala mede (Dropstar, 30/10/2026): componentes de tinta com menos de
// 30 px não são traço e saem antes da distância. Vizinhos nas oito direções.
@@ -153,10 +169,21 @@ function tracoFaixa(t,fim){
const at=(x,y)=>(x<0||x>=w||y<0||y>=n)?0:dist[y*w+x];
// Item 16: tinta em áreas de 20 px ou mais (a 300 DPI) é a que fica a 10 px
// ou mais do fundo; a conta é da tinta das linhas medidas.
const largo=100/escala;
for(let y=de;y<ate;y++){ const o=y*w; for(let x=0;x<w;x++){ const d=dist[o+x]; if(!d) continue; t.tintaPx++; if(d>=largo) t.largosPx++; } }
let tintaFaixa=0;
for(let y=de;y<ate;y++){ const o=y*w; for(let x=0;x<w;x++) if(dist[o+x]) tintaFaixa++; }
t.tintaPx+=tintaFaixa;
if(tintaFaixa){
t.largosPx+=tintaPerto(t,100/escala,Math.round(10/escala),de,ate);
// Traço fino, até 4 px: nada a 3 px do fundo a até 2 px dele.
t.finosPx+=tintaFaixa-tintaPerto(t,30/escala,Math.max(1,Math.round(2/escala)),de,ate);
}
for(let y=de;y<ate;y++) for(let x=0;x<w;x++){
const d=dist[y*w+x]; if(!d||d>=CAP) continue;
const d=dist[y*w+x]; if(!d) continue;
// Mais largo que a distância medida (uns 40 px): o eixo dessa área também
// conta, na última faixa, ou dois pixels soltos de borda viram o menor
// traço de uma arte toda chapada. O comprimento do eixo é cerca de metade
// do contorno da região além do limite.
if(d>=CAP){ if(at(x-1,y)<CAP||at(x+1,y)<CAP||at(x,y-1)<CAP||at(x,y+1)<CAP){hist[max]+=0.5;t.total+=0.5;} continue; }
// No eixo do traço a distância não é menor que a de nenhum vizinho; perto
// de um canto sempre há um vizinho mais fundo, e o canto não conta.
let iguais=0, eixo=true;
@@ -185,12 +212,12 @@ function tracoFaixa(t,fim){
function tracoFim(t){
if(t.lido!==undefined) return t.lido;
tracoFaixa(t,true);
t.tinta=t.dist=t.rot=t.pai=t.area=null; // a faixa não serve mais
t.tinta=t.dist=t.rot=t.pai=t.area=t.prox=null; // a faixa não serve mais
if(!t.total) return t.lido=null;
let soma=0, px=1;
for(let i=1;i<t.hist.length;i++){ soma+=t.hist[i]; if(soma>=t.total*0.01){ px=i; break; } }
// largos: a parte da tinta em áreas chapadas, de 20 px ou mais (item 16)
return t.lido={px, classe:px<=4?'C1':px<=19?'C2':'C3', largos:t.tintaPx?t.largosPx/t.tintaPx:0};
return t.lido={px, classe:px<=4?'C1':px<=19?'C2':'C3', largos:t.tintaPx?t.largosPx/t.tintaPx:0, finos:t.tintaPx?t.finosPx/t.tintaPx:0};
}
// A linha y da folha: o alfa de cada pixel em alfa[inicio + x*de].
function mapaLinha(m,y,alfa,inicio,de){