1 /* === S Y N F I G ========================================================= */
2 /*! \file layer_polygon.cpp
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 /* ========================================================================= */
23 /* === H E A D E R S ======================================================= */
32 #include "layer_polygon.h"
36 #include "paramdesc.h"
40 #include "valuenode.h"
41 //#include "ETL/bezier"
49 /* === U S I N G =========================================================== */
51 using namespace synfig;
55 /* === G L O B A L S ======================================================= */
57 SYNFIG_LAYER_INIT(Layer_Polygon);
58 SYNFIG_LAYER_SET_NAME(Layer_Polygon,"polygon");
59 SYNFIG_LAYER_SET_LOCAL_NAME(Layer_Polygon,_("Polygon"));
60 SYNFIG_LAYER_SET_CATEGORY(Layer_Polygon,_("Geometry"));
61 SYNFIG_LAYER_SET_VERSION(Layer_Polygon,"0.1");
62 SYNFIG_LAYER_SET_CVS_ID(Layer_Polygon,"$Id$");
64 /* === C L A S S E S ======================================================= */
66 /* === M E T H O D S ======================================================= */
68 Layer_Polygon::Layer_Polygon():
69 Layer_Shape (1.0,Color::BLEND_COMPOSITE),
72 vector_list.push_back(Point(0,0.5));
73 vector_list.push_back(Point(-0.333333,0));
74 vector_list.push_back(Point(0.333333,0));
78 Layer_Polygon::~Layer_Polygon()
86 int i,pointcount=vector_list.size();
91 //Layer_Shape::clear();
95 move_to(vector_list[0][0],vector_list[0][1]);
97 for(i = 1;i < pointcount; i++)
99 if(isnan(vector_list[i][0]) || isnan(vector_list[i][1]))
101 line_to(vector_list[i][0],vector_list[i][1]);
109 Layer_Polygon::add_polygon(const vector<Point> &point_list)
111 int i,pointcount=point_list.size();
116 //Layer_Shape::clear();
120 move_to(point_list[0][0],point_list[0][1]);
122 for(i = 1;i < pointcount; i++)
124 if(isnan(point_list[i][0]) || isnan(point_list[i][1]))
126 line_to(point_list[i][0],point_list[i][1]);
133 Layer_Polygon::clear()
135 Layer_Shape::clear();
140 Layer_Polygon::set_param(const String & param, const ValueBase &value)
142 if( param=="vector_list" && value.same_as(vector_list))
145 Layer_Shape::clear();
151 return Layer_Shape::set_param(param,value);
155 Layer_Polygon::get_param(const String ¶m)const
162 return Layer_Shape::get_param(param);
166 Layer_Polygon::get_param_vocab()const
168 Layer::Vocab ret(Layer_Shape::get_param_vocab());
170 ret.push_back(ParamDesc("vector_list")
171 .set_local_name(_("Vector List"))
172 .set_origin("offset")