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

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