<html>
<head>
<meta content="text/html; charset=ISO-8859-1"
http-equiv="Content-Type">
</head>
<body bgcolor="#FFFFFF" text="#000000">
<br>
<div class="moz-cite-prefix">Il 18/09/2014 16:00, Bart ha scritto:<br>
<br>
</div>
<blockquote
cite="mid:CAMye31wYqwjjMQ5zETJ3w2xuHvON2d-eYhVVAA=Qzj7t9c09PQ@mail.gmail.com"
type="cite">
<pre wrap="">
what do I need to do to make that work using Canvas.Pie
And the same Q for a fraction Y, starting of from section X?
</pre>
</blockquote>
Pie and RadialPie are quite easy to use.<br>
<br>
RadialPie works with resolution of 1/16 degree (meaning that a full
circle is 360*16 = 5760).<br>
Takes as parameters the coordinates of the top left (x1,y1) and
bottom right of the rectangle containing you ellipse (circle), the
starting angle and the angular length (both in units of 1/16
degree). <br>
<br>
Here are some fractions of code, just to see in practice how to use
it:<br>
<pre> Total := FTranslated + FUntranslated + FFuzzy;
Circle := 360 * 16;
TranslatedAngle := FTranslated * Circle div Total;
UntranslatedAngle := FUntranslated * Circle div Total;
FuzzyAngle := FFuzzy * Circle div Total;
ObsoleteAngle := FObsolete * Circle div Total;
if FuzzyAngle > 0 then begin
Canvas.Brush.Color:= FFuzzyColor;
if FFuzzy = Total then
Canvas.Ellipse(FPieRect)
else Canvas.RadialPie(FPieLeft,1,FPieRight,FPieHeight,0,FuzzyAngle);;
end;
if UntranslatedAngle > 0 then begin
Canvas.Brush.Color:= FUnTranslColor;
if FUntranslated = Total then
Canvas.Ellipse(FPieRect)
else Canvas.RadialPie(FPieLeft,1,FPieRight,FPieHeight,FuzzyAngle,UntranslatedAngle);;
end;
</pre>
And, for Pie, that's the Lazarus Help description:<br>
<br>
<i> procedure TCanvas.Pie(EllipseX1, EllipseY1, EllipseX2,
EllipseY2,</i><i><br>
</i><i>
StartX, StartY, EndX, EndY:
Integer); </i><i><br>
</i><i>
</i><i><br>
</i><i> The pie is part of an ellipse between the points EllipseX1,
EllipseY1, EllipseX2, EllipseY2.</i><i><br>
</i><i> The values StartX, StartY and EndX, EndY represent the
starting and ending</i><i><br>
</i><i> radial-points between which the Bounding-Arc is drawn.</i><i><br>
</i><br>
and here a portion of code using it, where <i>PercentDone</i> is a
value between 0 and 100, <i>MiddleX</i> and <i>MiddleY</i> are the
coordinates of the center, <i>W</i> and<i> H </i>are Width and
Height of the Paint Rectangle.<br>
<pre> Angle := (Pi * ((PercentDone / 50.0) + 0.5));
Pie(PaintRect.Left, PaintRect.Top, W, H,
Integer(Round(MiddleX * (1 - Cos(Angle)))),
Integer(Round(MiddleY * (1 - Sin(Angle)))), MiddleX, 0);
</pre>
I hope that it helps.<br>
<br>
Giuliano<br>
<br>
<br>
<br>
</body>
</html>