xref: /haiku/headers/libs/agg/agg_curves.h (revision 39241fe22890fb958b6ba32d6ab9526da98be187)
1 //----------------------------------------------------------------------------
2 // Anti-Grain Geometry - Version 2.2
3 // Copyright (C) 2002-2004 Maxim Shemanarev (http://www.antigrain.com)
4 //
5 // Permission to copy, use, modify, sell and distribute this software
6 // is granted provided this copyright notice appears in all copies.
7 // This software is provided "as is" without express or implied
8 // warranty, and with no claim as to its suitability for any purpose.
9 //
10 //----------------------------------------------------------------------------
11 // Contact: mcseem@antigrain.com
12 //          mcseemagg@yahoo.com
13 //          http://www.antigrain.com
14 //----------------------------------------------------------------------------
15 //
16 // classes curve3 and curve4
17 //
18 //----------------------------------------------------------------------------
19 
20 #ifndef AGG_CURVES_INCLUDED
21 #define AGG_CURVES_INCLUDED
22 
23 #include "agg_basics.h"
24 #include "agg_vertex_iterator.h"
25 
26 namespace agg
27 {
28 
29     // See Implemantation agg_curves.cpp
30 
31 
32     //------------------------------------------------------------------curve3
33     class curve3
34     {
35     public:
36         curve3() :
37           m_num_steps(0), m_step(0), m_scale(1.0) { }
38 
39         curve3(double x1, double y1,
40                double x2, double y2,
41                double x3, double y3) :
42           m_num_steps(0), m_step(0), m_scale(1.0)
43         {
44             init(x1, y1, x2, y2, x3, y3);
45         }
46 
47         void reset() { m_num_steps = 0; m_step = -1; }
48         void init(double x1, double y1,
49                   double x2, double y2,
50                   double x3, double y3);
51         void approximation_scale(double s) { m_scale = s; }
52         double approximation_scale() const { return m_scale;  }
53 
54         void     rewind(unsigned id);
55         unsigned vertex(double* x, double* y);
56 
57         typedef curve3 source_type;
58         typedef vertex_iterator<source_type> iterator;
59         iterator begin(unsigned id) { return iterator(*this, id); }
60         iterator end() { return iterator(path_cmd_stop); }
61 
62     private:
63         int      m_num_steps;
64         int      m_step;
65         double   m_scale;
66         double   m_start_x;
67         double   m_start_y;
68         double   m_end_x;
69         double   m_end_y;
70         double   m_fx;
71         double   m_fy;
72         double   m_dfx;
73         double   m_dfy;
74         double   m_ddfx;
75         double   m_ddfy;
76         double   m_saved_fx;
77         double   m_saved_fy;
78         double   m_saved_dfx;
79         double   m_saved_dfy;
80     };
81 
82 
83 
84 
85 
86 
87 
88     //-----------------------------------------------------------------curve4
89     class curve4
90     {
91     public:
92         curve4() :
93           m_num_steps(0), m_step(0), m_scale(1.0) { }
94 
95         curve4(double x1, double y1,
96                double x2, double y2,
97                double x3, double y3,
98                double x4, double y4) :
99           m_num_steps(0), m_step(0), m_scale(1.0)
100         {
101             init(x1, y1, x2, y2, x3, y3, x4, y4);
102         }
103 
104         void reset() { m_num_steps = 0; m_step = -1; }
105         void init(double x1, double y1,
106                   double x2, double y2,
107                   double x3, double y3,
108                   double x4, double y4);
109 
110         void approximation_scale(double s) { m_scale = s; }
111         double approximation_scale() const { return m_scale;  }
112 
113         void     rewind(unsigned id);
114         unsigned vertex(double* x, double* y);
115 
116         typedef curve4 source_type;
117         typedef vertex_iterator<source_type> iterator;
118         iterator begin(unsigned id) { return iterator(*this, id); }
119         iterator end() { return iterator(path_cmd_stop); }
120 
121     private:
122         int      m_num_steps;
123         int      m_step;
124         double   m_scale;
125         double   m_start_x;
126         double   m_start_y;
127         double   m_end_x;
128         double   m_end_y;
129         double   m_fx;
130         double   m_fy;
131         double   m_dfx;
132         double   m_dfy;
133         double   m_ddfx;
134         double   m_ddfy;
135         double   m_dddfx;
136         double   m_dddfy;
137         double   m_saved_fx;
138         double   m_saved_fy;
139         double   m_saved_dfx;
140         double   m_saved_dfy;
141         double   m_saved_ddfx;
142         double   m_saved_ddfy;
143     };
144 
145 
146 
147 
148 }
149 
150 #endif
151