J'ai le point central, le rayon et l'angle pour dessiner la tarte, mais the Pie function prend 4 points comme données d'entrée. Est-ce que quelqu'un a une fonction de conversion ou une meilleure explication pour cela?Comment appeler la fonction Pie?
2
A
Répondre
2
Les quatre points dans la fonction tarte:
- coin supérieur gauche du rectangle de sélection.
- Coin inférieur droit du rectangle englobant.
- Pointez sur le cercle qui marque le début de la tarte.
- Pointez sur le cercle qui marque l'extrémité de la tarte (sens inverse des aiguilles d'une montre).
Conversion:
Centerpoint: cx, cy Rayon: r Angle: une
En supposant que votre tarte commence au sommet.
- X1 = Cx-r, Y1 = Cx + r
- X2 = Cx + r, Y2 = Cy-r
- X3 = Cx, Y3 = Y1
- X4 = Cx + r sin (a), Y4 = Cy + r cos (a)
Vous devrez peut-être retourner un signe quelque part, mais cela devrait faire l'affaire.
Avec deux anges différentes (a et b):
- X3 = Cx + sin r (a), Y3 = Cy + r cos (a)
- X4 = Cx + r sin (b), Y4 = Cy + r cos (b)
0
Ceci est écrit en (ancien) C++, mais la plupart devrait être converti en Delphi (ou presque n'importe quoi d'autre) assez facilement. Il suppose également que les entrées sont en pourcentages (un cercle complet est de 100%) au lieu d'angles bruts, mais (encore une fois) cela devrait être assez facile à traiter. Il a une conversion de pourcentage en angle en radians, donc une conversion d'autres unités devrait être un ajustement assez trivial.
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;
}
Questions connexes
- 1. ImageMagick & Pie Charts
- 2. C Sharp Pie Chart
- 3. appeler la fonction (achat InApp)
- 4. comment appeler la fonction javascript actionscript de
- 5. Comment appeler la fonction jquery personnalisée onClick
- 6. Comment appeler la fonction wcf depuis as3
- 7. Comment appeler la fonction DLL dans vbscript
- 8. Comment appeler la fonction vb de javascript
- 9. Comment appeler la fonction suivante dans JQuery
- 10. Comment appeler la fonction Ajax récursivement
- 11. Comment appeler une fonction automatiquement?
- 12. Comment appeler une fonction dynamique
- 13. Comment appeler la fonction C# dans la procédure stockée
- 14. Comment appeler la souris sur la fonction sur divs dyanamic
- 15. Luabind conditionnellement appeler la fonction Lua
- 16. appeler une fonction à partir de la fonction statique
- 17. fonction Javascript onReady pour appeler la fonction Namespace
- 18. comment appeler une autre fonction en javascript?
- 19. Comment appeler une fonction anonyme en C#?
- 20. comment appeler dynamiquement une fonction C#
- 21. Comment appeler une fonction Objective C?
- 22. PHP call_user_func vs simplement appeler la fonction
- 23. Besoin d'aide pour appeler la fonction
- 24. appeler la fonction interne du plug-in
- 25. Comment puis-je appeler une fonction JQuery?
- 26. Comment appeler une fonction javascript sur onrowcommand?
- 27. Comment appeler une fonction pointeur vers membre?
- 28. Comment appeler la fonction Processing.js à partir du HTML?
- 29. Comment appeler la fonction de changement de jquery datepicker surelect
- 30. Comment appeler la fonction python2.5 de x86asm/x64asm?
ce tire une tarte de zéro à angle A, où est l'angle B venir donc nous avons une tarte de A à B? – Maysam