Remove .gitignore do nothing is ignored.
[synfig.git] / synfig-core / trunk / src / modules / mod_geometry / star.cpp
index a85aa2c..cb1d8e6 100644 (file)
@@ -1,9 +1,12 @@
-/*! ========================================================================
-** Synfig
-** Template File
-** $Id: star.cpp,v 1.1.1.1 2005/01/04 01:23:10 darco Exp $
+/* === S Y N F I G ========================================================= */
+/*!    \file star.cpp
+**     \brief Implementation of the "Star" layer
 **
+**     $Id$
+**
+**     \legal
 **     Copyright (c) 2002-2005 Robert B. Quattlebaum Jr., Adrian Bentley
+**     Copyright (c) 2007-2008 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 ===========================================================
 **
@@ -55,10 +59,10 @@ using namespace etl;
 
 SYNFIG_LAYER_INIT(Star);
 SYNFIG_LAYER_SET_NAME(Star,"star");
-SYNFIG_LAYER_SET_LOCAL_NAME(Star,_("Star"));
-SYNFIG_LAYER_SET_CATEGORY(Star,_("Geometry"));
+SYNFIG_LAYER_SET_LOCAL_NAME(Star,N_("Star"));
+SYNFIG_LAYER_SET_CATEGORY(Star,N_("Geometry"));
 SYNFIG_LAYER_SET_VERSION(Star,"0.1");
-SYNFIG_LAYER_SET_CVS_ID(Star,"$Id: star.cpp,v 1.1.1.1 2005/01/04 01:23:10 darco Exp $");
+SYNFIG_LAYER_SET_CVS_ID(Star,"$Id$");
 
 /* === P R O C E D U R E S ================================================= */
 
@@ -70,7 +74,8 @@ Star::Star():
        radius1(1.0),
        radius2(0.38),
        points(5),
-       angle(Angle::deg(90))
+       angle(Angle::deg(90)),
+       regular_polygon(false)
 {
        sync();
 }
@@ -80,14 +85,15 @@ Star::sync()
 {
        Angle dist_between_points(Angle::rot(1)/float(points));
        std::vector<Point> vector_list;
-       
+
        int i;
        for(i=0;i<points;i++)
        {
                Angle dist1(dist_between_points*i+angle);
                Angle dist2(dist_between_points*i+dist_between_points/2+angle);
                vector_list.push_back(Point(Angle::cos(dist1).get()*radius1,Angle::sin(dist1).get()*radius1));
-               vector_list.push_back(Point(Angle::cos(dist2).get()*radius2,Angle::sin(dist2).get()*radius2));
+               if (!regular_polygon)
+                       vector_list.push_back(Point(Angle::cos(dist2).get()*radius2,Angle::sin(dist2).get()*radius2));
        }
        clear();
        add_polygon(vector_list);
@@ -96,21 +102,21 @@ Star::sync()
 bool
 Star::set_param(const String & param, const ValueBase &value)
 {
-       if(     param=="radius1" && value.same_as(radius1))
+       if(     param=="radius1" && value.same_type_as(radius1))
        {
                value.put(&radius1);
                sync();
                return true;
        }
 
-       if(     param=="radius2" && value.same_as(radius2))
+       if(     param=="radius2" && value.same_type_as(radius2))
        {
                value.put(&radius2);
                sync();
                return true;
        }
 
-       if(     param=="points" && value.same_as(points))
+       if(     param=="points" && value.same_type_as(points))
        {
                value.put(&points);
                if(points<2)points=2;
@@ -118,13 +124,20 @@ Star::set_param(const String & param, const ValueBase &value)
                return true;
        }
 
-       if(     param=="angle" && value.same_as(angle))
+       if(     param=="angle" && value.same_type_as(angle))
        {
                value.put(&angle);
                sync();
                return true;
        }
 
+       if(param=="regular_polygon" && value.same_type_as(regular_polygon))
+       {
+               value.put(&regular_polygon);
+               sync();
+               return true;
+       }
+
        if(param=="vector_list")
                return false;
 
@@ -138,12 +151,13 @@ Star::get_param(const String& param)const
        EXPORT(radius2);
        EXPORT(points);
        EXPORT(angle);
+       EXPORT(regular_polygon);
 
        EXPORT_NAME();
        EXPORT_VERSION();
 
        if(param=="vector_list")
-               return ValueBase();     
+               return ValueBase();
 
        return Layer_Polygon::get_param(param);
 }
@@ -160,20 +174,20 @@ Star::get_param_vocab()const
                .set_local_name(_("Outer Radius"))
                .set_description(_("The radius of the outer points in the star"))
                .set_is_distance()
-               .set_origin("offset")
+               .set_origin("origin")
        );
 
        ret.push_back(ParamDesc("radius2")
                .set_local_name(_("Inner Radius"))
                .set_description(_("The radius of the inner points in the star"))
                .set_is_distance()
-               .set_origin("offset")
+               .set_origin("origin")
        );
 
        ret.push_back(ParamDesc("angle")
                .set_local_name(_("Angle"))
                .set_description(_("The orientation of the star"))
-               .set_origin("offset")
+               .set_origin("origin")
        );
 
        ret.push_back(ParamDesc("points")
@@ -181,5 +195,10 @@ Star::get_param_vocab()const
                .set_description(_("The number of points in the star"))
        );
 
+       ret.push_back(ParamDesc("regular_polygon")
+               .set_local_name(_("Regular Polygon"))
+               .set_description(_("Whether to draw a star or a regular polygon"))
+       );
+
        return ret;
 }