Skip to main content

kurbo_material_icons/
lib.rs

1//! This library includes icons from Google's [material design icons
2//! repository](https://github.com/google/material-design-icons).
3
4use kurbo::{PathEl, Point, Rect, Shape, Size};
5
6/// Material icons as kurbo paths
7#[derive(Debug, Copy, Clone)]
8pub struct IconPaths {
9    pub paths: &'static [IconPath],
10    pub size: Size,
11}
12
13#[derive(Debug, Copy, Clone)]
14pub struct IconPath {
15    pub els: &'static [PathEl],
16    pub opacity: f64,
17}
18
19impl Shape for IconPath {
20    type PathElementsIter<'a> = std::iter::Copied<std::slice::Iter<'static, PathEl>>;
21    fn path_elements(&self, _tolerance: f64) -> Self::PathElementsIter<'_> {
22        self.els.iter().copied()
23    }
24
25    fn area(&self) -> f64 {
26        self.els.area()
27    }
28
29    fn perimeter(&self, accuracy: f64) -> f64 {
30        self.els.perimeter(accuracy)
31    }
32
33    fn winding(&self, pt: Point) -> i32 {
34        self.els.winding(pt)
35    }
36    fn bounding_box(&self) -> Rect {
37        self.els.bounding_box()
38    }
39
40    fn as_path_slice(&self) -> Option<&[PathEl]> {
41        Some(self.els)
42    }
43}
44
45mod icon_paths;
46pub use icon_paths::normal as icons;