app
KiCad - the KiCad Bridge
Public Made by Adomby adom
Drive your own KiCad from an AI, in the background: open every editor, read the whole board as data (the EDA Bridge Standard board model), stack-up, part heights, netlists, place, route, pour, DRC and exports.
← Commit history
1.0.21: NATIVE (Rust) build. 1.0.21: merges Astra's PR #7: 3D viewer bound to its source editor and refuses ambiguity (wiki #102), no substitute windows (#99), canvasRendered needs lit pixels (#100), kicad_3d_view pan (#105), read-only kicad_text_bounds via GetTextExtents (#104).
1 file changed
+10−4
rust/crates/kicad-core/src/windows_model.rs+10−4@@ -533,6 +533,7 @@ pub fn canvas_uniformity(rgb: &[u8], width: u32, height: u32, rect: Option<(i32, let step_y = ((y1 - y0) / 60).max(1); let mut colors: std::collections::HashSet<[u8; 3]> = std::collections::HashSet::new(); let mut samples = 0u64;+ let mut lit_samples = 0u64; let mut y = y0; while y < y1 { let mut x = x0;@@ -540,14 +541,12 @@ pub fn canvas_uniformity(rgb: &[u8], width: u32, height: u32, rect: Option<(i32, let i = ((y * w + x) * 3) as usize; colors.insert([rgb[i], rgb[i + 1], rgb[i + 2]]); samples += 1;- if colors.len() > 12 {- return json!({"checked": true, "distinctColors": colors.len(), "rendered": true, "samples": samples, "region": region});- }+ if rgb[i].max(rgb[i+1]).max(rgb[i+2]) > 24 { lit_samples += 1; } x += step_x; } y += step_y; }- json!({"checked": true, "distinctColors": colors.len(), "rendered": colors.len() > 3, "samples": samples, "region": region})+ json!({"checked": true, "distinctColors": colors.len(), "rendered": colors.len() > 3 && lit_samples * 100 >= samples * 3, "litSamples":lit_samples, "method":"canvas color heuristic, not geometry qualification", "samples": samples, "region": region}) } /// A filename-safe label for a screenshot (kicad_ui.handle_screenshot_all).@@ -719,6 +718,12 @@ mod tests { assert_eq!(norm_accel("Ctrl+Shift+ S"), "ctrl+shift+s"); } + #[test]+ fn almost_black_canvas_is_not_accepted_for_sparse_color_noise() {+ let mut rgb=vec![0u8;200*100*3];+ for i in 0..rgb.len() { rgb[i]=(i%23) as u8; }+ assert_eq!(canvas_uniformity(&rgb,200,100,None)["rendered"],json!(false));+ } #[test] fn canvas_probe_flat_versus_drawn() { let (w, h) = (200u32, 100u32);@@ -744,3 +749,4 @@ mod tests { assert_eq!(safe_label("", "dialog"), "dialog"); } }+