X-Git-Url: https://git.pterodactylus.net/?a=blobdiff_plain;f=synfig-core%2Ftrunk%2Fsrc%2Fmodules%2Flyr_std%2Fsphere_distort.cpp;h=cf37a99c2a526f149cdbaaa79d3c730e883a26a2;hb=9fdedd6c7339a0707e6837deb04ed4fa9abd53c2;hp=af4c3c728e121b81eb657a9c2243ca98fe4eed50;hpb=16b3beced25134bef064705568ecb893a6be4e79;p=synfig.git diff --git a/synfig-core/trunk/src/modules/lyr_std/sphere_distort.cpp b/synfig-core/trunk/src/modules/lyr_std/sphere_distort.cpp index af4c3c7..cf37a99 100644 --- a/synfig-core/trunk/src/modules/lyr_std/sphere_distort.cpp +++ b/synfig-core/trunk/src/modules/lyr_std/sphere_distort.cpp @@ -1,20 +1,21 @@ -/* === S I N F G =========================================================== */ +/* === S Y N F I G ========================================================= */ /*! \file sphere_distort.cpp ** \brief Sphere Distort File ** ** $Id: sphere_distort.cpp,v 1.2 2005/01/24 05:00:18 darco Exp $ ** ** \legal -** Copyright (c) 2002 Robert B. Quattlebaum Jr. +** 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 */ /* ========================================================================= */ @@ -29,17 +30,17 @@ #endif #include "sphere_distort.h" -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include #endif @@ -47,7 +48,7 @@ using namespace std; using namespace etl; -using namespace sinfg; +using namespace synfig; /* === M A C R O S ========================================================= */ @@ -65,12 +66,12 @@ enum /* === G L O B A L S ======================================================= */ -SINFG_LAYER_INIT(Layer_SphereDistort); -SINFG_LAYER_SET_NAME(Layer_SphereDistort,"spherize"); -SINFG_LAYER_SET_LOCAL_NAME(Layer_SphereDistort,_("Spherize")); -SINFG_LAYER_SET_CATEGORY(Layer_SphereDistort,_("Distortions")); -SINFG_LAYER_SET_VERSION(Layer_SphereDistort,"0.2"); -SINFG_LAYER_SET_CVS_ID(Layer_SphereDistort,"$Id: sphere_distort.cpp,v 1.2 2005/01/24 05:00:18 darco Exp $"); +SYNFIG_LAYER_INIT(Layer_SphereDistort); +SYNFIG_LAYER_SET_NAME(Layer_SphereDistort,"spherize"); +SYNFIG_LAYER_SET_LOCAL_NAME(Layer_SphereDistort,_("Spherize")); +SYNFIG_LAYER_SET_CATEGORY(Layer_SphereDistort,_("Distortions")); +SYNFIG_LAYER_SET_VERSION(Layer_SphereDistort,"0.2"); +SYNFIG_LAYER_SET_CVS_ID(Layer_SphereDistort,"$Id: sphere_distort.cpp,v 1.2 2005/01/24 05:00:18 darco Exp $"); /* === P R O C E D U R E S ================================================= */ @@ -82,7 +83,7 @@ Layer_SphereDistort::Layer_SphereDistort() :Layer_Composite(1.0,Color::BLEND_STRAIGHT), center(0,0), radius(1), -percent(1,1), +percent(1.0), type(TYPE_NORMAL), clip(false) { @@ -104,10 +105,10 @@ Layer_SphereDistort::set_param(const String & param, const ValueBase &value) { connect_dynamic_param("amount",dynamic_param_list().find("percent")->second); disconnect_dynamic_param("percent"); - sinfg::warning("Layer_SphereDistort::::set_param(): Updated valuenode connection to use the new \"amount\" parameter."); + synfig::warning("Layer_SphereDistort::::set_param(): Updated valuenode connection to use the new \"amount\" parameter."); } else - sinfg::warning("Layer_SphereDistort::::set_param(): The parameter \"segment_list\" is deprecated. Use \"bline\" instead."); + synfig::warning("Layer_SphereDistort::::set_param(): The parameter \"segment_list\" is deprecated. Use \"bline\" instead."); } return false; @@ -295,8 +296,8 @@ inline Point sphtrans(const Point &p, const Point ¢er, const Real &radius, return sphtrans(p, center, radius, percent, type, tmp); } -sinfg::Layer::Handle -Layer_SphereDistort::hit_check(sinfg::Context context, const sinfg::Point &pos)const +synfig::Layer::Handle +Layer_SphereDistort::hit_check(synfig::Context context, const synfig::Point &pos)const { bool clipped; Point point(sphtrans(pos,center,radius,percent,type,clipped)); @@ -347,11 +348,11 @@ bool Layer_SphereDistort::accelerated_render(Context context,Surface *surface,in (type == TYPE_DISTH && (sphr.minx >= windr.maxx || windr.minx >= sphr.maxx)) || (type == TYPE_DISTV && (sphr.miny >= windr.maxy || windr.miny >= sphr.maxy)) ) { - //sinfg::warning("Spherize: Bounding box reject"); + //synfig::warning("Spherize: Bounding box reject"); return context.accelerated_render(surface,quality,renddesc,cb); } - //sinfg::warning("Spherize: Bounding box accept"); + //synfig::warning("Spherize: Bounding box accept"); } //Ok, so we overlap some... now expand the window for rendering @@ -380,10 +381,10 @@ bool Layer_SphereDistort::accelerated_render(Context context,Surface *surface,in //expandr.set_point(tl[0],tl[1]); //expandr.expand(br[0],br[1]); - //sinfg::warning("Spherize: Loop through lines and stuff"); + //synfig::warning("Spherize: Loop through lines and stuff"); for(int i=0; i<4; ++i) { - //sinfg::warning("Spherize: %d", i); + //synfig::warning("Spherize: %d", i); Vector p_o = center-origin[i]; //project onto left line @@ -403,13 +404,13 @@ bool Layer_SphereDistort::accelerated_render(Context context,Surface *surface,in expandr.expand(p[0],p[1]); } - /*sinfg::warning("Spherize: Bounding box (%f,%f)-(%f,%f)", + /*synfig::warning("Spherize: Bounding box (%f,%f)-(%f,%f)", expandr.minx,expandr.miny,expandr.maxx,expandr.maxy);*/ //now that we have the bouding rectangle of ALL the pixels (should be...) //order it so that it's in the same orientation as the tl,br pair - //sinfg::warning("Spherize: Organize like tl,br"); + //synfig::warning("Spherize: Organize like tl,br"); Point ntl(0,0),nbr(0,0); //sort x @@ -450,7 +451,7 @@ bool Layer_SphereDistort::accelerated_render(Context context,Surface *surface,in nw = renddesc.get_w() + nr - nl; nh = renddesc.get_h() + nb - nt; - //sinfg::warning("Spherize: Setting subwindow (%d,%d) (%d,%d) (%d,%d)",nl,nt,nr,nb,nw,nh); + //synfig::warning("Spherize: Setting subwindow (%d,%d) (%d,%d) (%d,%d)",nl,nt,nr,nb,nw,nh); r.set_subwindow(nl,nt,nw,nh); /*r = renddesc; @@ -458,10 +459,10 @@ bool Layer_SphereDistort::accelerated_render(Context context,Surface *surface,in nl = 0, nt = 0;*/ } - //sinfg::warning("Spherize: render background"); + //synfig::warning("Spherize: render background"); if(!context.accelerated_render(&background,quality,r,cb)) { - sinfg::warning("SphereDistort: Layer below failed"); + synfig::warning("SphereDistort: Layer below failed"); return false; } @@ -477,7 +478,7 @@ bool Layer_SphereDistort::accelerated_render(Context context,Surface *surface,in Point rtl = r.get_tl(); - //sinfg::warning("Spherize: About to transform"); + //synfig::warning("Spherize: About to transform"); for(y = 0; y < h; ++y, sample[1] += ph, p.inc_y()) { @@ -497,7 +498,7 @@ bool Layer_SphereDistort::accelerated_render(Context context,Surface *surface,in if(!(xs >= 0 && xs < nw && ys >= 0 && ys < nh)) { - //sinfg::warning("Spherize: we failed to account for %f,%f",xs,ys); + //synfig::warning("Spherize: we failed to account for %f,%f",xs,ys); p.put_value(context.get_color(trans));//Color::alpha()); continue; } @@ -524,18 +525,18 @@ bool Layer_SphereDistort::accelerated_render(Context context,Surface *surface,in } #endif -class Spherize_Trans : public Transform +class synfig::Spherize_Trans : public synfig::Transform { etl::handle layer; public: Spherize_Trans(const Layer_SphereDistort* x):Transform(x->get_guid()),layer(x) { } - sinfg::Vector perform(const sinfg::Vector& x)const + synfig::Vector perform(const synfig::Vector& x)const { return sphtrans(x,layer->center,layer->radius,-layer->percent,layer->type); } - sinfg::Vector unperform(const sinfg::Vector& x)const + synfig::Vector unperform(const synfig::Vector& x)const { return sphtrans(x,layer->center,layer->radius,layer->percent,layer->type); }