1 /*! ========================================================================
4 ** $Id: star.cpp,v 1.1.1.1 2005/01/04 01:23:10 darco Exp $
6 ** Copyright (c) 2002 Robert B. Quattlebaum Jr.
8 ** This software and associated documentation
9 ** are CONFIDENTIAL and PROPRIETARY property of
10 ** the above-mentioned copyright holder.
12 ** You may not copy, print, publish, or in any
13 ** other way distribute this software without
14 ** a prior written agreement with
15 ** the copyright holder.
17 ** === N O T E S ===========================================================
19 ** ========================================================================= */
21 /* === H E A D E R S ======================================================= */
31 #include <ETL/stringf>
33 #include <ETL/hermite>
35 #include <sinfg/string.h>
36 #include <sinfg/time.h>
37 #include <sinfg/context.h>
38 #include <sinfg/paramdesc.h>
39 #include <sinfg/renddesc.h>
40 #include <sinfg/surface.h>
41 #include <sinfg/value.h>
42 #include <sinfg/valuenode.h>
43 #include <sinfg/segment.h>
49 /* === M A C R O S ========================================================= */
53 /* === G L O B A L S ======================================================= */
55 SINFG_LAYER_INIT(Star);
56 SINFG_LAYER_SET_NAME(Star,"star");
57 SINFG_LAYER_SET_LOCAL_NAME(Star,_("Star"));
58 SINFG_LAYER_SET_CATEGORY(Star,_("Geometry"));
59 SINFG_LAYER_SET_VERSION(Star,"0.1");
60 SINFG_LAYER_SET_CVS_ID(Star,"$Id: star.cpp,v 1.1.1.1 2005/01/04 01:23:10 darco Exp $");
62 /* === P R O C E D U R E S ================================================= */
64 /* === M E T H O D S ======================================================= */
66 /* === E N T R Y P O I N T ================================================= */
80 Angle dist_between_points(Angle::rot(1)/float(points));
81 std::vector<Point> vector_list;
86 Angle dist1(dist_between_points*i+angle);
87 Angle dist2(dist_between_points*i+dist_between_points/2+angle);
88 vector_list.push_back(Point(Angle::cos(dist1).get()*radius1,Angle::sin(dist1).get()*radius1));
89 vector_list.push_back(Point(Angle::cos(dist2).get()*radius2,Angle::sin(dist2).get()*radius2));
92 add_polygon(vector_list);
96 Star::set_param(const String & param, const ValueBase &value)
98 if( param=="radius1" && value.same_as(radius1))
105 if( param=="radius2" && value.same_as(radius2))
112 if( param=="points" && value.same_as(points))
115 if(points<2)points=2;
120 if( param=="angle" && value.same_as(angle))
127 if(param=="vector_list")
130 return Layer_Polygon::set_param(param,value);
134 Star::get_param(const String& param)const
144 if(param=="vector_list")
147 return Layer_Polygon::get_param(param);
151 Star::get_param_vocab()const
153 Layer::Vocab ret(Layer_Polygon::get_param_vocab());
155 // Pop off the polygon parameter from the polygon vocab
158 ret.push_back(ParamDesc("radius1")
159 .set_local_name(_("Outer Radius"))
160 .set_description(_("The radius of the outer points in the star"))
162 .set_origin("offset")
165 ret.push_back(ParamDesc("radius2")
166 .set_local_name(_("Inner Radius"))
167 .set_description(_("The radius of the inner points in the star"))
169 .set_origin("offset")
172 ret.push_back(ParamDesc("angle")
173 .set_local_name(_("Angle"))
174 .set_description(_("The orientation of the star"))
175 .set_origin("offset")
178 ret.push_back(ParamDesc("points")
179 .set_local_name(_("Points"))
180 .set_description(_("The number of points in the star"))