summaryrefslogtreecommitdiff
path: root/agg/inc/agg_curves.h
blob: bfb02e91ab96beb543ff6a363d1c2c62933edc9d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
//----------------------------------------------------------------------------
// Anti-Grain Geometry - Version 2.3
// Copyright (C) 2002-2005 Maxim Shemanarev (http://www.antigrain.com)
//
// Permission to copy, use, modify, sell and distribute this software
// is granted provided this copyright notice appears in all copies.
// This software is provided "as is" without express or implied
// warranty, and with no claim as to its suitability for any purpose.
//
//----------------------------------------------------------------------------
// Contact: mcseem@antigrain.com
//          mcseemagg@yahoo.com
//          http://www.antigrain.com
//----------------------------------------------------------------------------
//
// classes curve3 and curve4
//
//----------------------------------------------------------------------------

#ifndef AGG_CURVES_INCLUDED
#define AGG_CURVES_INCLUDED

#include "agg_basics.h"
#include "agg_vertex_iterator.h"

namespace agg
{

    // See Implemantation agg_curves.cpp


    //------------------------------------------------------------------curve3
    class curve3
    {
    public:
        curve3() :
          m_num_steps(0), m_step(0), m_scale(1.0) { }

        curve3(double x1, double y1,
               double x2, double y2,
               double x3, double y3) :
          m_num_steps(0), m_step(0), m_scale(1.0)
        {
            init(x1, y1, x2, y2, x3, y3);
        }

        void reset() { m_num_steps = 0; m_step = -1; }
        void init(double x1, double y1,
                  double x2, double y2,
                  double x3, double y3);
        void approximation_scale(double s) { m_scale = s; }
        double approximation_scale() const { return m_scale;  }

        void     rewind(unsigned id);
        unsigned vertex(double* x, double* y);

        typedef curve3 source_type;
        typedef vertex_iterator<source_type> iterator;
        iterator begin(unsigned id) { return iterator(*this, id); }
        iterator end() { return iterator(path_cmd_stop); }

    private:
        int      m_num_steps;
        int      m_step;
        double   m_scale;
        double   m_start_x;
        double   m_start_y;
        double   m_end_x;
        double   m_end_y;
        double   m_fx;
        double   m_fy;
        double   m_dfx;
        double   m_dfy;
        double   m_ddfx;
        double   m_ddfy;
        double   m_saved_fx;
        double   m_saved_fy;
        double   m_saved_dfx;
        double   m_saved_dfy;
    };







    //-----------------------------------------------------------------curve4
    class curve4
    {
    public:
        curve4() :
          m_num_steps(0), m_step(0), m_scale(1.0) { }

        curve4(double x1, double y1,
               double x2, double y2,
               double x3, double y3,
               double x4, double y4) :
          m_num_steps(0), m_step(0), m_scale(1.0)
        {
            init(x1, y1, x2, y2, x3, y3, x4, y4);
        }

        void reset() { m_num_steps = 0; m_step = -1; }
        void init(double x1, double y1,
                  double x2, double y2,
                  double x3, double y3,
                  double x4, double y4);

        void approximation_scale(double s) { m_scale = s; }
        double approximation_scale() const { return m_scale;  }

        void     rewind(unsigned id);
        unsigned vertex(double* x, double* y);

        typedef curve4 source_type;
        typedef vertex_iterator<source_type> iterator;
        iterator begin(unsigned id) { return iterator(*this, id); }
        iterator end() { return iterator(path_cmd_stop); }

    private:
        int      m_num_steps;
        int      m_step;
        double   m_scale;
        double   m_start_x;
        double   m_start_y;
        double   m_end_x;
        double   m_end_y;
        double   m_fx;
        double   m_fy;
        double   m_dfx;
        double   m_dfy;
        double   m_ddfx;
        double   m_ddfy;
        double   m_dddfx;
        double   m_dddfy;
        double   m_saved_fx;
        double   m_saved_fy;
        double   m_saved_dfx;
        double   m_saved_dfy;
        double   m_saved_ddfx;
        double   m_saved_ddfy;
    };




}

#endif