mirror of
https://github.com/penpot/penpot.git
synced 2025-07-24 05:47:19 +02:00
🎉 Sort viewport tiles by distance to center
This commit is contained in:
parent
b6c4376217
commit
8a8d89dfc0
2 changed files with 15 additions and 3 deletions
|
@ -5,9 +5,15 @@ use skia_safe as skia;
|
|||
use std::collections::{HashMap, HashSet};
|
||||
|
||||
pub type Tile = (i32, i32);
|
||||
pub type TileWithDistance = (i32, i32, i32);
|
||||
|
||||
pub const TILE_SIZE: f32 = 512.;
|
||||
|
||||
// @see https://en.wikipedia.org/wiki/Taxicab_geometry
|
||||
pub fn manhattan_distance(a: (i32, i32), b: (i32, i32)) -> i32 {
|
||||
(a.0 - b.0).abs() + (a.1 - b.1).abs()
|
||||
}
|
||||
|
||||
pub fn get_tile_dimensions() -> skia::ISize {
|
||||
(TILE_SIZE as i32, TILE_SIZE as i32).into()
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue