我有绘制饼图的中心点,半径和角度,但the Pie function需要4点作为输入数据。有没有人有任何转换功能或更好的解释呢?如何调用Pie函数?
2
A
回答
2
的四点饼功能:
- 上边框的左上角。
- 边界矩形的右下角。
- 指向标记饼图开始的圆上的点。
- 指向标记馅饼末端的圆圈(逆时针)。
转换:
中心点:CX,赛扬 半径,R 角度:一个
假设你的馅饼从高层开始。
- X1 = CX-R,Y1 = CX + R
- X2 = CX + R,Y2 =赛扬-R
- X3 = CX,Y3 = Y1
- X4 = CX + R罪(a),Y4 = Cy + rcos(a)
你可能不得不在某个地方翻转一个标志,但是这应该是有用的。
用两个不同角度的(a和b):
- X3 = CX + R SIN(a)中,Y3 =赛扬+ R cos(A)
- X4 = Cx + r sin(b),Y4 = Cy + r cos(b)
0
这是用(旧)C++编写的,但大多数应该很容易地转换为Delphi(或几乎任何其他)。它还假定输入是以百分比(整圆为100%)而不是原始角度,但(再次)应该很容易处理。它以弧度转换百分比到角度,所以从其他单位转换应该是一个很小的调整。
class section {
double percent;
int color;
public:
section(double percent_, int color_) :
percent(percent_), color(color_) {}
void draw(HDC destination, POINT const ¢er, int diameter, double &start_angle);
};
void section::draw(HDC destination, POINT const ¢er, int radius, double &start_angle) {
double start_x, start_y, end_x, end_y;
double angle, end_angle;
int top = center.y - radius;
int bottom = center.y + radius;
int left = center.x - radius;
int right = center.x + radius;
// now we have to convert a percentage to an angle in radians.
// there are 100 percent in a circle, and 2*PI radians in a
// circle, so we figure this percentage of 2*PI radians.
angle = percent/100.0 * 2.0 * 3.1416;
end_angle = start_angle + angle;
// Now we have to convert these angles into rectangular
// coordinates in the window, which depend on where we're
// putting the chart, and how big we're making it.
start_x = center.x + radius * cos(start_angle);
start_y = center.y + radius * sin(start_angle);
end_x = center.x + radius * cos(end_angle);
end_y = center.y + radius * sin(end_angle);
// Now we need to actually draw the pie section by selecting
// the correct color into the DC, drawing the section, then
// selecting the original brush back, and deleing our brush.
HBRUSH brush = CreateSolidBrush(color);
HBRUSH old_brush = (HBRUSH)SelectObject(destination, brush);
Pie(destination, left, top, right, bottom,
(int)start_x, (int)start_y, (int)end_x, (int)end_y);
SelectObject(destination, old_brush);
DeleteObject(brush);
// our sole awareness of other sections: the next section will
// start wherever we finished.
start_angle = end_angle;
}
相关问题
- 1. 如何在函数中调用函数?
- 2. jQuery flot pie调整大小
- 3. 如何调用函数
- 4. 如何函数会调用
- 5. 如何调用该函数?
- 6. 如何调用javascript函数
- 7. 如何调用jquery函数?
- 8. YII如何调用函数?
- 9. 如何调用javascript函数
- 10. $ $如何调用函数?
- 11. 如何调用onClick函数
- 12. 如何调用javascript函数?
- 13. 如何调用JavaScript函数?
- 14. 如何调用函数
- 15. 如何调用.change()函数?
- 16. 如何调用PHP函数?
- 17. 如何调用自调用函数
- 18. 如何使函数在ajax调用中调用函数?
- 19. 如何在调用javascript函数时调用gwt函数
- 20. 如何从node.js中的调用函数访问调用函数?
- 21. 如何在其他函数中调用自调用javascript函数?
- 22. 如何替换的onclick函数调用我的函数调用
- 23. Swift:如何调用调用随机函数的函数?
- 24. 如何在调用函数调用次数时调用函数中的闭包
- 25. 如何调用回调函数中的继承函数
- 26. .filter()如何使回调函数调用另一个函数?
- 27. 我如何调用Ajax回调函数的JavaScript函数
- 28. 如何逐个调用函数参数
- 29. 如何分割函数调用参数
- 30. 如何调用数组的函数?
由此得出一个馅饼从零到角A,哪里的角B来了,所以我们必须从A馅饼到B? – Maysam 2010-07-19 19:25:58