c412428a3d072891ae651f59a720572825a58248
[ipdf/code.git] / src / path.h
1 #ifndef _PATH_H
2 #define _PATH_H
3
4 #include "transformationtype.h"
5 #include <vector>
6 #include <algorithm>
7 #include "rect.h"
8 #include "real.h"
9
10 #ifdef TRANSFORM_BEZIERS_TO_PATH
11         #include "gmprat.h"
12         #include "paranoidnumber.h"
13 #endif
14
15
16 namespace IPDF
17 {
18         typedef TRect<PReal> PRect;
19         
20         struct Colour
21         {
22                 uint8_t r; uint8_t g; uint8_t b; uint8_t a;
23                 Colour() = default;
24                 Colour(uint8_t _r, uint8_t _g, uint8_t _b, uint8_t _a) : r(_r), g(_g), b(_b), a(_a) {}
25                 bool operator==(const Colour & c) const
26                 {
27                         return (r == c.r && g == c.g && b == c.b && a == c.a);
28                 }
29                 bool operator!=(const Colour & c) const {return !this->operator==(c);}
30         };
31         
32         class Objects;
33         class View;
34         
35         struct Path
36         {
37                 Path(Objects & objects, unsigned _start, unsigned _end, const Colour & _fill = Colour(128,128,128,255), const Colour & _stroke = Colour(0,0,0,0));
38                 
39                 Rect SolveBounds(const Objects & objects);
40                 Rect & GetBounds(Objects & objects);
41                 std::vector<Vec2> & FillPoints(const Objects & objects, const View & view);
42                 
43                 // Is point inside shape?
44                 bool PointInside(const Objects & objects, const Vec2 & pt, bool debug=false) const;
45                 
46                 unsigned m_start; // First bounding Bezier index
47                 unsigned m_end; // Last (inclusive) '' ''
48                 unsigned m_index; // index into Objects array
49                 
50                 Vec2 m_top;
51                 Vec2 m_bottom;
52                 Vec2 m_left;
53                 Vec2 m_right;
54                 
55                 std::vector<Vec2> m_fill_points;
56                 
57                 PRect m_bounds;
58
59                 
60                 Colour m_fill;  // colour to fill with  
61                 Colour m_stroke; // colour to outline with
62         };
63
64 }
65 #endif //_PATH_H

UCC git Repository :: git.ucc.asn.au