开发者

How to set shape.Position without creating new Point objects in WPF?

开发者 https://www.devze.com 2023-02-26 05:34 出处:网络
I have 1000s shapes whose StartPoint, EndPoint, Center, etc is being set 30 times per second but the only way to do this is to create a new Point each time, since System.Windows.Point is a struct so I

I have 1000s shapes whose StartPoint, EndPoint, Center, etc is being set 30 times per second but the only way to do this is to create a new Point each time, since System.Windows.Point is a struct so I can't do this开发者_开发知识库:

shape.Center.X = x;

And there is not even a SetCenter, etc method to solve this.

Any ideas on how to do this?


Why don't you want to create new Points?

They're simple value types, no memory or performance issues that I can see.


Use TranslateTransform to place the shapes. Use the RenderTransformOrigin to set the 'center'.

EDIT

RenderTransforms can be accelerated by the GPU. You wouldn't add a transformation each frame but add just one and change its properties over time. See BitmapCache and this is also quite interesting

0

精彩评论

暂无评论...
验证码 换一张
取 消