3

I need to pan an image at a preset Scale level (no zoom). When panning from left to right, I need the left-side of the image to disappear as the leading right edge appears. This would give the image the appearance of a video as the camera pans the scene. What I've done so far:

double origX = 0.0;
double origY = 0.5;
double newx;
double newy;

image1.RenderTransformOrgin = new Point(origX, origY);

image1.RenderTransform = new ScaleTransform(2.0, 2.0);

if (newX == 0.0)
{
 image1.RenderTransformOrgin = new Point(origX, origY);
}
else
{
 image1.RenderTransformOrgin = new Point(newX, newY);
}

Using this code I am able to start the virtual "camera lens" on the left and then move it to any other point of the image. By manually increasing newX's value incrementally I am able to create the effect I need. My question is how best to increase the newX value to produce a smooth, animated appearance? Thank You.

Rick P
  • 31
  • 2
  • What you mean how to increase? In wpf we have animations, you just have to setup it properly. Try [animating](http://stackoverflow.com/a/31548743/1997232) `XProperty` of `TranslateTranform` (use `DoubleAnimation` with `ElasticEasy`). – Sinatr Jan 08 '16 at 16:08
  • I have tried getting TranslateTransform and PointAnimation using DoubleAnimation to work, but have had little success. My best attempt only produced a pan of a small segment of the image. This may very well be due to my skill level and knowledge - not the method suggested. – Rick P Jan 08 '16 at 17:48
  • By increase, I mean to constantly increase the value of newX steadily from 0.00 to 0.01 to 0.02 until reaching 0.99. – Rick P Jan 08 '16 at 17:55
  • Read more about [animations](https://msdn.microsoft.com/library/ms752312(v=vs.100).aspx). What you are trying to do is a *manual* animation (the worst, rarely unavoidable). [This](http://stackoverflow.com/a/12551856/1997232) should help (replace `ScaleTransform` with `TranslateTransform`). – Sinatr Jan 11 '16 at 08:04

0 Answers0