X-Git-Url: https://git.pterodactylus.net/?a=blobdiff_plain;f=synfig-core%2Ftrunk%2Fsrc%2Fmodules%2Flyr_std%2Frotate.cpp;h=0aa35e28f106ba5b9812c177d55739e30757d3eb;hb=36d01e1527fda602a9aed07d209eb34e6770bca8;hp=166bd0ade491c53e541a7b50a782eb05c9d16e62;hpb=16b3beced25134bef064705568ecb893a6be4e79;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 166bd0a..0aa35e2 100644 --- a/synfig-core/trunk/src/modules/lyr_std/rotate.cpp +++ b/synfig-core/trunk/src/modules/lyr_std/rotate.cpp @@ -1,18 +1,20 @@ -/*! ======================================================================== -** Sinfg -** 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 Template Header ** -** Copyright (c) 2002 Robert B. Quattlebaum Jr. +** \legal +** Copyright (c) 2002-2005 Robert B. Quattlebaum Jr., Adrian Bentley ** -** This software and associated documentation -** are CONFIDENTIAL and PROPRIETARY property of -** the above-mentioned copyright holder. +** This package is free software; you can redistribute it and/or +** modify it under the terms of the GNU General Public License as +** published by the Free Software Foundation; either version 2 of +** the License, or (at your option) any later version. ** -** You may not copy, print, publish, or in any -** other way distribute this software without -** a prior written agreement with -** the copyright holder. +** This package is distributed in the hope that it will be useful, +** 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 =========================================================== ** @@ -28,15 +30,15 @@ #endif #include "rotate.h" -#include -#include -#include -#include -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include +#include +#include +#include +#include #include #endif @@ -45,12 +47,12 @@ /* === G L O B A L S ======================================================= */ -SINFG_LAYER_INIT(Rotate); -SINFG_LAYER_SET_NAME(Rotate,"rotate"); -SINFG_LAYER_SET_LOCAL_NAME(Rotate,_("Rotate")); -SINFG_LAYER_SET_CATEGORY(Rotate,_("Transform")); -SINFG_LAYER_SET_VERSION(Rotate,"0.1"); -SINFG_LAYER_SET_CVS_ID(Rotate,"$Id: rotate.cpp,v 1.2 2005/01/24 05:00:18 darco Exp $"); +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_VERSION(Rotate,"0.1"); +SYNFIG_LAYER_SET_CVS_ID(Rotate,"$Id: rotate.cpp,v 1.2 2005/01/24 05:00:18 darco Exp $"); /* === P R O C E D U R E S ================================================= */ @@ -74,7 +76,7 @@ bool Rotate::set_param(const String & param, const ValueBase &value) { IMPORT(origin); - + if(param=="amount" && value.same_as(amount)) { amount=value.get(amount); @@ -82,7 +84,7 @@ Rotate::set_param(const String & param, const ValueBase &value) cos_val=Angle::cos(amount).get(); return true; } - + return false; } @@ -91,18 +93,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")) @@ -113,7 +115,7 @@ Rotate::get_param_vocab()const .set_description(_("Amount of rotation")) .set_origin("origin") ); - + return ret; } @@ -122,14 +124,14 @@ class Rotate_Trans : public Transform etl::handle layer; public: Rotate_Trans(const Rotate* x):Transform(x->get_guid()),layer(x) { } - - sinfg::Vector perform(const sinfg::Vector& x)const + + 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; } - - sinfg::Vector unperform(const sinfg::Vector& x)const + + synfig::Vector unperform(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; @@ -141,8 +143,8 @@ Rotate::get_transform()const return new Rotate_Trans(this); } -sinfg::Layer::Handle -Rotate::hit_check(sinfg::Context context, const sinfg::Point &p)const +synfig::Layer::Handle +Rotate::hit_check(synfig::Context context, const synfig::Point &p)const { Point pos(p-origin); Point newpos(cos_val*pos[0]+sin_val*pos[1],-sin_val*pos[0]+cos_val*pos[1]); @@ -178,21 +180,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])); @@ -216,10 +218,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); @@ -227,15 +229,15 @@ Rotate::accelerated_render(Context context,Surface *surface,int quality, const R desc.set_br(br); desc.set_wh(round_to_int(pw*(br[0]-tl[0])),round_to_int(ph*(br[1]-tl[1]))); - //sinfg::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()); - //sinfg::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()); - + //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());