1 /* === S Y N F I G ========================================================= */
3 ** \brief Template Header
8 ** Copyright (c) 2002-2005 Robert B. Quattlebaum Jr., Adrian Bentley
10 ** This package is free software; you can redistribute it and/or
11 ** modify it under the terms of the GNU General Public License as
12 ** published by the Free Software Foundation; either version 2 of
13 ** the License, or (at your option) any later version.
15 ** This package is distributed in the hope that it will be useful,
16 ** but WITHOUT ANY WARRANTY; without even the implied warranty of
17 ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
18 ** General Public License for more details.
21 ** === N O T E S ===========================================================
23 ** ========================================================================= */
25 /* === H E A D E R S ======================================================= */
35 #include <ETL/stringf>
37 #include <ETL/hermite>
39 #include <synfig/string.h>
40 #include <synfig/time.h>
41 #include <synfig/context.h>
42 #include <synfig/paramdesc.h>
43 #include <synfig/renddesc.h>
44 #include <synfig/surface.h>
45 #include <synfig/value.h>
46 #include <synfig/valuenode.h>
47 #include <synfig/segment.h>
53 /* === M A C R O S ========================================================= */
57 /* === G L O B A L S ======================================================= */
59 SYNFIG_LAYER_INIT(Star);
60 SYNFIG_LAYER_SET_NAME(Star,"star");
61 SYNFIG_LAYER_SET_LOCAL_NAME(Star,_("Star"));
62 SYNFIG_LAYER_SET_CATEGORY(Star,_("Geometry"));
63 SYNFIG_LAYER_SET_VERSION(Star,"0.1");
64 SYNFIG_LAYER_SET_CVS_ID(Star,"$Id$");
66 /* === P R O C E D U R E S ================================================= */
68 /* === M E T H O D S ======================================================= */
70 /* === E N T R Y P O I N T ================================================= */
76 angle(Angle::deg(90)),
77 regular_polygon(false)
85 Angle dist_between_points(Angle::rot(1)/float(points));
86 std::vector<Point> vector_list;
91 Angle dist1(dist_between_points*i+angle);
92 Angle dist2(dist_between_points*i+dist_between_points/2+angle);
93 vector_list.push_back(Point(Angle::cos(dist1).get()*radius1,Angle::sin(dist1).get()*radius1));
95 vector_list.push_back(Point(Angle::cos(dist2).get()*radius2,Angle::sin(dist2).get()*radius2));
98 add_polygon(vector_list);
102 Star::set_param(const String & param, const ValueBase &value)
104 if( param=="radius1" && value.same_type_as(radius1))
111 if( param=="radius2" && value.same_type_as(radius2))
118 if( param=="points" && value.same_type_as(points))
121 if(points<2)points=2;
126 if( param=="angle" && value.same_type_as(angle))
133 if(param=="regular_polygon" && value.same_type_as(regular_polygon))
135 value.put(®ular_polygon);
140 if(param=="vector_list")
143 return Layer_Polygon::set_param(param,value);
147 Star::get_param(const String& param)const
153 EXPORT(regular_polygon);
158 if(param=="vector_list")
161 return Layer_Polygon::get_param(param);
165 Star::get_param_vocab()const
167 Layer::Vocab ret(Layer_Polygon::get_param_vocab());
169 // Pop off the polygon parameter from the polygon vocab
172 ret.push_back(ParamDesc("radius1")
173 .set_local_name(_("Outer Radius"))
174 .set_description(_("The radius of the outer points in the star"))
176 .set_origin("offset")
179 ret.push_back(ParamDesc("radius2")
180 .set_local_name(_("Inner Radius"))
181 .set_description(_("The radius of the inner points in the star"))
183 .set_origin("offset")
186 ret.push_back(ParamDesc("angle")
187 .set_local_name(_("Angle"))
188 .set_description(_("The orientation of the star"))
189 .set_origin("offset")
192 ret.push_back(ParamDesc("points")
193 .set_local_name(_("Points"))
194 .set_description(_("The number of points in the star"))
197 ret.push_back(ParamDesc("regular_polygon")
198 .set_local_name(_("Regular Polygon"))
199 .set_description(_("Whether to draw a star or a regular polygon"))