fn create_outline(document_layer_path: Vec<LayerId>, overlay_path: Option<Vec<LayerId>>, document: &DocumentMessageHandler, responses: &mut VecDeque<Message>) -> Option<Vec<LayerId>> {
		// Get layer data
		let document_layer = document.graphene_document.layer(&document_layer_path).ok()?;

		// Get the bezpath from the shape or text
		let path = match &document_layer.data {
			LayerDataType::Shape(shape) => Some(shape.path.clone()),
			LayerDataType::Text(text) => Some(text.to_bez_path_nonmut(&document.graphene_document.font_cache)),
			_ => document_layer
				.aabounding_box_for_transform(DAffine2::IDENTITY, &document.graphene_document.font_cache)
				.map(|bounds| kurbo::Rect::new(bounds[0].x, bounds[0].y, bounds[1].x, bounds[1].y).to_path(0.)),
		}?;

		// Generate a new overlay layer if necessary
		let overlay = match overlay_path {
			Some(path) => path,
			None => {
				let overlay_path = vec![generate_uuid()];
				let operation = Operation::AddOverlayShape {
					path: overlay_path.clone(),
					bez_path: BezPath::new(),
					style: style::PathStyle::new(Some(Stroke::new(COLOR_ACCENT, PATH_OUTLINE_WEIGHT)), Fill::None),
					closed: false,
				};

				responses.push_back(DocumentMessage::Overlays(operation.into()).into());

				overlay_path
			}
		};

		// Update the shape bezpath
		let operation = Operation::SetShapePath {
			path: overlay.clone(),
			bez_path: path,
		};
		responses.push_back(DocumentMessage::Overlays(operation.into()).into());

		// Update the transform to match the document
		let operation = Operation::SetLayerTransform {
			path: overlay.clone(),
			transform: document.graphene_document.multiply_transforms(&document_layer_path).unwrap().to_cols_array(),
		};
		responses.push_back(DocumentMessage::Overlays(operation.into()).into());

		Some(overlay)
	}
/// Creates an outline of a layer either with a pre-existing overlay or by generating a new one
Creates an outline of a layer either with a pre-existing overlay or by generating a new one
Creates an outline of a layer either with a pre - existing overlay or by generating a new one
fn create_outline(document_layer_path: Vec<LayerId>, overlay_path: Option<Vec<LayerId>>, document: &DocumentMessageHandler, responses: &mut VecDeque<Message>) -> Option<Vec<LayerId>> {
		// Get layer data
		let document_layer = document.graphene_document.layer(&document_layer_path).ok()?;
		// Get the bezpath from the shape or text
		let path = match &document_layer.data {
			LayerDataType::Shape(shape) => Some(shape.path.clone()),
			LayerDataType::Text(text) => Some(text.to_bez_path_nonmut(&document.graphene_document.font_cache)),
			_ => document_layer
				.aabounding_box_for_transform(DAffine2::IDENTITY, &document.graphene_document.font_cache)
				.map(|bounds| kurbo::Rect::new(bounds[0].x, bounds[0].y, bounds[1].x, bounds[1].y).to_path(0.)),
		}?;
		// Generate a new overlay layer if necessary
		let overlay = match overlay_path {
			Some(path) => path,
			None => {
				let overlay_path = vec![generate_uuid()];
				let operation = Operation::AddOverlayShape {
					path: overlay_path.clone(),
					bez_path: BezPath::new(),
					style: style::PathStyle::new(Some(Stroke::new(COLOR_ACCENT, PATH_OUTLINE_WEIGHT)), Fill::None),
					closed: false,
				};
				responses.push_back(DocumentMessage::Overlays(operation.into()).into());
				overlay_path
			}
		};
		// Update the shape bezpath
		let operation = Operation::SetShapePath {
			path: overlay.clone(),
			bez_path: path,
		};
		responses.push_back(DocumentMessage::Overlays(operation.into()).into());
		// Update the transform to match the document
		let operation = Operation::SetLayerTransform {
			path: overlay.clone(),
			transform: document.graphene_document.multiply_transforms(&document_layer_path).unwrap().to_cols_array(),
		};
		responses.push_back(DocumentMessage::Overlays(operation.into()).into());
		Some(overlay)
	}
fn create_outline ( document_layer_path : Vec < LayerId > , overlay_path : Option < Vec < LayerId > > , document : & DocumentMessageHandler , responses : & mut VecDeque < Message > ) -> Option < Vec < LayerId > > { // Get layer data let document_layer = document . graphene_document . layer ( & document_layer_path ) . ok ( ) ? ; // Get the bezpath from the shape or text let path = match & document_layer . data { LayerDataType :: Shape ( shape ) => Some ( shape . path . clone ( ) ) , LayerDataType :: Text ( text ) => Some ( text . to_bez_path_nonmut ( & document . graphene_document . font_cache ) ) , _ => document_layer . aabounding_box_for_transform ( DAffine2 :: IDENTITY , & document . graphene_document . font_cache ) . map ( | bounds | kurbo :: Rect :: new ( bounds [ 0 ] . x , bounds [ 0 ] . y , bounds [ 1 ] . x , bounds [ 1 ] . y ) . to_path ( 0. ) ) , } ? ; // Generate a new overlay layer if necessary let overlay = match overlay_path { Some ( path ) => path , None => { let overlay_path = vec ! [ generate_uuid ( ) ] ; let operation = Operation :: AddOverlayShape { path : overlay_path . clone ( ) , bez_path : BezPath :: new ( ) , style : style :: PathStyle :: new ( Some ( Stroke :: new ( COLOR_ACCENT , PATH_OUTLINE_WEIGHT ) ) , Fill :: None ) , closed : false , } ; responses . push_back ( DocumentMessage :: Overlays ( operation . into ( ) ) . into ( ) ) ; overlay_path } } ; // Update the shape bezpath let operation = Operation :: SetShapePath { path : overlay . clone ( ) , bez_path : path , } ; responses . push_back ( DocumentMessage :: Overlays ( operation . into ( ) ) . into ( ) ) ; // Update the transform to match the document let operation = Operation :: SetLayerTransform { path : overlay . clone ( ) , transform : document . graphene_document . multiply_transforms ( & document_layer_path ) . unwrap ( ) . to_cols_array ( ) , } ; responses . push_back ( DocumentMessage :: Overlays ( operation . into ( ) ) . into ( ) ) ; Some ( overlay ) }
Creates an outline of a layer either with a pre-existing overlay or by generating a new one
Creates an outline of a layer either with a pre - existing overlay or by generating a new one
document_layer_path
Vec<LayerId>
overlay_path
Option<Vec<LayerId>>
document
&DocumentMessageHandler
responses
&mut VecDeque<Message>
document_layer_path
Vec<LayerId>
overlay_path
Option<Vec<LayerId>>
document
&DocumentMessageHandler
responses
&mut VecDeque<Message>