X-Git-Url: https://git.pterodactylus.net/?a=blobdiff_plain;f=synfig-core%2Ftrunk%2Fsrc%2Fmodules%2Flyr_std%2Fmandelbrot.cpp;h=3343bb26140c67233d2f0ab7182f2b687c50faee;hb=c74ce4738eff208de3bef4b63929b6975a896e93;hp=70a762f4b09674611228f8bb776df4be0375a03a;hpb=16b3beced25134bef064705568ecb893a6be4e79;p=synfig.git diff --git a/synfig-core/trunk/src/modules/lyr_std/mandelbrot.cpp b/synfig-core/trunk/src/modules/lyr_std/mandelbrot.cpp index 70a762f..3343bb2 100644 --- a/synfig-core/trunk/src/modules/lyr_std/mandelbrot.cpp +++ b/synfig-core/trunk/src/modules/lyr_std/mandelbrot.cpp @@ -1,18 +1,22 @@ -/*! ======================================================================== -** Sinfg -** Template File -** $Id: mandelbrot.cpp,v 1.1.1.1 2005/01/04 01:23:10 darco Exp $ +/* === S Y N F I G ========================================================= */ +/*! \file mandelbrot.cpp +** \brief Template Header ** -** Copyright (c) 2002 Robert B. Quattlebaum Jr. +** $Id$ ** -** This software and associated documentation -** are CONFIDENTIAL and PROPRIETARY property of -** the above-mentioned copyright holder. +** \legal +** Copyright (c) 2002-2005 Robert B. Quattlebaum Jr., Adrian Bentley ** -** 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 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. +** +** 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 =========================================================== ** @@ -29,14 +33,14 @@ #include "mandelbrot.h" -#include -#include -#include -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include +#include +#include +#include #endif @@ -46,12 +50,12 @@ /* === G L O B A L S ======================================================= */ -SINFG_LAYER_INIT(Mandelbrot); -SINFG_LAYER_SET_NAME(Mandelbrot,"mandelbrot"); -SINFG_LAYER_SET_LOCAL_NAME(Mandelbrot,_("Mandelbrot Set")); -SINFG_LAYER_SET_CATEGORY(Mandelbrot,_("Fractals")); -SINFG_LAYER_SET_VERSION(Mandelbrot,"0.2"); -SINFG_LAYER_SET_CVS_ID(Mandelbrot,"$Id: mandelbrot.cpp,v 1.1.1.1 2005/01/04 01:23:10 darco Exp $"); +SYNFIG_LAYER_INIT(Mandelbrot); +SYNFIG_LAYER_SET_NAME(Mandelbrot,"mandelbrot"); +SYNFIG_LAYER_SET_LOCAL_NAME(Mandelbrot,_("Mandelbrot Set")); +SYNFIG_LAYER_SET_CATEGORY(Mandelbrot,_("Fractals")); +SYNFIG_LAYER_SET_VERSION(Mandelbrot,"0.2"); +SYNFIG_LAYER_SET_CVS_ID(Mandelbrot,"$Id$"); /* === P R O C E D U R E S ================================================= */ @@ -111,11 +115,11 @@ Mandelbrot::Mandelbrot(): smooth_outside=true; broken=false; - + bailout=4; lp=log(log(bailout)); } - + bool Mandelbrot::set_param(const String & param, const ValueBase &value) { @@ -126,7 +130,7 @@ Mandelbrot::set_param(const String & param, const ValueBase &value) IMPORT(gradient_offset_outside); IMPORT(gradient_loop_inside); IMPORT(gradient_scale_outside); - + IMPORT(distort_inside); IMPORT(distort_outside); IMPORT(solid_inside); @@ -141,8 +145,8 @@ Mandelbrot::set_param(const String & param, const ValueBase &value) IMPORT(gradient_inside); IMPORT(gradient_outside); - - if(param=="iterations" && value.same_as(iterations)) + + if(param=="iterations" && value.same_type_as(iterations)) { iterations=value.get(iterations); if(iterations<0) @@ -151,7 +155,7 @@ Mandelbrot::set_param(const String & param, const ValueBase &value) iterations=500000; return true; } - if(param=="bailout" && value.same_as(bailout)) + if(param=="bailout" && value.same_type_as(bailout)) { bailout=value.get(bailout); bailout*=bailout; @@ -188,22 +192,22 @@ Mandelbrot::get_param(const String & param)const EXPORT(gradient_inside); EXPORT(gradient_outside); - + if(param=="bailout") return sqrt(bailout); EXPORT_NAME(); EXPORT_VERSION(); - - return ValueBase(); + + return ValueBase(); } Layer::Vocab Mandelbrot::get_param_vocab()const { Layer::Vocab ret; - - + + ret.push_back(ParamDesc("iterations") .set_local_name(_("Iterations")) ); @@ -216,7 +220,7 @@ Mandelbrot::get_param_vocab()const .set_description(_("Modify equation to achieve interesting results")) ); - + ret.push_back(ParamDesc("distort_inside") .set_local_name(_("Distort Inside")) .set_group(_("Inside")) @@ -279,7 +283,7 @@ Mandelbrot::get_param_vocab()const .set_local_name(_("Scale Outside")) .set_group(_("Outside")) ); - + return ret; } @@ -290,18 +294,18 @@ Mandelbrot::get_color(Context context, const Point &pos)const cr, ci, zr, zi, zr_hold; - + ColorReal depth, mag; - + Color ret; - + zr=zi=0; cr=pos[0]; ci=pos[1]; - + for(int i=0;ibailout) - { + { if(smooth_outside) { // Darco's original mandelbrot smoothing algo @@ -334,7 +338,7 @@ Mandelbrot::get_color(Context context, const Point &pos)const ColorReal amount(depth/static_cast(iterations)); amount=amount*gradient_scale_outside+gradient_offset_outside; amount-=floor(amount); - + if(solid_outside) ret=gradient_outside(amount); else @@ -343,7 +347,7 @@ Mandelbrot::get_color(Context context, const Point &pos)const ret=context.get_color(Point(pos[0]+zr,pos[1]+zi)); else ret=context.get_color(pos); - + if(invert_outside) ret=~ret; @@ -351,7 +355,7 @@ Mandelbrot::get_color(Context context, const Point &pos)const ret=Color::blend(gradient_outside(amount), ret, 1.0); } - + return ret; } } @@ -368,13 +372,13 @@ Mandelbrot::get_color(Context context, const Point &pos)const ret=context.get_color(Point(pos[0]+zr,pos[1]+zi)); else ret=context.get_color(pos); - + if(invert_inside) ret=~ret; if(shade_inside) ret=Color::blend(gradient_inside(amount), ret, 1.0); } - + return ret; }