Remove .gitignore do nothing is ignored.
[synfig.git] / synfig-core / trunk / src / modules / lyr_std / mandelbrot.cpp
index 70a762f..bacbbda 100644 (file)
@@ -1,18 +1,23 @@
-/*! ========================================================================
-** 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 Implementation of the "Mandelbrot Set" layer
 **
-** 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
+**     Copyright (c) 2007 Chris Moore
 **
-** 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 ===========================================================
 **
 
 #include "mandelbrot.h"
 
-#include <sinfg/string.h>
-#include <sinfg/time.h>
-#include <sinfg/context.h>
-#include <sinfg/paramdesc.h>
-#include <sinfg/renddesc.h>
-#include <sinfg/surface.h>
-#include <sinfg/value.h>
-#include <sinfg/valuenode.h>
+#include <synfig/string.h>
+#include <synfig/time.h>
+#include <synfig/context.h>
+#include <synfig/paramdesc.h>
+#include <synfig/renddesc.h>
+#include <synfig/surface.h>
+#include <synfig/value.h>
+#include <synfig/valuenode.h>
 
 #endif
 
 
 /* === 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,N_("Mandelbrot Set"));
+SYNFIG_LAYER_SET_CATEGORY(Mandelbrot,N_("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 +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)
 {
@@ -126,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);
@@ -141,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)
@@ -151,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;
@@ -188,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"))
        );
@@ -216,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"))
@@ -279,7 +284,7 @@ Mandelbrot::get_param_vocab()const
                .set_local_name(_("Scale Outside"))
                .set_group(_("Outside"))
        );
-               
+
        return ret;
 }
 
@@ -290,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;i<iterations;i++)
        {
                // Perform complex multiplication
@@ -310,12 +315,12 @@ Mandelbrot::get_color(Context context, const Point &pos)const
                if(broken)zr+=zi; // Use "broken" algorithm, if requested (looks weird)
                zi=zr_hold*zi*2 + ci;
 
-               
+
                // Calculate Magnitude
                mag=zr*zr+zi*zi;
 
                if(mag>bailout)
-               {       
+               {
                        if(smooth_outside)
                        {
                                // Darco's original mandelbrot smoothing algo
@@ -334,7 +339,7 @@ Mandelbrot::get_color(Context context, const Point &pos)const
                        ColorReal amount(depth/static_cast<ColorReal>(iterations));
                        amount=amount*gradient_scale_outside+gradient_offset_outside;
                        amount-=floor(amount);
-                       
+
                        if(solid_outside)
                                ret=gradient_outside(amount);
                        else
@@ -343,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;
 
@@ -351,7 +356,7 @@ Mandelbrot::get_color(Context context, const Point &pos)const
                                        ret=Color::blend(gradient_outside(amount), ret, 1.0);
                        }
 
-                       
+
                        return ret;
                }
        }
@@ -368,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;
 }