[Lazarus] Fuzzy translations ignored
Giuliano Colla
giuliano.colla at fastwebnet.it
Thu Sep 18 20:07:39 CEST 2014
Il 18/09/2014 16:00, Bart ha scritto:
> 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?
Pie and RadialPie are quite easy to use.
RadialPie works with resolution of 1/16 degree (meaning that a full
circle is 360*16 = 5760).
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).
Here are some fractions of code, just to see in practice how to use it:
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;
And, for Pie, that's the Lazarus Help description:
/ procedure TCanvas.Pie(EllipseX1, EllipseY1, EllipseX2, EllipseY2,//
// StartX, StartY, EndX, EndY: Integer); //
////
// The pie is part of an ellipse between the points EllipseX1,
EllipseY1, EllipseX2, EllipseY2.//
// The values StartX, StartY and EndX, EndY represent the starting and
ending//
// radial-points between which the Bounding-Arc is drawn.//
/
and here a portion of code using it, where /PercentDone/ is a value
between 0 and 100, /MiddleX/ and /MiddleY/ are the coordinates of the
center, /W/ and/H /are Width and Height of the Paint Rectangle.
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);
I hope that it helps.
Giuliano
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.lazarus-ide.org/pipermail/lazarus/attachments/20140918/0d81c8ba/attachment-0003.html>
More information about the Lazarus
mailing list