From 7b4762d8b568f70e9b1a8d18afe0998af661d906 Mon Sep 17 00:00:00 2001 From: dooglus Date: Fri, 23 Mar 2007 20:46:58 +0000 Subject: [PATCH] Stretch layers change the size of their content's bounding box. Wrote a get_full_bounding_rect() function to reflect this. git-svn-id: http://svn.voria.com/code@376 1f10aa63-cdf2-0310-b900-c93c546f37ac --- synfig-core/trunk/src/modules/lyr_std/stretch.cpp | 19 +++++++++++++++++-- synfig-core/trunk/src/modules/lyr_std/stretch.h | 2 ++ 2 files changed, 19 insertions(+), 2 deletions(-) diff --git a/synfig-core/trunk/src/modules/lyr_std/stretch.cpp b/synfig-core/trunk/src/modules/lyr_std/stretch.cpp index c54cf67..a6f4def 100644 --- a/synfig-core/trunk/src/modules/lyr_std/stretch.cpp +++ b/synfig-core/trunk/src/modules/lyr_std/stretch.cpp @@ -6,6 +6,7 @@ ** ** \legal ** Copyright (c) 2002-2005 Robert B. Quattlebaum Jr., Adrian Bentley +** Copyright (c) 2007 Chris Moore ** ** This package is free software; you can redistribute it and/or ** modify it under the terms of the GNU General Public License as @@ -135,12 +136,14 @@ public: synfig::Vector perform(const synfig::Vector& x)const { - return Vector((x[0]-layer->center[0])*layer->amount[0]+layer->center[0],(x[1]-layer->center[1])*layer->amount[1]+layer->center[1]); + return Vector((x[0]-layer->center[0])*layer->amount[0]+layer->center[0], + (x[1]-layer->center[1])*layer->amount[1]+layer->center[1]); } synfig::Vector unperform(const synfig::Vector& x)const { - return Vector((x[0]-layer->center[0])/layer->amount[0]+layer->center[0],(x[1]-layer->center[1])/layer->amount[1]+layer->center[1]); + return Vector((x[0]-layer->center[0])/layer->amount[0]+layer->center[0], + (x[1]-layer->center[1])/layer->amount[1]+layer->center[1]); } }; etl::handle @@ -167,3 +170,15 @@ Layer_Stretch::accelerated_render(Context context,Surface *surface,int quality, // Render the scene return context.accelerated_render(surface,quality,desc,cb); } + +Rect +Layer_Stretch::get_full_bounding_rect(Context context)const +{ + Rect rect(context.get_full_bounding_rect()); + Point min(rect.get_min()), max(rect.get_max()); + + return Rect(Point((min[0]-center[0])*amount[0]+center[0], + (min[1]-center[1])*amount[1]+center[1]), + Point((max[0]-center[0])*amount[0]+center[0], + (max[1]-center[1])*amount[1]+center[1])); +} diff --git a/synfig-core/trunk/src/modules/lyr_std/stretch.h b/synfig-core/trunk/src/modules/lyr_std/stretch.h index 70e0449..2b70ecc 100644 --- a/synfig-core/trunk/src/modules/lyr_std/stretch.h +++ b/synfig-core/trunk/src/modules/lyr_std/stretch.h @@ -6,6 +6,7 @@ ** ** \legal ** Copyright (c) 2002-2005 Robert B. Quattlebaum Jr., Adrian Bentley +** Copyright (c) 2007 Chris Moore ** ** This package is free software; you can redistribute it and/or ** modify it under the terms of the GNU General Public License as @@ -64,6 +65,7 @@ public: virtual Vocab get_param_vocab()const; virtual etl::handle get_transform()const; + virtual synfig::Rect get_full_bounding_rect(Context context)const; }; // END of class Layer_Stretch }; // END of namespace synfig -- 2.7.4