This repository has no description
0

Configure Feed

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

✨ Add Layer#objects_in and Layer#object_at

+19 -1
+19 -1
src/graphics/layer.rs
··· 1 - use crate::{ColoredObject, Fill, Filter, ObjectSizes, Region, Toggleable}; 1 + use crate::{ 2 + ColoredObject, Fill, Filter, ObjectSizes, Point, Region, Toggleable, 3 + }; 2 4 use std::{collections::HashMap, fmt::Display}; 3 5 4 6 #[derive(Debug, Clone, Default)] ··· 39 41 pub fn safe_object(&mut self, name: &str) -> Option<&mut ColoredObject> { 40 42 self.objects.get_mut(name) 41 43 } 44 + 45 + pub fn objects_in( 46 + &mut self, 47 + region: Region, 48 + ) -> impl Iterator<Item = (&String, &mut ColoredObject)> { 49 + self.objects 50 + .iter_mut() 51 + .filter(move |(_, obj)| obj.object.region().within(&region)) 52 + } 53 + 54 + pub fn object_at(&mut self, point: Point) -> Option<&mut ColoredObject> { 55 + self.objects 56 + .values_mut() 57 + .find(|obj| obj.object.region().start == point) 58 + } 59 + 42 60 // Remove all objects. 43 61 pub fn clear(&mut self) { 44 62 self.objects.clear();