This repository has no description
0

Configure Feed

Select the types of activity you want to include in your feed.

✨ Canvas#debug_grid, Region#corners

+38
+13
src/geometry/region.rs
··· 57 57 .chain(left_edge) 58 58 } 59 59 60 + /// Corners of the region's outline 61 + /// Does _not_ match .bottomright() etc., since 62 + /// this method takes into account that the region is inclusive 63 + /// topleft, topright, bottomright, bottomleft 64 + pub fn corners(&self) -> [Point; 4] { 65 + [ 66 + self.topleft(), 67 + self.topright().translated(1, 0), 68 + self.bottomright().translated(1, 1), 69 + self.bottomleft().translated(0, 1), 70 + ] 71 + } 72 + 60 73 pub fn is_empty(&self) -> bool { 61 74 self.width() == 0 || self.height() == 0 62 75 }
+25
src/graphics/canvas.rs
··· 341 341 ) 342 342 } 343 343 344 + pub fn debug_grid(&mut self, color: Color) { 345 + let world = self.world_region.clone(); 346 + let layer = self.layer_or_empty("debug_plane"); 347 + 348 + let ymax = world.end.1 + 1; 349 + let xmax = world.end.0 + 1; 350 + 351 + // Vertical lines 352 + for Point(x, y) in world.iter() { 353 + layer.set( 354 + format!("grid_vertical_{x}"), 355 + Object::Line(Point(x, 0), Point(x, ymax), 1.0) 356 + .colored(color) 357 + .opacified(0.25), 358 + ); 359 + 360 + layer.set( 361 + format!("grid_horizontal_{y}"), 362 + Object::Line(Point(0, y), Point(xmax, y), 1.0) 363 + .colored(color) 364 + .opacified(0.25), 365 + ); 366 + } 367 + } 368 + 344 369 pub fn dimensions<T: From<usize>>(&self) -> (T, T) { 345 370 (self.width().into(), self.height().into()) 346 371 }