MCPcopy Create free account
hub / github.com/LemonOSProject/LemonOS / Split

Method Split

LibLemon/include/lemon/gfx/types.h:51–104  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

49 int bottom(int newBottom) { height += newBottom - (y + height); return y + height; }
50
51 std::list<Rect> Split(Rect cut){
52 std::list<Rect> clips;
53 Rect victim = *this;
54
55 if(cut.left() >= victim.left() && cut.left() <= victim.right()) { // Clip left edge
56 Rect clip;
57 clip.top(victim.top());
58 clip.left(victim.left());
59 clip.bottom(victim.bottom());
60 clip.right(cut.left()); // Left of cutting rect's left edge
61
62 victim.left(cut.left());
63
64 clips.push_back(clip);
65 }
66
67 if(cut.top() >= victim.top() && cut.top() <= victim.bottom()) { // Clip top edge
68 Rect clip;
69 clip.top(victim.top());
70 clip.left(victim.left());
71 clip.bottom(cut.top()); // Above cutting rect's top edge
72 clip.right(victim.right());
73
74 victim.top(cut.top());
75
76 clips.push_back(clip);
77 }
78
79 if(cut.right() >= victim.left() && cut.right() <= victim.right()) { // Clip right edge
80 Rect clip;
81 clip.top(victim.top());
82 clip.left(cut.right());
83 clip.bottom(victim.bottom());
84 clip.right(victim.right());
85
86 victim.right(cut.right());
87
88 clips.push_back(clip);
89 }
90
91 if(cut.bottom() >= victim.top() && cut.bottom() <= victim.bottom()) { // Clip bottom edge
92 Rect clip;
93 clip.top(cut.bottom());
94 clip.left(victim.left());
95 clip.bottom(victim.bottom());
96 clip.right(victim.right());
97
98 victim.bottom(cut.bottom());
99
100 clips.push_back(clip);
101 }
102
103 return clips;
104 }
105} rect_t; // Rectangle
106
107typedef struct RGBAColour{

Callers 2

PaintMethod · 0.80
mainFunction · 0.80

Calls 4

leftMethod · 0.80
rightMethod · 0.80
topMethod · 0.80
bottomMethod · 0.80

Tested by

no test coverage detected