Anti-Grain Geometry - AGG (libagg)
2.5
|
00001 //---------------------------------------------------------------------------- 00002 // Anti-Grain Geometry (AGG) - Version 2.5 00003 // A high quality rendering engine for C++ 00004 // Copyright (C) 2002-2006 Maxim Shemanarev 00005 // Contact: mcseem@antigrain.com 00006 // mcseemagg@yahoo.com 00007 // http://antigrain.com 00008 // 00009 // AGG is free software; you can redistribute it and/or 00010 // modify it under the terms of the GNU General Public License 00011 // as published by the Free Software Foundation; either version 2 00012 // of the License, or (at your option) any later version. 00013 // 00014 // AGG is distributed in the hope that it will be useful, 00015 // but WITHOUT ANY WARRANTY; without even the implied warranty of 00016 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00017 // GNU General Public License for more details. 00018 // 00019 // You should have received a copy of the GNU General Public License 00020 // along with AGG; if not, write to the Free Software 00021 // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, 00022 // MA 02110-1301, USA. 00023 //---------------------------------------------------------------------------- 00024 00025 #ifndef AGG_TRANS_SINGLE_PATH_INCLUDED 00026 #define AGG_TRANS_SINGLE_PATH_INCLUDED 00027 00028 #include "agg_basics.h" 00029 #include "agg_vertex_sequence.h" 00030 00031 namespace agg 00032 { 00033 00034 // See also: agg_trans_single_path.cpp 00035 // 00036 //-------------------------------------------------------trans_single_path 00037 class trans_single_path 00038 { 00039 enum status_e 00040 { 00041 initial, 00042 making_path, 00043 ready 00044 }; 00045 00046 public: 00047 typedef vertex_sequence<vertex_dist, 6> vertex_storage; 00048 00049 trans_single_path(); 00050 00051 //-------------------------------------------------------------------- 00052 void base_length(double v) { m_base_length = v; } 00053 double base_length() const { return m_base_length; } 00054 00055 //-------------------------------------------------------------------- 00056 void preserve_x_scale(bool f) { m_preserve_x_scale = f; } 00057 bool preserve_x_scale() const { return m_preserve_x_scale; } 00058 00059 //-------------------------------------------------------------------- 00060 void reset(); 00061 void move_to(double x, double y); 00062 void line_to(double x, double y); 00063 void finalize_path(); 00064 00065 //-------------------------------------------------------------------- 00066 template<class VertexSource> 00067 void add_path(VertexSource& vs, unsigned path_id=0) 00068 { 00069 double x; 00070 double y; 00071 00072 unsigned cmd; 00073 vs.rewind(path_id); 00074 while(!is_stop(cmd = vs.vertex(&x, &y))) 00075 { 00076 if(is_move_to(cmd)) 00077 { 00078 move_to(x, y); 00079 } 00080 else 00081 { 00082 if(is_vertex(cmd)) 00083 { 00084 line_to(x, y); 00085 } 00086 } 00087 } 00088 finalize_path(); 00089 } 00090 00091 //-------------------------------------------------------------------- 00092 double total_length() const; 00093 void transform(double *x, double *y) const; 00094 00095 private: 00096 vertex_storage m_src_vertices; 00097 double m_base_length; 00098 double m_kindex; 00099 status_e m_status; 00100 bool m_preserve_x_scale; 00101 }; 00102 00103 00104 } 00105 00106 #endif