TAChart: Add font orientation to the BGRA drawer. Update demo.

git-svn-id: trunk@30183 -
This commit is contained in:
ask 2011-04-04 15:29:18 +00:00
parent 3a1863981e
commit 0a5e0fb00c
3 changed files with 11 additions and 6 deletions

View File

@ -15,6 +15,7 @@ object Form1: TForm1
Width = 300
AxisList = <
item
Marks.LabelFont.Orientation = 400
Title.LabelFont.Orientation = 900
end
item

View File

@ -30,21 +30,22 @@ implementation
{$R *.lfm}
uses
BGRABitmap, TADrawerBGRA;
BGRABitmap, TADrawerBGRA, TADrawerCanvas, TADrawUtils;
{ TForm1 }
procedure TForm1.PaintBox1Paint(Sender: TObject);
var
bmp: TBGRABitmap;
id: IChartDrawer;
begin
bmp := TBGRABitmap.Create(PaintBox1.Width, PaintBox1.Height);
Chart1.DisableRedrawing;
try
Chart1.Title.Text.Text := 'BGRABitmap';
Chart1.Draw(
TBGRABitmapDrawer.Create(bmp),
Rect(0, 0, PaintBox1.Width, PaintBox1.Height));
id := TBGRABitmapDrawer.Create(bmp);
id.DoGetFontOrientation := @CanvasGetFontOrientationFunc;
Chart1.Draw(id, Rect(0, 0, PaintBox1.Width, PaintBox1.Height));
bmp.Draw(PaintBox1.Canvas, 0, 0);
Chart1.Title.Text.Text := 'Standard';
finally

View File

@ -30,6 +30,7 @@ type
FBrushColor: TBGRAPixel;
FCanvas: TBGRABitmap;
FFontColor: TBGRAPixel;
FFontOrientation: Integer;
FPenColor: TBGRAPixel;
FPenWidth: Integer;
FPrevPoint: TPoint;
@ -104,7 +105,7 @@ end;
procedure TBGRABitmapDrawer.AddToFontOrientation(ADelta: Integer);
begin
// NA
FFontOrientation += ADelta;
end;
procedure TBGRABitmapDrawer.ClippingStart(const AClipRect: TRect);
@ -234,6 +235,7 @@ procedure TBGRABitmapDrawer.SetFont(AFont: TFPCustomFont);
begin
FCanvas.FontName := AFont.Name;
FCanvas.FontHeight := AFont.Size * 96 div 72;
FFontOrientation := FGetFontOrientationFunc(AFont);
with AFont.FPColor do
FFontColor := BGRA(red shr 8, green shr 8, blue shr 8, alpha shr 8);
// TODO: FontStyle
@ -262,7 +264,8 @@ end;
procedure TBGRABitmapDrawer.SimpleTextOut(AX, AY: Integer; const AText: String);
begin
FCanvas.TextOut(AX, AY, AText, FFontColor);
FCanvas.TextOutAngle(
AX, AY, FFontOrientation, AText, FFontColor, taLeftJustify);
end;
end.