Skip to content

Commit

Permalink
Monochrome icons full SVG support I think
Browse files Browse the repository at this point in the history
Should color literally everything now.
Gradients, backgrounds, different written formats, etc
  • Loading branch information
Beinsezii committed Jul 21, 2023
1 parent 5c63ffd commit 481825c
Showing 1 changed file with 9 additions and 9 deletions.
18 changes: 9 additions & 9 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -273,15 +273,15 @@ fn monochromatize_svg(data: &mut [u8], color: Color32) {
let color = color.to_normalized_gamma_f32();
let color = [color[0], color[1], color[2]];
if let Ok(svg) = std::str::from_utf8_mut(data) {
let mut indicies: Vec<(usize, usize)> =
svg.match_indices("fill:#").map(|(i, _)| (i, 5)).collect();
indicies.append(
&mut svg
.match_indices("stroke:#")
.map(|(i, _)| (i, 7))
.collect::<Vec<(usize, usize)>>(),
);
// indicies.append(&mut svg.match_indices("stop-color=\"#").map(|(i, _)| (i, 12)).collect::<Vec<(usize, usize)>>());
let indicies: Vec<(usize, usize)> = svg
.match_indices("fill:#")
.chain(svg.match_indices("stroke:#"))
.chain(svg.match_indices("color:#"))
.chain(svg.match_indices("fill=\"#"))
.chain(svg.match_indices("stroke=\"#"))
.chain(svg.match_indices("color=\"#"))
.map(|(i, s)| (i, s.len() - 1))
.collect();

for (i, o) in indicies.into_iter() {
unsafe {
Expand Down

0 comments on commit 481825c

Please sign in to comment.