I am wondering if someone managed to override the default WPF rendering behavior when applying the scaletransform form to the form. The default behavior converts the entire figure of the figure, including strokes, but I would only like to scale the geometry. The difficulty is that my figures are in a visual hierarchy with visual transformations applied at different levels (like a 2D scene graphic, but a WPF visual tree), I cannot change this (!). I read in various places that it is possible to create a custom shape to undo the transformation to transform the visualization and put it in the geometry. At the moment, I have something like:
public sealed class MyPath : Shape {
As you can clearly see, I'm completely new to this, and the code above is probably completely messed up. I tried to transfer the matrix into geometry without changing the final geometry transformation, so tr.Value * tr.Value and trInv. But it does not work as I want. I know that this transfer conversion technology works in theory because I tried it with constant conversions (testing to set Geometry.Transform to scale x from 4 and clicking on the conversion to x scale from 0.25 worked fine, but the resulting form drawing , it seems stretch = fill was not applied, which I will describe). So there must be something that I am missing with visual transformations.
A testing scenario that does not work is as follows:
- I am applying scaled rendering conversion with scaleX = 4 and scaleY = 1 in xaml.
- The built-in Path class scales the entire drawing so that the strokes are 4 times wider in the x direction than in the y direction.
- I want MyPath to scale only geometry, not strokes. <- THIS DOES NOT WORK!
- What happens: the geometry scales correctly, the strokes scale by 4 in the x direction and slightly less than 4 in the y direction. What's wrong? I have the feeling that I should not work only with RenderedGeometry.Transform, but what should I use instead? I need to enable rendering and stretch = fill out the form. My rendering transform hierarchy may contain a combination of scales, rotations, and translations, so the solution should be general enough to handle any transform, not just axis scaling.
Note. I know that creating geometry in OnRender is bad, but I want it to work before I spend time cleaning it.
By the way, I read this post:
Invariant stroke stroke thickness regardless of scale
The problem that was mentioned above is that I have to accept visualization transformations, and I'm not sure how to adapt this solution to work with them.
source share