chore: remove dead PaletteContext methods (find_closest, read_color_fp)
Browse filesThese were planned for palette-space anchor color matching but the
implementation samples colors directly from the gradient sprite,
making the palette lookup methods unnecessary.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
crates/openwa-core/src/display/gradient.rs
CHANGED
|
@@ -52,48 +52,6 @@ impl PaletteContext {
|
|
| 52 |
}
|
| 53 |
None
|
| 54 |
}
|
| 55 |
-
|
| 56 |
-
/// Find the closest palette match for an RGB color (components in 8.8 fixed-point).
|
| 57 |
-
/// Returns (palette_index, error_percentage).
|
| 58 |
-
fn find_closest(&self, r: i32, g: i32, b: i32) -> (u8, i32) {
|
| 59 |
-
let mut best_idx = 0u8;
|
| 60 |
-
let mut best_dist = i32::MAX;
|
| 61 |
-
for i in 0..self.used_count {
|
| 62 |
-
let idx = self.used_list[i] as usize;
|
| 63 |
-
if idx == 0 {
|
| 64 |
-
continue;
|
| 65 |
-
}
|
| 66 |
-
let c = self.colors[idx];
|
| 67 |
-
let cr = ((c & 0xFF) as i32) * 0x100;
|
| 68 |
-
let cg = (((c >> 8) & 0xFF) as i32) * 0x100;
|
| 69 |
-
let cb = (((c >> 16) & 0xFF) as i32) * 0x100;
|
| 70 |
-
// Weighted perceptual distance: R*3 + G*5 + B*2
|
| 71 |
-
let dist = (r - cr).abs() * 3 + (g - cg).abs() * 5 + (b - cb).abs() * 2;
|
| 72 |
-
if dist == 0 {
|
| 73 |
-
return (idx as u8, 0);
|
| 74 |
-
}
|
| 75 |
-
if dist < best_dist {
|
| 76 |
-
best_dist = dist;
|
| 77 |
-
best_idx = idx as u8;
|
| 78 |
-
}
|
| 79 |
-
}
|
| 80 |
-
let error = if best_dist < i32::MAX {
|
| 81 |
-
(best_dist * 100) / 0x2FD00
|
| 82 |
-
} else {
|
| 83 |
-
100
|
| 84 |
-
};
|
| 85 |
-
(best_idx, error)
|
| 86 |
-
}
|
| 87 |
-
|
| 88 |
-
/// Read RGB color for a palette index, in 8.8 fixed-point format.
|
| 89 |
-
/// Returns (r, g, b) each in range 0..0xFF00.
|
| 90 |
-
fn read_color_fp(&self, idx: u8) -> (i32, i32, i32) {
|
| 91 |
-
let c = self.colors[idx as usize];
|
| 92 |
-
let r = ((c & 0xFF) as i32) << 8;
|
| 93 |
-
let g = (((c >> 8) & 0xFF) as i32) << 8;
|
| 94 |
-
let b = (((c >> 16) & 0xFF) as i32) << 8;
|
| 95 |
-
(r, g, b)
|
| 96 |
-
}
|
| 97 |
}
|
| 98 |
|
| 99 |
/// Compute the complex sky gradient for non-standard level heights.
|
|
|
|
| 52 |
}
|
| 53 |
None
|
| 54 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 55 |
}
|
| 56 |
|
| 57 |
/// Compute the complex sky gradient for non-standard level heights.
|