eb2b7b7f33d953a64cfca28f7eca015212910bff
[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 #ifdef TRANSFORM_BEZIERS_TO_PATH
13 #include "gmprat.h"
14 #endif
15
16 #endif
17
18 namespace IPDF
19 {
20         
21         struct Colour
22         {
23                 uint8_t r; uint8_t g; uint8_t b; uint8_t a;
24                 Colour() = default;
25                 Colour(uint8_t _r, uint8_t _g, uint8_t _b, uint8_t _a) : r(_r), g(_g), b(_b), a(_a) {}
26                 bool operator==(const Colour & c) const
27                 {
28                         return (r == c.r && g == c.g && b == c.b && a == c.a);
29                 }
30                 bool operator!=(const Colour & c) const {return !this->operator==(c);}
31         };
32         
33         class Objects;
34         class View;
35         
36         struct Path
37         {
38                 Path(Objects & objects, unsigned _start, unsigned _end, const Colour & _fill = Colour(128,128,128,255), const Colour & _stroke = Colour(0,0,0,0));
39                 
40                 Rect SolveBounds(const Objects & objects);
41                 Rect & GetBounds(Objects & objects);
42                 std::vector<Vec2> & FillPoints(const Objects & objects, const View & view);
43                 
44                 // Is point inside shape?
45                 bool PointInside(const Objects & objects, const Vec2 & pt, bool debug=false) const;
46                 
47                 unsigned m_start; // First bounding Bezier index
48                 unsigned m_end; // Last (inclusive) '' ''
49                 unsigned m_index; // index into Objects array
50                 
51                 Vec2 m_top;
52                 Vec2 m_bottom;
53                 Vec2 m_left;
54                 Vec2 m_right;
55                 
56                 std::vector<Vec2> m_fill_points;
57                 
58                 #ifdef TRANSFORM_BEZIERS_TO_PATH
59                 Gmprat x;
60                 Gmprat y;
61                 Gmprat w;
62                 Gmprat h;
63                 #endif
64                 
65                 Colour m_fill;  // colour to fill with  
66                 Colour m_stroke; // colour to outline with
67         };
68
69 }
70 #endif //_PATH_H

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