提交 | 用户 | age
|
4b03ae
|
1 |
#pragma once
|
Q |
2 |
|
|
3 |
int DivRectX(const CRect rect0, CRect & rect1, CRect & rect2, float w1=0, float w2=0)
|
|
4 |
{
|
|
5 |
int x0, y0, x1, y1, x2;// , y2;
|
|
6 |
int w, h;
|
|
7 |
x0 = rect0.left;
|
|
8 |
y0 = rect0.top;
|
|
9 |
x1 = rect0.right;
|
|
10 |
y1 = rect0.bottom;
|
|
11 |
w = rect0.Width();
|
|
12 |
h = rect0.Height();
|
|
13 |
|
|
14 |
if (w1 > 1&&w2<1) { x2 = int(x0 + w1); }
|
|
15 |
else if (w2 > 1) { x2 = int(x1 - w2); }
|
|
16 |
else{ x2 = int((x0*w2 + x1*w1) / (w1 + w2));
|
|
17 |
}
|
|
18 |
rect1.SetRect(x0, y0, x2, y1);
|
|
19 |
rect2.SetRect(x2, y0, x1, y1);
|
|
20 |
return 0;
|
|
21 |
|
|
22 |
};
|
|
23 |
int DivRectY(const CRect rect0, CRect & rect1, CRect & rect2, float h1=0, float h2=0)
|
|
24 |
{
|
|
25 |
int x0, y0, x1, y1, y2;
|
|
26 |
x0 = rect0.left;
|
|
27 |
y0 = rect0.top;
|
|
28 |
x1 = rect0.right;
|
|
29 |
y1 = rect0.bottom;
|
|
30 |
if (h1 > 1 && h2 < 1) { y2 = int(y0 + h1); }
|
|
31 |
else if (h2 > 1) { y2 = int(y1 - h2); }
|
|
32 |
else { y2 = int((y0*h2 + y1*h1) / (h1 + h2)); }
|
|
33 |
|
|
34 |
rect1.SetRect(x0, y0, x1, y2);
|
|
35 |
rect2.SetRect(x0, y2, x1, y1);
|
|
36 |
return 0;
|
|
37 |
}
|
|
38 |
|
|
39 |
int DivRectX3(const CRect rect0, CRect & rect1, CRect & rect2, CRect & rect3, float w1=0, float w2=0, float w3=0)
|
|
40 |
{
|
|
41 |
int x0, y0, x1, y1, x2, x3;// , y2;
|
|
42 |
|
|
43 |
x0 = rect0.left;
|
|
44 |
y0 = rect0.top;
|
|
45 |
x1 = rect0.right;
|
|
46 |
y1 = rect0.bottom;
|
|
47 |
|
|
48 |
x2 = int((x0*(w2+w3) + x1*w1) / (w1 + w2 + w3));
|
|
49 |
x3 = int((x0*(w3) + x1*(w1+w2)) / (w1 + w2 + w3));
|
|
50 |
|
|
51 |
rect1.SetRect(x0, y0, x2, y1);
|
|
52 |
rect2.SetRect(x2, y0, x3, y1);
|
|
53 |
rect3.SetRect(x3, y0, x1, y1);
|
|
54 |
|
|
55 |
return 0;
|
|
56 |
|
|
57 |
};
|
|
58 |
int DivRectY3(const CRect rect0, CRect & rect1, CRect & rect2, CRect & rect3, float h1=0, float h2=0, float h3=0)
|
|
59 |
{
|
|
60 |
int x0, y0, x1, y1, y2, y3;
|
|
61 |
x0 = rect0.left;
|
|
62 |
y0 = rect0.top;
|
|
63 |
x1 = rect0.right;
|
|
64 |
y1 = rect0.bottom;
|
|
65 |
|
|
66 |
y2 = int((y0*(h2 + h3) + y1*h1) / (h1 + h2 + h3));
|
|
67 |
y3 = int((y0*h2 + y1*(h1 + h2)) / (h1 + h2 + h3));
|
|
68 |
|
|
69 |
rect1.SetRect(x0, y0, x1, y2);
|
|
70 |
rect2.SetRect(x0, y2, x1, y3);
|
|
71 |
rect3.SetRect(x0, y3, x1, y1);
|
|
72 |
return 0;
|
|
73 |
} |