fn create_anchors_from_kurbo(&self, responses: &mut VecDeque<Message>) -> Vec<VectorAnchor> {
		// We need the indices paired with the kurbo path elements
		let indexed_elements = self.bez_path.elements().iter().enumerate().map(|(index, element)| (index, *element)).collect::<Vec<IndexedEl>>();

		// Create the manipulation points
		let mut anchors: Vec<VectorAnchor> = vec![];
		let (mut first_path_element, mut last_path_element): (Option<IndexedEl>, Option<IndexedEl>) = (None, None);
		let mut last_move_to_element: Option<IndexedEl> = None;
		let mut ended_with_close_path = false;
		let mut first_move_to_id: usize = 0;

		// TODO Consider using a LL(1) grammar to improve readability
		// Create an anchor at each join between two kurbo segments
		for elements in indexed_elements.windows(2) {
			let (_, current_element) = elements[0];
			let (_, next_element) = elements[1];
			ended_with_close_path = false;

			if matches!(current_element, kurbo::PathEl::ClosePath) {
				continue;
			}

			// An anchor cannot stradle a line / curve segment and a ClosePath segment
			if matches!(next_element, kurbo::PathEl::ClosePath) {
				ended_with_close_path = true;
				if self.closed {
					self.close_path(&mut anchors, first_move_to_id, first_path_element, last_path_element, last_move_to_element, responses);
				} else {
					anchors.push(self.create_anchor(last_path_element, None, responses));
				}
				continue;
			}

			// Keep track of the first and last elements of this shape
			if matches!(current_element, kurbo::PathEl::MoveTo(_)) {
				last_move_to_element = Some(elements[0]);
				first_path_element = Some(elements[1]);
				first_move_to_id = anchors.len();
			}
			last_path_element = Some(elements[1]);

			anchors.push(self.create_anchor(Some(elements[0]), Some(elements[1]), responses));
		}

		// If the path definition didn't include a ClosePath, we still need to behave as though it did
		if !ended_with_close_path {
			if self.closed {
				self.close_path(&mut anchors, first_move_to_id, first_path_element, last_path_element, last_move_to_element, responses);
			} else {
				anchors.push(self.create_anchor(last_path_element, None, responses));
			}
		}

		anchors
	}
/// Create the anchors from the kurbo path, only done during of new anchors construction
Create the anchors from the kurbo path, only done during of new anchors construction
Create the anchors from the kurbo path only done during of new anchors construction
fn create_anchors_from_kurbo(&self, responses: &mut VecDeque<Message>) -> Vec<VectorAnchor> {
		// We need the indices paired with the kurbo path elements
		let indexed_elements = self.bez_path.elements().iter().enumerate().map(|(index, element)| (index, *element)).collect::<Vec<IndexedEl>>();
		// Create the manipulation points
		let mut anchors: Vec<VectorAnchor> = vec![];
		let (mut first_path_element, mut last_path_element): (Option<IndexedEl>, Option<IndexedEl>) = (None, None);
		let mut last_move_to_element: Option<IndexedEl> = None;
		let mut ended_with_close_path = false;
		let mut first_move_to_id: usize = 0;
		// TODO Consider using a LL(1) grammar to improve readability
		// Create an anchor at each join between two kurbo segments
		for elements in indexed_elements.windows(2) {
			let (_, current_element) = elements[0];
			let (_, next_element) = elements[1];
			ended_with_close_path = false;
			if matches!(current_element, kurbo::PathEl::ClosePath) {
				continue;
			}
			// An anchor cannot stradle a line / curve segment and a ClosePath segment
			if matches!(next_element, kurbo::PathEl::ClosePath) {
				ended_with_close_path = true;
				if self.closed {
					self.close_path(&mut anchors, first_move_to_id, first_path_element, last_path_element, last_move_to_element, responses);
				} else {
					anchors.push(self.create_anchor(last_path_element, None, responses));
				}
				continue;
			}
			// Keep track of the first and last elements of this shape
			if matches!(current_element, kurbo::PathEl::MoveTo(_)) {
				last_move_to_element = Some(elements[0]);
				first_path_element = Some(elements[1]);
				first_move_to_id = anchors.len();
			}
			last_path_element = Some(elements[1]);
			anchors.push(self.create_anchor(Some(elements[0]), Some(elements[1]), responses));
		}
		// If the path definition didn't include a ClosePath, we still need to behave as though it did
		if !ended_with_close_path {
			if self.closed {
				self.close_path(&mut anchors, first_move_to_id, first_path_element, last_path_element, last_move_to_element, responses);
			} else {
				anchors.push(self.create_anchor(last_path_element, None, responses));
			}
		}
		anchors
	}
fn create_anchors_from_kurbo ( & self , responses : & mut VecDeque < Message > ) -> Vec < VectorAnchor > { // We need the indices paired with the kurbo path elements let indexed_elements = self . bez_path . elements ( ) . iter ( ) . enumerate ( ) . map ( | ( index , element ) | ( index , * element ) ) . collect :: < Vec < IndexedEl > > ( ) ; // Create the manipulation points let mut anchors : Vec < VectorAnchor > = vec ! [ ] ; let ( mut first_path_element , mut last_path_element ) : ( Option < IndexedEl > , Option < IndexedEl > ) = ( None , None ) ; let mut last_move_to_element : Option < IndexedEl > = None ; let mut ended_with_close_path = false ; let mut first_move_to_id : usize = 0 ; // TODO Consider using a LL(1) grammar to improve readability // Create an anchor at each join between two kurbo segments for elements in indexed_elements . windows ( 2 ) { let ( _ , current_element ) = elements [ 0 ] ; let ( _ , next_element ) = elements [ 1 ] ; ended_with_close_path = false ; if matches ! ( current_element kurbo PathEl ClosePath ) { continue ; } // An anchor cannot stradle a line / curve segment and a ClosePath segment if matches ! ( next_element kurbo PathEl ClosePath ) { ended_with_close_path = true ; if self . closed { self . close_path ( & mut anchors , first_move_to_id , first_path_element , last_path_element , last_move_to_element , responses ) ; } else { anchors . push ( self . create_anchor ( last_path_element , None , responses ) ) ; } continue ; } // Keep track of the first and last elements of this shape if matches ! ( current_element kurbo PathEl MoveTo ( ) ) { last_move_to_element = Some ( elements [ 0 ] ) ; first_path_element = Some ( elements [ 1 ] ) ; first_move_to_id = anchors . len ( ) ; } last_path_element = Some ( elements [ 1 ] ) ; anchors . push ( self . create_anchor ( Some ( elements [ 0 ] ) , Some ( elements [ 1 ] ) , responses ) ) ; } // If the path definition didn't include a ClosePath, we still need to behave as though it did if ! ended_with_close_path { if self . closed { self . close_path ( & mut anchors , first_move_to_id , first_path_element , last_path_element , last_move_to_element , responses ) ; } else { anchors . push ( self . create_anchor ( last_path_element , None , responses ) ) ; } } anchors }
Create the anchors from the kurbo path, only done during of new anchors construction
Create the anchors from the kurbo path only done during of new anchors construction
&self
responses
&mut VecDeque<Message>
&self
responses
&mut VecDeque<Message>