Some really horrible utility Quadtree functions.
[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 namespace IPDF
10 {
11         
12         struct Colour
13         {
14                 uint8_t r; uint8_t g; uint8_t b; uint8_t a;
15                 Colour() = default;
16                 Colour(uint8_t _r, uint8_t _g, uint8_t _b, uint8_t _a) : r(_r), g(_g), b(_b), a(_a) {}
17                 bool operator==(const Colour & c) const
18                 {
19                         return (r == c.r && g == c.g && b == c.b && a == c.a);
20                 }
21                 bool operator!=(const Colour & c) const {return !this->operator==(c);}
22         };
23         
24         class Objects;
25         class View;
26         
27         struct Path
28         {
29                 Path(const Objects & objects, unsigned _start, unsigned _end, const Colour & _fill = Colour(128,128,128,255), const Colour & _stroke = Colour(0,0,0,0));
30                 
31                 Rect SolveBounds(const Objects & objects) const;
32                 std::vector<Vec2> & FillPoints(const Objects & objects, const View & view);
33                 
34                 // Is point inside shape?
35                 bool PointInside(const Objects & objects, const Vec2 & pt, bool debug=false) const;
36                 
37                 unsigned m_start; // First bounding Bezier index
38                 unsigned m_end; // Last (inclusive) '' ''
39                 unsigned m_index; // index into Objects array
40                 
41                 Vec2 m_top;
42                 Vec2 m_bottom;
43                 Vec2 m_left;
44                 Vec2 m_right;
45                 
46                 std::vector<Vec2> m_fill_points;
47                 
48                 Colour m_fill;  // colour to fill with  
49                 Colour m_stroke; // colour to outline with
50         };
51
52 }
53 #endif //_PATH_H

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