Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

WPF: How to apply a GeneralTransform to a Geometry data and return the new geometry?

Having some Geometry data and a Transform how can the transform be applied to the Geometry to get a new Geometry with it's data transformed ?

Ex: I Have a Path object that has it's Path.Data set to a PathGeometry object, I want to tranform the points of the PathGeometry object in place using a transform, and not apply a transform to the PathGeometry that will be used at render time.

P.S. I know that the Transform class has a method Point Transform.Transform(Point p) that can be used to transform a Point but...is there a way to transform a arbitrary geometry at once?

Edit: See my repply for a currently found solution

like image 823
Pop Catalin Avatar asked Oct 30 '08 12:10

Pop Catalin


1 Answers

I've found a solution with which arbitrary tranform can be applied to a path geometry, thanks to Todd White's answer:

Basically Geometry.Combine is used to combine the desired geometry with Geometry.Empty using Union, and the desired transform is given. The resulting geometry is transformed with the given transform.

PathGeometry geometryTransformed = Geometry.Combine(Geometry.Empty, geometry, GeometryCombineMode.Union, transform);
like image 156
Pop Catalin Avatar answered Sep 30 '22 05:09

Pop Catalin