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
67
68
69
70
71
72
73
| #pragma once
|
| int DivRectX(const CRect rect0, CRect & rect1, CRect & rect2, float w1=0, float w2=0)
| {
| int x0, y0, x1, y1, x2;// , y2;
| int w, h;
| x0 = rect0.left;
| y0 = rect0.top;
| x1 = rect0.right;
| y1 = rect0.bottom;
| w = rect0.Width();
| h = rect0.Height();
|
| if (w1 > 1&&w2<1) { x2 = int(x0 + w1); }
| else if (w2 > 1) { x2 = int(x1 - w2); }
| else{ x2 = int((x0*w2 + x1*w1) / (w1 + w2));
| }
| rect1.SetRect(x0, y0, x2, y1);
| rect2.SetRect(x2, y0, x1, y1);
| return 0;
|
| };
| int DivRectY(const CRect rect0, CRect & rect1, CRect & rect2, float h1=0, float h2=0)
| {
| int x0, y0, x1, y1, y2;
| x0 = rect0.left;
| y0 = rect0.top;
| x1 = rect0.right;
| y1 = rect0.bottom;
| if (h1 > 1 && h2 < 1) { y2 = int(y0 + h1); }
| else if (h2 > 1) { y2 = int(y1 - h2); }
| else { y2 = int((y0*h2 + y1*h1) / (h1 + h2)); }
|
| rect1.SetRect(x0, y0, x1, y2);
| rect2.SetRect(x0, y2, x1, y1);
| return 0;
| }
|
| int DivRectX3(const CRect rect0, CRect & rect1, CRect & rect2, CRect & rect3, float w1=0, float w2=0, float w3=0)
| {
| int x0, y0, x1, y1, x2, x3;// , y2;
|
| x0 = rect0.left;
| y0 = rect0.top;
| x1 = rect0.right;
| y1 = rect0.bottom;
|
| x2 = int((x0*(w2+w3) + x1*w1) / (w1 + w2 + w3));
| x3 = int((x0*(w3) + x1*(w1+w2)) / (w1 + w2 + w3));
|
| rect1.SetRect(x0, y0, x2, y1);
| rect2.SetRect(x2, y0, x3, y1);
| rect3.SetRect(x3, y0, x1, y1);
|
| return 0;
|
| };
| int DivRectY3(const CRect rect0, CRect & rect1, CRect & rect2, CRect & rect3, float h1=0, float h2=0, float h3=0)
| {
| int x0, y0, x1, y1, y2, y3;
| x0 = rect0.left;
| y0 = rect0.top;
| x1 = rect0.right;
| y1 = rect0.bottom;
|
| y2 = int((y0*(h2 + h3) + y1*h1) / (h1 + h2 + h3));
| y3 = int((y0*h2 + y1*(h1 + h2)) / (h1 + h2 + h3));
|
| rect1.SetRect(x0, y0, x1, y2);
| rect2.SetRect(x0, y2, x1, y3);
| rect3.SetRect(x0, y3, x1, y1);
| return 0;
| }
|
|