|
|
@@ -1,4 +1,4 @@
|
|
1
|
|
-use coord::{ScreenRect, SubTileCoord, TileCoord};
|
|
|
1
|
+use coord::{ScreenRect, SubTileCoord, TileCoord, TextureRect};
|
|
2
|
2
|
use linked_hash_map::LinkedHashMap;
|
|
3
|
3
|
use map_view::VisibleTile;
|
|
4
|
4
|
use std::collections::HashMap;
|
|
|
@@ -8,37 +8,6 @@ use tile::Tile;
|
|
8
|
8
|
use tile_cache::TileCache;
|
|
9
|
9
|
use tile_source::TileSource;
|
|
10
|
10
|
|
|
11
|
|
-#[derive(Copy, Clone, Debug)]
|
|
12
|
|
-pub struct TextureRect {
|
|
13
|
|
- pub x1: f64,
|
|
14
|
|
- pub y1: f64,
|
|
15
|
|
- pub x2: f64,
|
|
16
|
|
- pub y2: f64,
|
|
17
|
|
-}
|
|
18
|
|
-
|
|
19
|
|
-impl TextureRect {
|
|
20
|
|
- pub fn inset(self, margin_x: f64, margin_y: f64) -> TextureRect {
|
|
21
|
|
- TextureRect {
|
|
22
|
|
- x1: self.x1 + margin_x,
|
|
23
|
|
- y1: self.y1 + margin_y,
|
|
24
|
|
- x2: self.x2 - margin_x,
|
|
25
|
|
- y2: self.y2 - margin_y,
|
|
26
|
|
- }
|
|
27
|
|
- }
|
|
28
|
|
-
|
|
29
|
|
- pub fn subdivide(&self, sub_tile: &SubTileCoord) -> TextureRect {
|
|
30
|
|
- let scale = 1.0 / f64::from(sub_tile.size);
|
|
31
|
|
- let w = (self.x2 - self.x1) * scale;
|
|
32
|
|
- let h = (self.y2 - self.y1) * scale;
|
|
33
|
|
- TextureRect {
|
|
34
|
|
- x1: self.x1 + f64::from(sub_tile.x) * w,
|
|
35
|
|
- y1: self.y1 + f64::from(sub_tile.y) * h,
|
|
36
|
|
- x2: self.x1 + f64::from(sub_tile.x + 1) * w,
|
|
37
|
|
- y2: self.y1 + f64::from(sub_tile.y + 1) * h,
|
|
38
|
|
- }
|
|
39
|
|
- }
|
|
40
|
|
-}
|
|
41
|
|
-
|
|
42
|
11
|
#[derive(Clone, Debug)]
|
|
43
|
12
|
pub struct TexturedVisibleTile {
|
|
44
|
13
|
pub screen_rect: ScreenRect,
|