application.GetScene().Add(actor);
SpringData springData{100.0f, 10.0f, 1.0f};
- float convergeDuration = SpringData::GetDuration(springData);
+ float convergeDuration = springData.GetDuration();
DALI_TEST_CHECK(convergeDuration < 2.0f);
tet_printf("convergeDuration : %f\n", convergeDuration);
- Animation animation = Animation::New(convergeDuration);
+ Animation animation = Animation::New(convergeDuration);
animation.AnimateTo(Property(actor, Dali::Actor::Property::POSITION_X), 100.0f, AlphaFunction(springData));
animation.Play();
application.GetScene().Add(actor);
SpringData springData{80.0f, 20.0f, 1.0f};
- float convergeDuration = SpringData::GetDuration(springData);
+ float convergeDuration = springData.GetDuration();
DALI_TEST_CHECK(convergeDuration > 0.0f);
Animation animation = Animation::New(convergeDuration);
application.GetScene().Add(actor);
SpringData springData{600.0f, 15.0f, 1.0f};
- float convergeDuration = SpringData::GetDuration(springData);
+ float convergeDuration = springData.GetDuration();
DALI_TEST_CHECK(convergeDuration > 0.0f);
tet_printf("convergeDuration : %f\n", convergeDuration);
{
}
-AlphaFunction::AlphaFunction(Dali::SpringData springData)
+AlphaFunction::AlphaFunction(const Dali::SpringData& springData)
: mMode(CUSTOM_SPRING),
mBuiltin(DEFAULT),
mSpringData(springData)
BOUNCY,
/**
- * @brief Slow spring. Smooth and relaxed motion with longer settling
+ * @brief Slow spring. Smooth and relaxed motion with longer settling.
* @SINCE_2_4.17
*/
SLOW
* that the value will exactly reach 1 at the end of the animation duration.
* To ensure the animation ends at 1, you may need to adjust the duration according to the spring configuration.
*/
- AlphaFunction(Dali::SpringData springData);
+ AlphaFunction(const Dali::SpringData& springData);
/**
* @brief Returns the control points of the alpha function.
{
}
-float SpringData::GetDuration(const SpringData& springData)
+float SpringData::GetDuration()
{
- if(springData.stiffness < MIN_STIFFNESS || springData.damping < MIN_DAMPING || springData.mass < MIN_MASS)
+ if(stiffness < MIN_STIFFNESS || damping < MIN_DAMPING || mass < MIN_MASS)
{
return 0.0f;
}
- double stiffness = static_cast<double>(springData.stiffness);
- double damping = static_cast<double>(springData.damping);
- double mass = static_cast<double>(springData.mass);
-
- double omega0 = std::sqrt(stiffness / mass);
- double zeta = damping / (2.0 * std::sqrt(stiffness * mass));
+ double omega0 = std::sqrt(static_cast<double>(stiffness) / static_cast<double>(mass));
+ double zeta = static_cast<double>(damping) / (2.0 * std::sqrt(static_cast<double>(stiffness) * static_cast<double>(mass)));
double time = 0.0;
if(zeta < 1.0)
float mass; ///< Mass of the object. Affects inertia and the duration of the motion. Minimum value is 0.1.
/**
- * @brief Returns the time in seconds it takes for a Spring Animation to converge based on the input SpringData.
- * The maximum value for the returned duration is 100 secons.
+ * @brief Returns the time in seconds it takes for a Spring Animation to converge based on the SpringData.
+ * The maximum value for the returned duration is 100 seconds.
* Since this value is calculated in an incremental manner, it may take longer if used frequently.
*
- * @SINCE_2_4.17
+ * @SINCE_2_4.18
+ * @return Expected duration for input springData.
*/
- static float GetDuration(const SpringData& springData);
+ float GetDuration();
};
/**