maplibre/legacy/
image_atlas.rs1use std::collections::HashMap;
4
5use crate::{
6 euclid::Rect,
7 legacy::{
8 image::{
9 Image, ImageContent, ImageManager, ImageMap, ImageStretches, ImageVersionMap,
10 PremultipliedImage,
11 },
12 TileSpace,
13 },
14};
15
16#[derive(Clone)]
18pub struct ImagePosition {
19 pub pixel_ratio: f64,
20 pub padded_rect: Rect<u16, TileSpace>,
21 pub version: u32,
22 pub stretch_x: ImageStretches,
23 pub stretch_y: ImageStretches,
24 pub content: Option<ImageContent>,
25}
26impl ImagePosition {
27 pub const PADDING: u16 = 1;
28
29 pub fn tl(&self) -> [u16; 2] {
31 [
32 (self.padded_rect.min().x + Self::PADDING),
33 (self.padded_rect.min().y + Self::PADDING),
34 ]
35 }
36
37 pub fn br(&self) -> [u16; 2] {
39 [
40 (self.padded_rect.min().x + self.padded_rect.width() - Self::PADDING),
41 (self.padded_rect.min().y + self.padded_rect.height() - Self::PADDING),
42 ]
43 }
44
45 pub fn tlbr(&self) -> [u16; 4] {
47 let _tl = self.tl();
48 let _br = self.br();
49 [_tl[0], _tl[1], _br[0], _br[1]]
50 }
51
52 pub fn display_size(&self) -> [f64; 2] {
54 [
55 (self.padded_rect.width() - Self::PADDING * 2) as f64 / self.pixel_ratio,
56 (self.padded_rect.height() - Self::PADDING * 2) as f64 / self.pixel_ratio,
57 ]
58 }
59}
60
61pub type ImagePositions = HashMap<String, ImagePosition>;
63
64pub struct ImagePatch {
66 image: Image,
67 padded_rect: Rect<u16, TileSpace>,
68}
69
70impl ImagePatch {}
71
72pub struct ImageAtlas {
74 image: PremultipliedImage,
75 icon_positions: ImagePositions,
76 pattern_positions: ImagePositions,
77}
78impl ImageAtlas {
79 pub fn get_image_patches_and_update_versions(image_manager: &ImageManager) -> Vec<ImagePatch> {
81 todo!()
82 }
83}
84
85pub fn make_image_atlas(
87 image_map_a: &ImageMap,
88 image_map_b: &ImageMap,
89 version_map: &ImageVersionMap,
90) -> ImageAtlas {
91 todo!()
92}