X-Git-Url: https://git.pterodactylus.net/?a=blobdiff_plain;f=synfig-core%2Ftrunk%2Fsrc%2Fmodules%2Flyr_std%2Frotate.cpp;h=a17a8546ee7b80c9d269e87d56cfd9e44f9adfdd;hb=756c0d29ac1742f231e6615f9a577e574e35a4af;hp=b907fea239e9a8a048093dda537b103d5ed10b1a;hpb=21bfc670b83d4c45da9ed1b95063b7e6a007168c;p=synfig.git diff --git a/synfig-core/trunk/src/modules/lyr_std/rotate.cpp b/synfig-core/trunk/src/modules/lyr_std/rotate.cpp index b907fea..a17a854 100644 --- a/synfig-core/trunk/src/modules/lyr_std/rotate.cpp +++ b/synfig-core/trunk/src/modules/lyr_std/rotate.cpp @@ -1,9 +1,12 @@ -/*! ======================================================================== -** Synfig -** Template File -** $Id: rotate.cpp,v 1.2 2005/01/24 05:00:18 darco Exp $ +/* === S Y N F I G ========================================================= */ +/*! \file rotate.cpp +** \brief Implementation of the "Rotate" layer ** +** $Id$ +** +** \legal ** Copyright (c) 2002-2005 Robert B. Quattlebaum Jr., Adrian Bentley +** Copyright (c) 2008 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 @@ -14,6 +17,7 @@ ** but WITHOUT ANY WARRANTY; without even the implied warranty of ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU ** General Public License for more details. +** \endlegal ** ** === N O T E S =========================================================== ** @@ -48,10 +52,10 @@ SYNFIG_LAYER_INIT(Rotate); SYNFIG_LAYER_SET_NAME(Rotate,"rotate"); -SYNFIG_LAYER_SET_LOCAL_NAME(Rotate,_("Rotate")); -SYNFIG_LAYER_SET_CATEGORY(Rotate,_("Transform")); +SYNFIG_LAYER_SET_LOCAL_NAME(Rotate,N_("Rotate")); +SYNFIG_LAYER_SET_CATEGORY(Rotate,N_("Transform")); SYNFIG_LAYER_SET_VERSION(Rotate,"0.1"); -SYNFIG_LAYER_SET_CVS_ID(Rotate,"$Id: rotate.cpp,v 1.2 2005/01/24 05:00:18 darco Exp $"); +SYNFIG_LAYER_SET_CVS_ID(Rotate,"$Id$"); /* === P R O C E D U R E S ================================================= */ @@ -75,15 +79,15 @@ bool Rotate::set_param(const String & param, const ValueBase &value) { IMPORT(origin); - - if(param=="amount" && value.same_as(amount)) + + if(param=="amount" && value.same_type_as(amount)) { amount=value.get(amount); sin_val=Angle::sin(amount).get(); cos_val=Angle::cos(amount).get(); return true; } - + return false; } @@ -92,18 +96,18 @@ Rotate::get_param(const String ¶m)const { EXPORT(origin); EXPORT(amount); - + EXPORT_NAME(); EXPORT_VERSION(); - - return ValueBase(); + + return ValueBase(); } Layer::Vocab Rotate::get_param_vocab()const { Layer::Vocab ret; - + ret.push_back(ParamDesc("origin") .set_local_name(_("Origin")) .set_description(_("Point where you want the origin to be")) @@ -114,7 +118,7 @@ Rotate::get_param_vocab()const .set_description(_("Amount of rotation")) .set_origin("origin") ); - + return ret; } @@ -123,13 +127,13 @@ class Rotate_Trans : public Transform etl::handle layer; public: Rotate_Trans(const Rotate* x):Transform(x->get_guid()),layer(x) { } - + synfig::Vector perform(const synfig::Vector& x)const { Point pos(x-layer->origin); return Point(layer->cos_val*pos[0]-layer->sin_val*pos[1],layer->sin_val*pos[0]+layer->cos_val*pos[1])+layer->origin; } - + synfig::Vector unperform(const synfig::Vector& x)const { Point pos(x-layer->origin); @@ -179,21 +183,21 @@ Rotate::accelerated_render(Context context,Surface *surface,int quality, const R SuperCallback stageone(cb,0,9000,10000); SuperCallback stagetwo(cb,9000,10000,10000); - + if(cb && !cb->amount_complete(0,10000)) return false; - + Point tl(renddesc.get_tl()-origin); Point br(renddesc.get_br()-origin); Point rot_tl(cos_val*tl[0]+sin_val*tl[1],-sin_val*tl[0]+cos_val*tl[1]); - Point rot_br(cos_val*br[0]+sin_val*br[1],-sin_val*br[0]+cos_val*br[1]); + Point rot_br(cos_val*br[0]+sin_val*br[1],-sin_val*br[0]+cos_val*br[1]); Point rot_tr(cos_val*br[0]+sin_val*tl[1],-sin_val*br[0]+cos_val*tl[1]); - Point rot_bl(cos_val*tl[0]+sin_val*br[1],-sin_val*tl[0]+cos_val*br[1]); + Point rot_bl(cos_val*tl[0]+sin_val*br[1],-sin_val*tl[0]+cos_val*br[1]); rot_tl+=origin; rot_br+=origin; rot_tr+=origin; rot_bl+=origin; - + Point min_point(min(min(min(rot_tl[0],rot_br[0]),rot_tr[0]),rot_bl[0]),min(min(min(rot_tl[1],rot_br[1]),rot_tr[1]),rot_bl[1])); Point max_point(max(max(max(rot_tl[0],rot_br[0]),rot_tr[0]),rot_bl[0]),max(max(max(rot_tl[1],rot_br[1]),rot_tr[1]),rot_bl[1])); @@ -217,10 +221,10 @@ Rotate::accelerated_render(Context context,Surface *surface,int quality, const R br[1]=max_point[1]; tl[1]=min_point[1]; } - + Real pw=(renddesc.get_w())/(renddesc.get_br()[0]-renddesc.get_tl()[0]); Real ph=(renddesc.get_h())/(renddesc.get_br()[1]-renddesc.get_tl()[1]); - + RendDesc desc(renddesc); desc.clear_flags(); //desc.set_flags(RendDesc::PX_ASPECT); @@ -230,13 +234,13 @@ Rotate::accelerated_render(Context context,Surface *surface,int quality, const R //synfig::warning("given window: [%f,%f]-[%f,%f] %dx%d",renddesc.get_tl()[0],renddesc.get_tl()[1],renddesc.get_br()[0],renddesc.get_br()[1],renddesc.get_w(),renddesc.get_h()); //synfig::warning("surface to render: [%f,%f]-[%f,%f] %dx%d",desc.get_tl()[0],desc.get_tl()[1],desc.get_br()[0],desc.get_br()[1],desc.get_w(),desc.get_h()); - + Surface source; source.set_wh(desc.get_w(),desc.get_h()); if(!context.accelerated_render(&source,quality,desc,&stageone)) return false; - + surface->set_wh(renddesc.get_w(),renddesc.get_h()); Surface::pen pen(surface->begin()); @@ -253,7 +257,7 @@ Rotate::accelerated_render(Context context,Surface *surface,int quality, const R tmp=Point(cos_val*(point[0]-origin[0])+sin_val*(point[1]-origin[1]),-sin_val*(point[0]-origin[0])+cos_val*(point[1]-origin[1])) +origin; (*surface)[y][x]=source.cubic_sample((tmp[0]-tl[0])*pw,(tmp[1]-tl[1])*ph); } - if(y&31==0 && cb) + if((y&31)==0 && cb) { if(!stagetwo.amount_complete(y,surface->get_h())) return false; @@ -273,7 +277,7 @@ Rotate::accelerated_render(Context context,Surface *surface,int quality, const R tmp=Point(cos_val*(point[0]-origin[0])+sin_val*(point[1]-origin[1]),-sin_val*(point[0]-origin[0])+cos_val*(point[1]-origin[1])) +origin; (*surface)[y][x]=source.linear_sample((tmp[0]-tl[0])*pw,(tmp[1]-tl[1])*ph); } - if(y&31==0 && cb) + if((y&31)==0 && cb) { if(!stagetwo.amount_complete(y,surface->get_h())) return false; @@ -303,7 +307,7 @@ Rotate::accelerated_render(Context context,Surface *surface,int quality, const R //pen.set_value(source[v][u]); (*surface)[y][x]=source[v][u]; } - if(y&31==0 && cb) + if((y&31)==0 && cb) { if(!stagetwo.amount_complete(y,surface->get_h())) return false;