{"record":{"id":"9012157a6b66cc19","repo":"tonhowtf/omniget","slug":"a-grade-n-o-cabe-nessa-folha","errorCode":null,"errorMessage":"a grade não cabe nessa folha","messagePattern":"a grade não cabe nessa folha","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src-tauri/omniget-core/src/core/tools/image_sprite.rs","lineNumber":358,"sourceCode":"fn slice(opts: &SpriteOptions, progress: &ProgressFn) -> anyhow::Result<SpriteResult> {\n    let files = gather(opts);\n    let input = files\n        .first()\n        .ok_or_else(|| anyhow!(\"escolha o spritesheet\"))?;\n    let sheet = image::open(input)\n        .map_err(|e| anyhow!(\"não abri {}: {}\", input.display(), e))?\n        .to_rgba8();\n    let grid = Grid {\n        cols: opts.cols,\n        rows: opts.rows,\n        cell_w: opts.cell_w,\n        cell_h: opts.cell_h,\n        margin: opts.margin,\n        spacing: opts.spacing,\n    };\n    let cells = grid_cells(sheet.width(), sheet.height(), &grid);\n    if cells.is_empty() {\n        return Err(anyhow!(\"a grade não cabe nessa folha\"));\n    }\n\n    let stem = if opts.name.trim().is_empty() {\n        input\n            .file_stem()\n            .map(|s| s.to_string_lossy().to_string())\n            .unwrap_or_else(|| \"quadro\".into())\n    } else {\n        super::sanitize_name(&opts.name)\n    };\n    let dir = out_dir(\n        opts,\n        &input\n            .parent()\n            .map(|p| p.join(format!(\"{}-quadros\", stem)))\n            .unwrap_or_default(),\n    );\n    std::fs::create_dir_all(&dir)?;","sourceCodeStart":340,"sourceCodeEnd":376,"githubUrl":"https://github.com/tonhowtf/omniget/blob/8600b91f4246848bac346874daa9e61c1fc5677a/src-tauri/omniget-core/src/core/tools/image_sprite.rs#L340-L376","documentation":"Thrown by slice when the computed sprite grid produces zero cells for the loaded sheet — i.e. cols/rows/cell size, margin and spacing do not fit within the image dimensions. grid_cells() returned an empty list, so there is nothing to slice.","triggerScenarios":"Calling run() with mode \"slice\" where cell_w/cell_h plus margins and spacing exceed sheet width/height, or cols/rows are zero, or the image is smaller than one cell.","commonSituations":"Manual grid config mistakes (values in the wrong unit, e.g. pixels vs percentage); reusing options from a different sheet; spacing/margin set too large for a small sheet.","solutions":["Verify cell_w*cols + spacing*(cols-1) + 2*margin <= sheet width, and the same for height.","Set cols/rows/cell_w/cell_h to 0 if the tool supports auto-derivation from the sheet size.","Log sheet.width()/height() and the grid values before slicing to spot the mismatch.","Reject or auto-correct oversized grid configs in the UI before calling run()."],"exampleFix":"// before\nlet grid = Grid { cols: 10, rows: 10, cell_w: 512, cell_h: 512, margin: 0, spacing: 0 };\n// after\n// for a 1024x1024 sheet this fits; validate first:\nassert!(opts.cell_w * opts.cols <= sheet_width && opts.cell_h * opts.rows <= sheet_height);","handlingStrategy":"validation","validationCode":"fn grid_fits(sheet_w: u32, sheet_h: u32, g: &Grid) -> bool {\n    let gw = g.margin * 2 + g.cell_w * g.cols + g.spacing * g.cols.saturating_sub(1);\n    let gh = g.margin * 2 + g.cell_h * g.rows + g.spacing * g.rows.saturating_sub(1);\n    gw <= sheet_w && gh <= sheet_h && g.cols > 0 && g.rows > 0 && g.cell_w > 0 && g.cell_h > 0\n}","typeGuard":null,"tryCatchPattern":"match image_sprite::run(&opts, &progress) {\n    Err(e) if e.to_string().contains(\"a grade não cabe\") => {\n        eprintln!(\"ajuste cols/rows/cell_w/cell_h para o tamanho da folha\");\n    }\n    other => other?,\n}","preventionTips":["Compute the grid math against real image dimensions before slicing.","Reuse per-sheet saved options, not global ones.","Clamp cell sizes to sheet dimensions in the UI.","Log sheet.width()/height() alongside grid params on failure."],"tags":["validation","grid","spritesheet","geometry"],"backgroundTag":"invalid-argument-value","analyzedSha":"8600b91f4246848bac346874daa9e61c1fc5677a","analyzedAt":"2026-09-12T14:29:19.317Z","contentChangedAt":"2026-09-12T14:29:19.317Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}