xref: /haiku/headers/libs/agg/agg_vcgen_stroke.h (revision 95bac3fda53a4cb21880712d7b43f8c21db32a2e)
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 #ifndef AGG_VCGEN_STROKE_INCLUDED
17 #define AGG_VCGEN_STROKE_INCLUDED
18 
19 #include "agg_math_stroke.h"
20 #include "agg_vertex_iterator.h"
21 
22 
23 namespace agg
24 {
25 
26     //============================================================vcgen_stroke
27     //
28     // See Implementation agg_vcgen_stroke.cpp
29     // Stroke generator
30     //
31     //------------------------------------------------------------------------
32     class vcgen_stroke
33     {
34         enum status_e
35         {
36             initial,
37             ready,
38             cap1,
39             cap2,
40             outline1,
41             close_first,
42             outline2,
43             out_vertices,
44             end_poly1,
45             end_poly2,
46             stop
47         };
48 
49     public:
50         typedef vertex_sequence<vertex_dist, 6> vertex_storage;
51         typedef pod_deque<point_type, 6>        coord_storage;
52 
53         vcgen_stroke();
54 
55         void line_cap(line_cap_e lc) { m_line_cap = lc; }
56         void line_join(line_join_e lj) { m_line_join = lj; }
57         void inner_line_join(line_join_e lj) { m_inner_line_join = lj; }
58 
59         line_cap_e line_cap() const { return m_line_cap; }
60         line_join_e line_join() const { return m_line_join; }
61         line_join_e inner_line_join() const { return m_inner_line_join; }
62 
63         void width(double w) { m_width = w * 0.5; }
64         void miter_limit(double ml) { m_miter_limit = ml; }
65         void miter_limit_theta(double t);
66         void inner_miter_limit(double ml) { m_inner_miter_limit = ml; }
67         void approximation_scale(double as) { m_approx_scale = as; }
68 
69         double width() const { return m_width * 2.0; }
70         double miter_limit() const { return m_miter_limit; }
71         double inner_miter_limit() const { return m_inner_miter_limit; }
72         double approximation_scale() const { return m_approx_scale; }
73 
74         void shorten(double s) { m_shorten = s; }
75         double shorten() const { return m_shorten; }
76 
77         // Vertex Generator Interface
78         void remove_all();
79         void add_vertex(double x, double y, unsigned cmd);
80 
81         // Vertex Source Interface
82         void     rewind(unsigned id);
83         unsigned vertex(double* x, double* y);
84 
85         typedef vcgen_stroke source_type;
86         typedef vertex_iterator<source_type> iterator;
87         iterator begin(unsigned id) { return iterator(*this, id); }
88         iterator end() { return iterator(path_cmd_stop); }
89 
90     private:
91         vcgen_stroke(const vcgen_stroke&);
92         const vcgen_stroke& operator = (const vcgen_stroke&);
93 
94         vertex_storage m_src_vertices;
95         coord_storage  m_out_vertices;
96         double         m_width;
97         double         m_miter_limit;
98         double         m_inner_miter_limit;
99         double         m_approx_scale;
100         double         m_shorten;
101         line_cap_e     m_line_cap;
102         line_join_e    m_line_join;
103         line_join_e    m_inner_line_join;
104         unsigned       m_closed;
105         status_e       m_status;
106         status_e       m_prev_status;
107         unsigned       m_src_vertex;
108         unsigned       m_out_vertex;
109     };
110 
111 
112 }
113 
114 #endif
115