const float BUTTON_TITLE_LABEL_Y_OFFSET = 0.05f;
const float ORIENTATION_DURATION = 0.5f; ///< Time to rotate to new orientation.
-} // unnamed namespace
+/**
+ * @brief Load an image, scaled-down to no more than the dimensions passed in.
+ *
+ * Uses ImageAttributes::ShrinkToFit which ensures the resulting image is
+ * smaller than or equal to the specified dimensions while preserving its
+ * original aspect ratio.
+ */
+ResourceImage LoadImageFittedInBox( const char * const imagePath, uint32_t maxWidth, uint32_t maxHeight )
+{
+ // Load the image nicely scaled-down to fit within the specified max width and height:
+ ImageAttributes attributes;
+ attributes.SetSize( maxWidth, maxHeight);
+ attributes.SetFilterMode( ImageAttributes::BoxThenLinear );
+ attributes.SetScalingMode( ImageAttributes::ShrinkToFit );
+ return ResourceImage::New( imagePath, attributes );
+}
+} // unnamed namespace
//
// Motion blurred actor
//
- Image image = ResourceImage::New( MOTION_BLUR_ACTOR_IMAGE1 );
+ // Scale down actor to fit on very low resolution screens with space to interact:
+ Size stageSize = Stage::GetCurrent().GetSize();
+ mMotionBlurActorSize = Size( std::min( stageSize.x * 0.3f, MOTION_BLUR_ACTOR_WIDTH ), std::min( stageSize.y * 0.3f, MOTION_BLUR_ACTOR_HEIGHT ) );
+ mMotionBlurActorSize = Size( std::min( mMotionBlurActorSize.x, mMotionBlurActorSize.y ), std::min( mMotionBlurActorSize.x, mMotionBlurActorSize.y ) );
+
+ Image image = LoadImageFittedInBox( MOTION_BLUR_ACTOR_IMAGE1, mMotionBlurActorSize.x, mMotionBlurActorSize.y );
mMotionBlurImageActor = ImageActor::New(image);
mMotionBlurImageActor.SetParentOrigin( ParentOrigin::CENTER );
- mMotionBlurImageActor.SetSize(MOTION_BLUR_ACTOR_WIDTH, MOTION_BLUR_ACTOR_HEIGHT);
+ mMotionBlurImageActor.SetSize(mMotionBlurActorSize.x, mMotionBlurActorSize.y);
mContentLayer.Add( mMotionBlurImageActor );
mMotionBlurImageActor2 = ImageActor::New(image);
mMotionBlurImageActor2.SetParentOrigin( ParentOrigin::CENTER );
- mMotionBlurImageActor2.SetSize(MOTION_BLUR_ACTOR_WIDTH, MOTION_BLUR_ACTOR_HEIGHT);
- mMotionBlurImageActor2.SetPosition(MOTION_BLUR_ACTOR_WIDTH * 1.1f, 0.0f);
+ mMotionBlurImageActor2.SetSize(mMotionBlurActorSize.x, mMotionBlurActorSize.y);
+ mMotionBlurImageActor2.SetPosition(mMotionBlurActorSize.x * 1.1f, 0.0f);
mMotionBlurImageActor.Add( mMotionBlurImageActor2 );
// Create shader used for doing motion blur
mMotionBlurImageActor3 = ImageActor::New(image);
mMotionBlurImageActor3.SetParentOrigin( ParentOrigin::CENTER );
- mMotionBlurImageActor3.SetSize(MOTION_BLUR_ACTOR_WIDTH, MOTION_BLUR_ACTOR_HEIGHT);
- mMotionBlurImageActor3.SetPosition(-MOTION_BLUR_ACTOR_WIDTH * 1.1f, 0.0f);
+ mMotionBlurImageActor3.SetSize(mMotionBlurActorSize.x, mMotionBlurActorSize.y);
+ mMotionBlurImageActor3.SetPosition(-mMotionBlurActorSize.x * 1.1f, 0.0f);
mMotionBlurImageActor.Add( mMotionBlurImageActor3 );
// Create shader used for doing motion blur
mMotionBlurImageActor4 = ImageActor::New(image);
mMotionBlurImageActor4.SetParentOrigin( ParentOrigin::CENTER );
- mMotionBlurImageActor4.SetSize(MOTION_BLUR_ACTOR_WIDTH, MOTION_BLUR_ACTOR_HEIGHT);
- mMotionBlurImageActor4.SetPosition(0.0f, MOTION_BLUR_ACTOR_HEIGHT * 1.1f);
+ mMotionBlurImageActor4.SetSize(mMotionBlurActorSize.x, mMotionBlurActorSize.y);
+ mMotionBlurImageActor4.SetPosition(0.0f, mMotionBlurActorSize.y * 1.1f);
mMotionBlurImageActor.Add( mMotionBlurImageActor4 );
// Create shader used for doing motion blur
mMotionBlurImageActor5 = ImageActor::New(image);
mMotionBlurImageActor5.SetParentOrigin( ParentOrigin::CENTER );
- mMotionBlurImageActor5.SetSize(MOTION_BLUR_ACTOR_WIDTH, MOTION_BLUR_ACTOR_HEIGHT);
- mMotionBlurImageActor5.SetPosition(0.0f, -MOTION_BLUR_ACTOR_HEIGHT * 1.1f);
+ mMotionBlurImageActor5.SetSize(mMotionBlurActorSize.x, mMotionBlurActorSize.y);
+ mMotionBlurImageActor5.SetPosition(0.0f, -mMotionBlurActorSize.y * 1.1f);
mMotionBlurImageActor.Add( mMotionBlurImageActor5 );
// Create shader used for doing motion blur
{
// has parent so we expect it to be on stage, start animation
mRotateAnimation = Animation::New( ORIENTATION_DURATION );
- mRotateAnimation.RotateTo( mView, Degree( -orientation ), Vector3::ZAXIS, AlphaFunctions::EaseOut );
- mRotateAnimation.Resize( mView, targetSize.width, targetSize.height );
+ mRotateAnimation.AnimateTo( Property( mView, Actor::Property::ORIENTATION ), Quaternion( Radian( Degree( -orientation ) ), Vector3::ZAXIS ), AlphaFunctions::EaseOut );
+ mRotateAnimation.AnimateTo( Property( mView, Actor::Property::SIZE_WIDTH ), targetSize.width );
+ mRotateAnimation.AnimateTo( Property( mView, Actor::Property::SIZE_HEIGHT ), targetSize.height );
mRotateAnimation.Play();
}
else
{
// set the rotation to match the orientation
- mView.SetRotation( Degree( -orientation ), Vector3::ZAXIS );
+ mView.SetOrientation( Degree( -orientation ), Vector3::ZAXIS );
mView.SetSize( targetSize );
}
}
{
float animDuration = 1.0f;
mActorAnimation = Animation::New(animDuration);
- mActorAnimation.RotateBy(mMotionBlurImageActor, Degree(720), Vector3::YAXIS, AlphaFunctions::EaseInOut);
+ mActorAnimation.AnimateBy( Property( mMotionBlurImageActor, Actor::Property::ORIENTATION ), Quaternion( Radian( Degree(360.0f) ), Vector3::YAXIS ), AlphaFunctions::EaseInOut );
mActorAnimation.SetEndAction( Animation::Bake );
mActorAnimation.Play();
}
{
float animDuration = 1.0f;
mActorAnimation = Animation::New(animDuration);
- mActorAnimation.RotateBy(mMotionBlurImageActor, Degree(720), Vector3::ZAXIS, AlphaFunctions::EaseInOut);
+ mActorAnimation.AnimateBy( Property( mMotionBlurImageActor, Actor::Property::ORIENTATION ), Quaternion( Radian( Degree(360.0f) ), Vector3::ZAXIS ), AlphaFunctions::EaseInOut );
mActorAnimation.SetEndAction( Animation::Bake );
mActorAnimation.Play();
}
{
float animDuration = 1.0f;
mActorAnimation = Animation::New(animDuration);
- mActorAnimation.RotateBy(mMotionBlurImageActor, Degree(360), Vector3::YAXIS, AlphaFunctions::EaseInOut);
- mActorAnimation.RotateBy(mMotionBlurImageActor, Degree(360), Vector3::ZAXIS, AlphaFunctions::EaseInOut);
+ mActorAnimation.AnimateBy( Property( mMotionBlurImageActor, Actor::Property::ORIENTATION ), Quaternion( Radian( Degree(360.0f) ), Vector3::YAXIS ), AlphaFunctions::EaseInOut );
+ mActorAnimation.AnimateBy( Property( mMotionBlurImageActor, Actor::Property::ORIENTATION ), Quaternion( Radian( Degree(360.0f) ), Vector3::ZAXIS ), AlphaFunctions::EaseInOut );
mActorAnimation.SetEndAction( Animation::Bake );
mActorAnimation.Play();
}
{
float animDuration = 1.0f;
mActorAnimation = Animation::New(animDuration);
- mActorAnimation.ScaleBy(mMotionBlurImageActor, Vector3(2.0f, 2.0f, 2.0f), AlphaFunctions::Bounce, 0.0f, 1.0f);
+ mActorAnimation.AnimateBy( Property( mMotionBlurImageActor, Actor::Property::SCALE ), Vector3(2.0f, 2.0f, 2.0f), AlphaFunctions::Bounce, TimePeriod( 0.0f, 1.0f ) );
mActorAnimation.SetEndAction( Animation::Bake );
mActorAnimation.Play();
}
mCurrentImage = 0;
}
- Image blurImage = ResourceImage::New( MOTION_BLUR_ACTOR_IMAGES[mCurrentImage] );
+ Image blurImage = LoadImageFittedInBox( MOTION_BLUR_ACTOR_IMAGES[mCurrentImage], mMotionBlurActorSize.x, mMotionBlurActorSize.y );
mMotionBlurImageActor.SetImage(blurImage);
}
// Motion blur
MotionBlurEffect mMotionBlurEffect;
ImageActor mMotionBlurImageActor;
+ Size mMotionBlurActorSize;
#ifdef MULTIPLE_MOTION_BLURRED_ACTORS
MotionBlurEffect mMotionBlurEffect2;
app.MainLoop();
}
-// Entry point for Linux & SLP applications
+// Entry point for Linux & Tizen applications
//
int main(int argc, char **argv)
{