forked from aseprite/aseprite
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmask_boundaries.h
66 lines (49 loc) · 1.55 KB
/
mask_boundaries.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
// Aseprite Document Library
// Copyright (c) 2020 Igara Studio S.A.
// Copyright (c) 2001-2015 David Capello
//
// This file is released under the terms of the MIT license.
// Read LICENSE.txt for more information.
#ifndef DOC_MASK_BOUNDARIES_H_INCLUDED
#define DOC_MASK_BOUNDARIES_H_INCLUDED
#pragma once
#include "gfx/path.h"
#include "gfx/rect.h"
#include <vector>
namespace doc {
class Image;
class MaskBoundaries {
public:
class Segment {
public:
Segment(bool open, const gfx::Rect& bounds) : m_open(open), m_bounds(bounds) {}
// Returns true if this segment enters into the boundaries.
bool open() const { return m_open; }
const gfx::Rect& bounds() const { return m_bounds; }
void offset(int x, int y) { m_bounds.offset(x, y); }
bool vertical() const { return m_bounds.w == 0; }
bool horizontal() const { return m_bounds.h == 0; }
private:
bool m_open;
gfx::Rect m_bounds;
friend class MaskBoundaries;
};
typedef std::vector<Segment> list_type;
typedef list_type::iterator iterator;
typedef list_type::const_iterator const_iterator;
bool isEmpty() const { return m_segs.empty(); }
void reset();
void regen(const Image* bitmap);
const_iterator begin() const { return m_segs.begin(); }
const_iterator end() const { return m_segs.end(); }
iterator begin() { return m_segs.begin(); }
iterator end() { return m_segs.end(); }
void offset(int x, int y);
gfx::Path& path() { return m_path; }
void createPathIfNeeeded();
private:
list_type m_segs;
gfx::Path m_path;
};
} // namespace doc
#endif