X-Git-Url: https://git.pterodactylus.net/?a=blobdiff_plain;f=synfig-core%2Ftrunk%2Fsrc%2Fmodules%2Flyr_std%2Fmandelbrot.cpp;h=bacbbdaac77009c7001a4c67b6bdfa531e989c75;hb=334e15ce6c4d9b1f30a168a55e7ef4d31320d568;hp=a77d44a39df795b53d187b378e952a632abad8ed;hpb=21bfc670b83d4c45da9ed1b95063b7e6a007168c;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 a77d44a..bacbbda 100644 --- a/synfig-core/trunk/src/modules/lyr_std/mandelbrot.cpp +++ b/synfig-core/trunk/src/modules/lyr_std/mandelbrot.cpp @@ -1,9 +1,12 @@ -/*! ======================================================================== -** Synfig -** 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 Implementation of the "Mandelbrot Set" layer ** +** $Id$ +** +** \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 @@ -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 =========================================================== ** @@ -49,10 +53,10 @@ 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_LOCAL_NAME(Mandelbrot,N_("Mandelbrot Set")); +SYNFIG_LAYER_SET_CATEGORY(Mandelbrot,N_("Fractals")); SYNFIG_LAYER_SET_VERSION(Mandelbrot,"0.2"); -SYNFIG_LAYER_SET_CVS_ID(Mandelbrot,"$Id: mandelbrot.cpp,v 1.1.1.1 2005/01/04 01:23:10 darco Exp $"); +SYNFIG_LAYER_SET_CVS_ID(Mandelbrot,"$Id$"); /* === P R O C E D U R E S ================================================= */ @@ -112,11 +116,11 @@ Mandelbrot::Mandelbrot(): smooth_outside=true; broken=false; - + bailout=4; lp=log(log(bailout)); } - + bool Mandelbrot::set_param(const String & param, const ValueBase &value) { @@ -127,7 +131,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); @@ -142,8 +146,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) @@ -152,7 +156,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; @@ -189,22 +193,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")) ); @@ -217,7 +221,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")) @@ -280,7 +284,7 @@ Mandelbrot::get_param_vocab()const .set_local_name(_("Scale Outside")) .set_group(_("Outside")) ); - + return ret; } @@ -291,18 +295,18 @@ Mandelbrot::get_color(Context context, const Point &pos)const cr, ci, zr, zi, zr_hold; - + ColorReal - depth, mag; - + depth, mag(0); + 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 @@ -335,7 +339,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 @@ -344,7 +348,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; @@ -352,7 +356,7 @@ Mandelbrot::get_color(Context context, const Point &pos)const ret=Color::blend(gradient_outside(amount), ret, 1.0); } - + return ret; } } @@ -369,13 +373,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; }