TAChart: Draw pie series on bgra back-end

git-svn-id: trunk@31199 -
This commit is contained in:
ask 2011-06-13 12:25:40 +00:00
parent 3e75caa3ae
commit a051702584

View File

@ -37,6 +37,7 @@ type
FPenWidth: Integer; FPenWidth: Integer;
FPrevPoint: TPoint; FPrevPoint: TPoint;
procedure InternalDrawPolygon(const APoints: ArrayOfTPointF);
procedure SetBrush(ABrush: TFPCustomBrush); procedure SetBrush(ABrush: TFPCustomBrush);
procedure SetFont(AFont: TFPCustomFont); procedure SetFont(AFont: TFPCustomFont);
procedure SetPen(APen: TFPCustomPen); procedure SetPen(APen: TFPCustomPen);
@ -155,6 +156,24 @@ begin
Result := 0.0; Result := 0.0;
end; end;
procedure TBGRABitmapDrawer.InternalDrawPolygon(const APoints: ArrayOfTPointF);
var
bt: TBGRACustomBitmap;
begin
if FBrushStyle = bsSolid then
FCanvas.FillPolyAntialias(APoints, FBrushColor)
else begin
bt := FCanvas.CreateBrushTexture(
FBrushStyle, FBrushColor, BGRAPixelTransparent);
try
FCanvas.FillPolyAntialias(APoints, bt);
finally
bt.Free;
end;
end;
FCanvas.DrawPolygonAntialias(APoints, FPenColor, FPenWidth);
end;
procedure TBGRABitmapDrawer.Line(AX1, AY1, AX2, AY2: Integer); procedure TBGRABitmapDrawer.Line(AX1, AY1, AX2, AY2: Integer);
begin begin
FCanvas.DrawLineAntialias(AX1, AY1, AX2, AY2, FPenColor, FPenWidth); FCanvas.DrawLineAntialias(AX1, AY1, AX2, AY2, FPenColor, FPenWidth);
@ -181,22 +200,8 @@ end;
procedure TBGRABitmapDrawer.Polygon( procedure TBGRABitmapDrawer.Polygon(
const APoints: array of TPoint; AStartIndex, ANumPts: Integer); const APoints: array of TPoint; AStartIndex, ANumPts: Integer);
var
bt: TBGRACustomBitmap;
begin begin
if FBrushStyle = bsSolid then InternalDrawPolygon(PointsToPointsF(APoints, AStartIndex, ANumPts));
FCanvas.DrawPolygonAntialias(
PointsToPointsF(APoints, AStartIndex, ANumPts), FBrushColor, FPenWidth)
else begin
bt := FCanvas.CreateBrushTexture(
FBrushStyle, FBrushColor, BGRAPixelTransparent);
try
FCanvas.DrawPolygonAntialias(
PointsToPointsF(APoints, AStartIndex, ANumPts), bt, FPenWidth);
finally
bt.Free;
end;
end;
end; end;
procedure TBGRABitmapDrawer.Polyline( procedure TBGRABitmapDrawer.Polyline(
@ -214,10 +219,17 @@ end;
procedure TBGRABitmapDrawer.RadialPie( procedure TBGRABitmapDrawer.RadialPie(
AX1, AY1, AX2, AY2: Integer; AStartAngle16Deg, AAngleLength16Deg: Integer); AX1, AY1, AX2, AY2: Integer; AStartAngle16Deg, AAngleLength16Deg: Integer);
const
CONV_COEFF = 65536 / (360 * 16);
var
cx, cy, rx, ry: Integer;
begin begin
Unused(AX1, AY1); BoundingBoxToCenterAndHalfRadius(AX1, AY1, AX2, AY2, cx, cy, rx, ry);
Unused(AX2, AY2); InternalDrawPolygon(FCanvas.ComputePie65536(
Unused(AStartAngle16Deg, AAngleLength16Deg); cx, cy, rx, ry,
Round(AStartAngle16Deg * CONV_COEFF),
Round((AStartAngle16Deg + AAngleLength16Deg) * CONV_COEFF)
));
end; end;
procedure TBGRABitmapDrawer.Rectangle(AX1, AY1, AX2, AY2: Integer); procedure TBGRABitmapDrawer.Rectangle(AX1, AY1, AX2, AY2: Integer);
@ -263,7 +275,6 @@ end;
procedure TBGRABitmapDrawer.SetBrushParams( procedure TBGRABitmapDrawer.SetBrushParams(
AStyle: TFPBrushStyle; AColor: TChartColor); AStyle: TFPBrushStyle; AColor: TChartColor);
begin begin
Unused(AStyle);
FBrushColor := ColorToBGRA(AColor); FBrushColor := ColorToBGRA(AColor);
FBrushStyle := AStyle; FBrushStyle := AStyle;
end; end;