Author: Diego Barrios Romero <[email protected]>
Date: Mon Oct 29 15:27:51 2012 +0100
Transformation chain applied to layers zoom and rectangle
---
synfig-core/src/modules/lyr_std/zoom.cpp | 18 +++++++++++++-----
synfig-core/src/modules/mod_geometry/rectangle.cpp | 5 ++++-
2 files changed, 17 insertions(+), 6 deletions(-)
diff --git a/synfig-core/src/modules/lyr_std/zoom.cpp
b/synfig-core/src/modules/lyr_std/zoom.cpp
index 430e5c6..d9f7c3d 100644
--- a/synfig-core/src/modules/lyr_std/zoom.cpp
+++ b/synfig-core/src/modules/lyr_std/zoom.cpp
@@ -6,6 +6,7 @@
**
** \legal
** Copyright (c) 2002-2005 Robert B. Quattlebaum Jr., Adrian Bentley
+** Copyright (c) 2012 Diego Barrios Romero
**
** This package is free software; you can redistribute it and/or
** modify it under the terms of the GNU General Public License as
@@ -39,6 +40,7 @@
#include <synfig/value.h>
#include <synfig/valuenode.h>
#include <synfig/transform.h>
+#include <synfig/transformationchain.h>
#endif
@@ -144,14 +146,20 @@ Zoom::get_transform()const
bool
Zoom::accelerated_render(Context context,Surface *surface,int quality, const
RendDesc &renddesc, ProgressCallback *cb)const
{
- Vector::value_type zoomfactor=1.0/exp(amount);
RendDesc desc(renddesc);
desc.clear_flags();
- // Adjust the top_left and bottom_right points
- // for our zoom amount
- desc.set_tl((desc.get_tl()-center)*zoomfactor+center);
- desc.set_br((desc.get_br()-center)*zoomfactor+center);
+ // In order to perform a scale transformation in 2D with an arbitrary
scale
+ // center, we first have to translate the object according to the
center,
+ // then scale it and then translate the object back to its position.
+ Matrix m1, m2, m3;
+ m1.set_translate(center);
+ m2.set_scale(exp(amount), exp(amount));
+ m3.set_translate(-center);
+
+ desc.get_transformation_chain().push(m1);
+ desc.get_transformation_chain().push(m2);
+ desc.get_transformation_chain().push(m3);
// Render the scene
return context.accelerated_render(surface,quality,desc,cb);
diff --git a/synfig-core/src/modules/mod_geometry/rectangle.cpp
b/synfig-core/src/modules/mod_geometry/rectangle.cpp
index 9ec1f01..6937ff0 100644
--- a/synfig-core/src/modules/mod_geometry/rectangle.cpp
+++ b/synfig-core/src/modules/mod_geometry/rectangle.cpp
@@ -8,6 +8,7 @@
** Copyright (c) 2002 Robert B. Quattlebaum Jr.
** Copyright (c) 2007, 2008 Chris Moore
** Copyright (c) 2011 Carlos López
+** Copyright (c) 2012 Diego Barrios Romero
**
** This package is free software; you can redistribute it and/or
** modify it under the terms of the GNU General Public License as
@@ -35,6 +36,7 @@
#include <synfig/time.h>
#include <synfig/context.h>
#include <synfig/paramdesc.h>
+#include <synfig/transformationchain.h>
#include <synfig/renddesc.h>
#include <synfig/surface.h>
#include <synfig/value.h>
@@ -320,7 +322,8 @@ Rectangle::accelerated_render(Context context,Surface
*surface,int quality, cons
Point max(point1),min(point2);
-
+ max = renddesc.get_transformation_chain().get_transformed(max);
+ min = renddesc.get_transformation_chain().get_transformed(min);
/*
------------------------------------------------------------------------------
The Windows 8 Center - In partnership with Sourceforge
Your idea - your app - 30 days.
Get started!
http://windows8center.sourceforge.net/
what-html-developers-need-to-know-about-coding-windows-8-metro-style-apps/
_______________________________________________
Synfig-devl mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/synfig-devl