Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to change x,y origin of canvas to bottom left and flip the y coordinates?

I have a bunch of data points that I would like to two-way bind to points on a canvas.

The points assume larger y values are reflected in an upwards direction like most math graphs.

How do I change the x,y origin of the canvas to the bottom left corner and reverse it's interpretation of the y coordinate?

(I would like to stay in XAML)

like image 542
David Smith Avatar asked Jul 27 '09 00:07

David Smith


2 Answers

<Canvas>
    <Canvas.LayoutTransform>
        <ScaleTransform ScaleX="1" ScaleY="-1" CenterX=".5" CenterY=".5" />
    </Canvas.LayoutTransform>
</Canvas>
like image 52
kenwarner Avatar answered Nov 03 '22 06:11

kenwarner


I tried the ScaleTransform method extensively: It does not work. It only shifts one of the 2 coordinates, never both. This, however, works as advertised:

<Canvas Name="myCanvas" Width="0" Height="0" RenderTransform="1 0 0 -1 0 0"
    HorizontalAlignment="Center" VerticalAlignment="Center" >
like image 3
Travis Banger Avatar answered Nov 03 '22 05:11

Travis Banger