This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| const DIV: u32 = 8; | |
| pub fn tesselate( | |
| image: &DynamicImage, | |
| sites: &Vec<(u32, u32)>, | |
| ) -> image::ImageBuffer<Rgb<u8>, Vec<u8>> { | |
| let (width, height) = image.dimensions(); | |
| // Create a mapping between a voronoi region and color | |
| let mut site_colors: HashMap<(u32, u32), Rgb<u8>> = HashMap::new(); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // Utilities | |
| type TrimStart<String extends string> = String extends ` ${infer R}` ? TrimStart<R> : String; | |
| type TrimEnd<String extends string> = String extends `${infer R} ` ? TrimEnd<R> : String; | |
| type Trim<String extends string> = TrimEnd<TrimStart<String>> | |
| type Head<Array extends any[]> = Array[0] | |
| type Tail<Array extends any[]> = | |
| ((...a: Array) => void) extends (h: any, ...rest: infer Tail) => void ? Tail : never; | |
| type MergeArrayOfObjects<T extends object[]> = T[1] extends undefined | |
| ? Head<T> |
OlderNewer