Click here to Skip to main content
15,997,727 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have a grid and grid contains an image. Grid bent on -52 degree on X Axis. this is rotated but not smoothly.

XAML code is:

HTML
<grid x:name="LayoutRootNew" grid.row="0" grid.columnspan="3" grid.rowspan="3" margin="11,40,0,0" verticalalignment="Top" xmlns:x="#unknown">
              
                
                <grid.projection>
                    <planeprojection rotationx="-51" />
                </grid.projection>
                

                <Image  Name="imgArrow1" Source="@../../Images/circle31mar.png" Stretch="Uniform" UseLayoutRounding="True"  Height="340" Width="340" HorizontalAlignment="Center" VerticalAlignment="Center">
                    <Image.Projection>
                        <planeprojection x:name="Image1Projection" centerofrotationx="0.5" centerofrotationy="0.5" />
                    </Image.Projection>
                    <Image.RenderTransform>
                        <rotatetransform x:name="Prize_ListWheel_Rotate">
                                     Angle="0" />
                    </Image.RenderTransform>
                 
                </Image>
                <Image Name="imgArrow2" Source="@../../Images/FRRingNew3.png" Margin="0,0,0,0" Height="222" Width="225" HorizontalAlignment="Center">
                    <Image.Projection>
                        <planeprojection x:name="Image1Projection2" centerofrotationx="0.5" centerofrotationy="0.5" />
                    </Image.Projection>
                </Image>

            </rotatetransform></grid>



.cs code is:

C#
_n = gameDataBO.FRRndNumber;         //Animation for red black Wheel
SessionManager.newrandom = _n;
             
// _n = SessionManager.rnno;

//-----new work start---------
randomnumber = _n;
animanglerot = 360.0 / Convert.ToDouble(itextmaxcount);
anglesteps = Convert.ToInt64((itextmaxcount * 2 * numberofrotations - 38) * anglefactor);

//----------new work end---------

imgArrow1.RenderTransformOrigin = new Point(0.5, 0.5);
imgArrow1.RenderTransform = new RotateTransform();

da = new DoubleAnimation();

da.From = 0;
da.To = -anglesteps;  //-360.00 * 1.9;// -(360.00 / 38.00);
anglesteps = anglesteps - 1;
Prize_ListWheel_Rotate.Angle += animanglerot / anglefactor;
//myDispatcherTimer.Interval = new TimeSpan(0, 0, 0, 0, 300); // 100 Milliseconds 
//myDispatcherTimer.Start();
da.Duration = TimeSpan.FromSeconds(2);

SineEase be = new SineEase();

be.EasingMode = EasingMode.EaseIn;
// da.EasingFunction = be;

_nRing = gameDataBO.FRRingRndNumber;     //Animation for Ring
SessionManager.newringrandom = _nRing;
_nRing = SessionManager.ringno;
imgArrow2.RenderTransformOrigin = new Point(0.5, 0.5);

imgArrow2.RenderTransform = new RotateTransform();
da2 = new DoubleAnimation();
da2.From = 0;
da2.To = 360.00 * 1;// +(360.00 / 38.00);
da2.Duration = TimeSpan.FromSeconds(2);
// da2.EasingFunction = be;

_netRotation = (_n + _nRing);

if (_netRotation > 38)
{
   _netRotation = (_netRotation % 38);
}

_finalAngle = _netRotation * (360.00 / 38.00);

Storyboard.SetTarget(da, imgArrow1.RenderTransform);
Storyboard.SetTarget(da2, imgArrow2.RenderTransform);
Storyboard.SetTargetProperty(da, new PropertyPath(RotateTransform.AngleProperty));
Storyboard.SetTargetProperty(da2, new PropertyPath(RotateTransform.AngleProperty));

sb1 = new Storyboard();
sb1.Children.Add(da);
sb1.Children.Add(da2);
sb1.Begin();
SessionManager.newsession = 0;



so i want to rotate that image along X axis clock wise for particular time period with different speed very smooth.
This works but roration is not smooth. i want to rotate my image as smooth. Please provide C# code for rotation.
Posted
Updated 13-May-14 1:33am
v5

1 solution

Smoothness is a matter of physiological retinian persistance, which for humans is about 0.04s.

So if you want to rotate you image smoothly within 7 seconds, it means you have to ensure a minimum number of steps, which in this case would be steps = 7 / 0.04 = 175. Which would mean a rotation angle of at most 360.0 / 175.0 = 2.057 degrees.

If you are experiencing flickering, that can mean two things:
- every step is displayed during a period larger than 0.04s
- or the graphic engine is not able to handle smoothly the number of rotations configured
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900