Quantcast
Channel: Windows Presentation Foundation (WPF) forum
Viewing all articles
Browse latest Browse all 18858

ScaleTransform causing translation??

$
0
0

Hello all:

I'm experimenting with transforms and am seeing a strange result that I'm sure has a simple explanation (which I can't figure out).

I'm drawing a rectangle on an InkCanvas. The rectangle is centered around the point where a user clicks, as in:

Path RectangleShape = new Path();
Path.Data = new RectangleGeometry(new rect(UpperLeftPoint, LowerRightPoint));

This works, and when I click the canvas I see the rectangle. Now, I tried to uniformly scale the rectangle down a little about it's center:

ScaleTransform scaleTransform = new ScaleTransform();
scaleTransform.ScaleX = 0.55;
scaleTransform.ScaleY = 0.55;

RectangleShape.RenderTransform = scaleTransform;
RectangleShape.RenderTransformOrigin = new Point(0.5, 0.5);
The rectangle did appear smaller, but to my surprise it was also translated to the left and up. What accounts for this translation? Am I missing something? Thanks in advance.


Viewing all articles
Browse latest Browse all 18858

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>