1 #ifndef UTILITY_H 2 #define UTILITY_H 3 4 5 #include <Rect.h> 6 7 8 inline BPoint 9 scale_direct(float x, float y, BRect area) 10 { 11 return BPoint(area.Width() * x + area.left, area.Height() * y + area.top); 12 } 13 14 15 inline BRect 16 scale_direct(float x1, float x2, float y1, float y2, BRect area) 17 { 18 return BRect(area.Width() * x1 + area.left, area.Height() * y1 + area.top, 19 area.Width()* x2 + area.left, area.Height() * y2 + area.top); 20 } 21 22 static const float kPositionalX[] = { 0, 0.1, 0.25, 0.3, 0.7, 0.75, 0.9, 1.0 }; 23 static const float kPositionalY[] = { 0, 0.1, 0.7, 0.8, 0.9, 1.0 }; 24 25 inline BPoint 26 scale(int x, int y,BRect area) 27 { 28 return scale_direct(kPositionalX[x], kPositionalY[y], area); 29 } 30 31 32 inline BRect 33 scale(int x1, int x2, int y1, int y2,BRect area) 34 { 35 return scale_direct(kPositionalX[x1], kPositionalX[x2], 36 kPositionalY[y1], kPositionalY[y2], area); 37 } 38 39 40 #endif // UTILITY_H 41