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