From 017bf390d4e1fd28d8b5f12338c0cf7ce917330c Mon Sep 17 00:00:00 2001 From: Ivan Mahonin Date: Sep 16 2015 20:21:15 +0000 Subject: Rotate, Stretch, Translate and Zoom --- diff --git a/synfig-core/src/modules/lyr_std/rotate.cpp b/synfig-core/src/modules/lyr_std/rotate.cpp index a23dd1b..33a3cea 100644 --- a/synfig-core/src/modules/lyr_std/rotate.cpp +++ b/synfig-core/src/modules/lyr_std/rotate.cpp @@ -33,7 +33,8 @@ # include #endif -#include "rotate.h" +#include + #include #include #include @@ -43,7 +44,11 @@ #include #include #include -#include + +#include "rotate.h" + +#include +#include #endif @@ -233,3 +238,20 @@ Rotate::get_full_bounding_rect(Context context)const return get_transform()->perform(under); } +rendering::Task::Handle +Rotate::build_rendering_task_vfunc(Context context)const +{ + Vector origin=param_origin.get(Vector()); + Angle amount=param_amount.get(Angle()); + + rendering::TaskTransformation::Handle task_transformation(new rendering::TaskTransformation()); + rendering::AffineTransformation::Handle affine_transformation(new rendering::AffineTransformation()); + affine_transformation->matrix = + Matrix().set_translate(-origin) + * Matrix().set_rotate(amount) + * Matrix().set_translate(origin); + task_transformation->transformation = affine_transformation; + task_transformation->sub_task() = context.build_rendering_task(); + return task_transformation; +} + diff --git a/synfig-core/src/modules/lyr_std/rotate.h b/synfig-core/src/modules/lyr_std/rotate.h index 628fb94..8b509e6 100644 --- a/synfig-core/src/modules/lyr_std/rotate.h +++ b/synfig-core/src/modules/lyr_std/rotate.h @@ -71,6 +71,9 @@ public: virtual Rect get_full_bounding_rect(Context context)const; virtual etl::handle get_transform()const; + +protected: + virtual rendering::Task::Handle build_rendering_task_vfunc(Context context)const; }; /* === E N D =============================================================== */ diff --git a/synfig-core/src/modules/lyr_std/stretch.cpp b/synfig-core/src/modules/lyr_std/stretch.cpp index 97ff7c5..915797d 100644 --- a/synfig-core/src/modules/lyr_std/stretch.cpp +++ b/synfig-core/src/modules/lyr_std/stretch.cpp @@ -31,7 +31,6 @@ # include #endif -#include "stretch.h" #include #include #include @@ -42,6 +41,11 @@ #include #include +#include "stretch.h" + +#include +#include + #endif /* === U S I N G =========================================================== */ @@ -244,3 +248,20 @@ Layer_Stretch::get_full_bounding_rect(Context context)const Point((max[0]-center[0])*amount[0]+center[0], (max[1]-center[1])*amount[1]+center[1])); } + +rendering::Task::Handle +Layer_Stretch::build_rendering_task_vfunc(Context context)const +{ + Vector amount=param_amount.get(Vector()); + Point center=param_center.get(Point()); + + rendering::TaskTransformation::Handle task_transformation(new rendering::TaskTransformation()); + rendering::AffineTransformation::Handle affine_transformation(new rendering::AffineTransformation()); + affine_transformation->matrix = + Matrix().set_translate(-center) + * Matrix().set_scale(amount) + * Matrix().set_translate(center); + task_transformation->transformation = affine_transformation; + task_transformation->sub_task() = context.build_rendering_task(); + return task_transformation; +} diff --git a/synfig-core/src/modules/lyr_std/stretch.h b/synfig-core/src/modules/lyr_std/stretch.h index b08fcf0..4621fee 100644 --- a/synfig-core/src/modules/lyr_std/stretch.h +++ b/synfig-core/src/modules/lyr_std/stretch.h @@ -69,6 +69,9 @@ public: virtual Vocab get_param_vocab()const; virtual etl::handle get_transform()const; virtual synfig::Rect get_full_bounding_rect(Context context)const; + +protected: + virtual rendering::Task::Handle build_rendering_task_vfunc(Context context)const; }; // END of class Layer_Stretch }; // END of namespace synfig diff --git a/synfig-core/src/modules/lyr_std/translate.cpp b/synfig-core/src/modules/lyr_std/translate.cpp index 058d2d7..057b8a6 100644 --- a/synfig-core/src/modules/lyr_std/translate.cpp +++ b/synfig-core/src/modules/lyr_std/translate.cpp @@ -32,7 +32,6 @@ # include #endif -#include "translate.h" #include #include #include @@ -44,6 +43,11 @@ #include #include +#include "translate.h" + +#include +#include + #endif /* === M A C R O S ========================================================= */ @@ -191,3 +195,15 @@ Translate::get_full_bounding_rect(Context context)const Vector origin=param_origin.get(Vector()); return context.get_full_bounding_rect() + origin; } + + +rendering::Task::Handle +Translate::build_rendering_task_vfunc(Context context)const +{ + rendering::TaskTransformation::Handle task_transformation(new rendering::TaskTransformation()); + rendering::AffineTransformation::Handle affine_transformation(new rendering::AffineTransformation()); + affine_transformation->matrix.set_translate(param_origin.get(Vector())); + task_transformation->transformation = affine_transformation; + task_transformation->sub_task() = context.build_rendering_task(); + return task_transformation; +} diff --git a/synfig-core/src/modules/lyr_std/translate.h b/synfig-core/src/modules/lyr_std/translate.h index 1f88dff..60cb526 100644 --- a/synfig-core/src/modules/lyr_std/translate.h +++ b/synfig-core/src/modules/lyr_std/translate.h @@ -67,6 +67,8 @@ public: synfig::Layer::Handle hit_check(synfig::Context context, const synfig::Point &point)const; virtual etl::handle get_transform()const; +protected: + virtual rendering::Task::Handle build_rendering_task_vfunc(Context context)const; }; /* === E N D =============================================================== */ diff --git a/synfig-core/src/modules/lyr_std/zoom.cpp b/synfig-core/src/modules/lyr_std/zoom.cpp index fb2b37c..58e1e65 100644 --- a/synfig-core/src/modules/lyr_std/zoom.cpp +++ b/synfig-core/src/modules/lyr_std/zoom.cpp @@ -30,7 +30,6 @@ # include #endif -#include "zoom.h" #include #include #include @@ -41,6 +40,11 @@ #include #include +#include "zoom.h" + +#include +#include + #endif /* === M A C R O S ========================================================= */ @@ -206,3 +210,19 @@ Zoom::get_full_bounding_rect(synfig::Context context)const return (context.get_full_bounding_rect()-center)*exp(param_amount.get(Real()))+center; } +rendering::Task::Handle +Zoom::build_rendering_task_vfunc(Context context)const +{ + Real amount=param_amount.get(Real()); + Point center=param_center.get(Point()); + + rendering::TaskTransformation::Handle task_transformation(new rendering::TaskTransformation()); + rendering::AffineTransformation::Handle affine_transformation(new rendering::AffineTransformation()); + affine_transformation->matrix = + Matrix().set_translate(-center) + * Matrix().set_scale(exp(amount)) + * Matrix().set_translate(center); + task_transformation->transformation = affine_transformation; + task_transformation->sub_task() = context.build_rendering_task(); + return task_transformation; +} diff --git a/synfig-core/src/modules/lyr_std/zoom.h b/synfig-core/src/modules/lyr_std/zoom.h index 1752edc..d6cdb31 100644 --- a/synfig-core/src/modules/lyr_std/zoom.h +++ b/synfig-core/src/modules/lyr_std/zoom.h @@ -65,6 +65,8 @@ public: virtual synfig::Rect get_full_bounding_rect(synfig::Context context)const; virtual etl::handle get_transform()const; +protected: + virtual rendering::Task::Handle build_rendering_task_vfunc(Context context)const; }; /* === E N D =============================================================== */