Merge branch 'master' of git.ucc.asn.au:ipdf/code
[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                 #pragma message "Path using Gmprat for bounds"
20                 typedef Gmprat PReal;
21         #else
22                 typedef Real PReal;
23         #endif
24         typedef TRect<PReal> PRect;
25         
26         struct Colour
27         {
28                 uint8_t r; uint8_t g; uint8_t b; uint8_t a;
29                 Colour() = default;
30                 Colour(uint8_t _r, uint8_t _g, uint8_t _b, uint8_t _a) : r(_r), g(_g), b(_b), a(_a) {}
31                 bool operator==(const Colour & c) const
32                 {
33                         return (r == c.r && g == c.g && b == c.b && a == c.a);
34                 }
35                 bool operator!=(const Colour & c) const {return !this->operator==(c);}
36         };
37         
38         class Objects;
39         class View;
40         
41         struct Path
42         {
43                 Path(Objects & objects, unsigned _start, unsigned _end, const Colour & _fill = Colour(128,128,128,255), const Colour & _stroke = Colour(0,0,0,0));
44                 
45                 Rect SolveBounds(const Objects & objects);
46                 Rect & GetBounds(Objects & objects);
47                 std::vector<Vec2> & FillPoints(const Objects & objects, const View & view);
48                 
49                 // Is point inside shape?
50                 bool PointInside(const Objects & objects, const Vec2 & pt, bool debug=false) const;
51                 
52                 unsigned m_start; // First bounding Bezier index
53                 unsigned m_end; // Last (inclusive) '' ''
54                 unsigned m_index; // index into Objects array
55                 
56                 Vec2 m_top;
57                 Vec2 m_bottom;
58                 Vec2 m_left;
59                 Vec2 m_right;
60                 
61                 std::vector<Vec2> m_fill_points;
62                 
63                 PRect m_bounds;
64
65                 
66                 Colour m_fill;  // colour to fill with  
67                 Colour m_stroke; // colour to outline with
68         };
69
70 }
71 #endif //_PATH_H

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