1 //----------------------------------------------------------------------------
2 // Anti-Grain Geometry - Version 2.3
3 // Copyright (C) 2002-2005 Maxim Shemanarev (http://www.antigrain.com)
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.
10 //----------------------------------------------------------------------------
11 // Contact: mcseem@antigrain.com
12 // mcseemagg@yahoo.com
13 // http://www.antigrain.com
14 //----------------------------------------------------------------------------
16 // Terminal markers generator (arrowhead/arrowtail)
18 //----------------------------------------------------------------------------
20 #include "agg_vcgen_markers_term.h"
25 //------------------------------------------------------------------------
26 void vcgen_markers_term::remove_all()
28 m_markers
.remove_all();
32 //------------------------------------------------------------------------
33 void vcgen_markers_term::add_vertex(double x
, double y
, unsigned cmd
)
37 if(m_markers
.size() & 1)
39 // Initial state, the first coordinate was added.
40 // If two of more calls of start_vertex() occures
41 // we just modify the last one.
42 m_markers
.modify_last(coord_type(x
, y
));
46 m_markers
.add(coord_type(x
, y
));
53 if(m_markers
.size() & 1)
55 // Initial state, the first coordinate was added.
56 // Add three more points, 0,1,1,0
57 m_markers
.add(coord_type(x
, y
));
58 m_markers
.add(m_markers
[m_markers
.size() - 1]);
59 m_markers
.add(m_markers
[m_markers
.size() - 3]);
65 // Replace two last points: 0,1,1,0 -> 0,1,2,1
66 m_markers
[m_markers
.size() - 1] = m_markers
[m_markers
.size() - 2];
67 m_markers
[m_markers
.size() - 2] = coord_type(x
, y
);
75 //------------------------------------------------------------------------
76 void vcgen_markers_term::rewind(unsigned id
)
79 m_curr_idx
= m_curr_id
;
83 //------------------------------------------------------------------------
84 unsigned vcgen_markers_term::vertex(double* x
, double* y
)
86 if(m_curr_id
> 2 || m_curr_idx
>= m_markers
.size())
90 const coord_type
& c
= m_markers
[m_curr_idx
];
96 return path_cmd_line_to
;
99 return path_cmd_move_to
;