1 /* === S Y N F I G ========================================================= */
2 /*! \file layer_polygon.cpp
3 ** \brief Implementation of the "Polygon" layer
8 ** Copyright (c) 2002-2005 Robert B. Quattlebaum Jr., Adrian Bentley
9 ** Copyright (c) 2007 Chris Moore
11 ** This package is free software; you can redistribute it and/or
12 ** modify it under the terms of the GNU General Public License as
13 ** published by the Free Software Foundation; either version 2 of
14 ** the License, or (at your option) any later version.
16 ** This package is distributed in the hope that it will be useful,
17 ** but WITHOUT ANY WARRANTY; without even the implied warranty of
18 ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
19 ** General Public License for more details.
22 /* ========================================================================= */
24 /* === H E A D E R S ======================================================= */
33 #include "layer_polygon.h"
37 #include "paramdesc.h"
41 #include "valuenode.h"
42 //#include "ETL/bezier"
50 /* === U S I N G =========================================================== */
52 using namespace synfig;
56 /* === G L O B A L S ======================================================= */
58 SYNFIG_LAYER_INIT(Layer_Polygon);
59 SYNFIG_LAYER_SET_NAME(Layer_Polygon,"polygon");
60 SYNFIG_LAYER_SET_LOCAL_NAME(Layer_Polygon,N_("Polygon"));
61 SYNFIG_LAYER_SET_CATEGORY(Layer_Polygon,N_("Geometry"));
62 SYNFIG_LAYER_SET_VERSION(Layer_Polygon,"0.1");
63 SYNFIG_LAYER_SET_CVS_ID(Layer_Polygon,"$Id$");
65 /* === C L A S S E S ======================================================= */
67 /* === M E T H O D S ======================================================= */
69 Layer_Polygon::Layer_Polygon():
70 Layer_Shape (1.0,Color::BLEND_COMPOSITE),
73 vector_list.push_back(Point(0,0.5));
74 vector_list.push_back(Point(-0.333333,0));
75 vector_list.push_back(Point(0.333333,0));
79 Layer_Polygon::~Layer_Polygon()
87 int i,pointcount=vector_list.size();
92 //Layer_Shape::clear();
96 move_to(vector_list[0][0],vector_list[0][1]);
98 for(i = 1;i < pointcount; i++)
100 if(isnan(vector_list[i][0]) || isnan(vector_list[i][1]))
102 line_to(vector_list[i][0],vector_list[i][1]);
110 Layer_Polygon::add_polygon(const std::vector<Point> &point_list)
112 int i,pointcount=point_list.size();
117 //Layer_Shape::clear();
121 move_to(point_list[0][0],point_list[0][1]);
123 for(i = 1;i < pointcount; i++)
125 if(isnan(point_list[i][0]) || isnan(point_list[i][1]))
127 line_to(point_list[i][0],point_list[i][1]);
134 Layer_Polygon::clear()
136 Layer_Shape::clear();
141 Layer_Polygon::set_param(const String & param, const ValueBase &value)
143 if( param=="vector_list" && value.same_type_as(vector_list))
146 Layer_Shape::clear();
152 return Layer_Shape::set_param(param,value);
156 Layer_Polygon::get_param(const String ¶m)const
163 return Layer_Shape::get_param(param);
167 Layer_Polygon::get_param_vocab()const
169 Layer::Vocab ret(Layer_Shape::get_param_vocab());
171 ret.push_back(ParamDesc("vector_list")
172 .set_local_name(_("Vector List"))
173 .set_origin("origin")