Commit 9aa20c50 authored by captainwong's avatar captainwong

fix some bug about rc op

parent e40ba8f1
...@@ -150,15 +150,15 @@ inline auto Height(LPCRECT rc) { ...@@ -150,15 +150,15 @@ inline auto Height(LPCRECT rc) {
inline void DeflateRect(LPRECT rc, int l, int t, int r, int b) { inline void DeflateRect(LPRECT rc, int l, int t, int r, int b) {
rc->left += l; rc->left += l;
rc->top += t; rc->top += t;
rc->right += r; rc->right -= r;
rc->bottom += b; rc->bottom -= b;
} }
inline void InflateRect(LPRECT rc, int l, int t, int r, int b) { inline void InflateRect(LPRECT rc, int l, int t, int r, int b) {
rc->left -= l; rc->left -= l;
rc->top -= t; rc->top -= t;
rc->right -= r; rc->right += r;
rc->bottom -= b; rc->bottom += b;
} }
} }
...@@ -189,14 +189,18 @@ inline std::vector<RECT> split_rect(LPCRECT rc, int n, int gap = 50) { ...@@ -189,14 +189,18 @@ inline std::vector<RECT> split_rect(LPCRECT rc, int n, int gap = 50) {
return v; return v;
}; };
// 将矩形水平平均分割为n份矩形,间距为wgap // 将矩形水平平均分割为n份矩形, 当hgap==-1时,分割出的矩形与源矩形保持比例
inline std::vector<RECT> split_rect_horizontal(LPCRECT rc, int n, int wgap = 50) { inline std::vector<RECT> split_rect_horizontal(LPCRECT rc, int n, int wgap = 50, int hgap = -1) {
using namespace detail; using namespace detail;
std::vector<RECT> v; std::vector<RECT> v;
double ratio = (rc->right - rc->left) * 1.0 / (rc->bottom - rc->top);
int w = (Width(rc) - (n + 1) * wgap) / n; int w = (Width(rc) - (n + 1) * wgap) / n;
int h = static_cast<int>(w / ratio);
int hgap = (Height(rc) - h) / 2; if (hgap == -1) {
double ratio = (rc->right - rc->left) * 1.0 / (rc->bottom - rc->top);
int h = static_cast<int>(w / ratio);
hgap = (Height(rc) - h) / 2;
}
for (int i = 0; i < n; i++) { for (int i = 0; i < n; i++) {
RECT r = *rc; RECT r = *rc;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment