diff --git a/components/aggpas/lazarus/example/unit2.lfm b/components/aggpas/lazarus/example/unit2.lfm index be01d3354d..3a0304cab9 100644 --- a/components/aggpas/lazarus/example/unit2.lfm +++ b/components/aggpas/lazarus/example/unit2.lfm @@ -1,7 +1,7 @@ object Form1: TForm1 - Left = 383 + Left = 387 Height = 204 - Top = 290 + Top = 287 Width = 238 Caption = 'Form1' OnCreate = FormCreate diff --git a/components/aggpas/lazarus/example/unit2.lrs b/components/aggpas/lazarus/example/unit2.lrs index c807cb7408..48f8b40a82 100644 --- a/components/aggpas/lazarus/example/unit2.lrs +++ b/components/aggpas/lazarus/example/unit2.lrs @@ -1,7 +1,7 @@ { This is an automatically generated lazarus resource file } LazarusResources.Add('TForm1','FORMDATA',[ - 'TPF0'#6'TForm1'#5'Form1'#4'Left'#3#127#1#6'Height'#3#204#0#3'Top'#3'"'#1#5'W' + 'TPF0'#6'TForm1'#5'Form1'#4'Left'#3#131#1#6'Height'#3#204#0#3'Top'#3#31#1#5'W' +'idth'#3#238#0#7'Caption'#6#5'Form1'#8'OnCreate'#7#10'FormCreate'#9'OnDestro' +'y'#7#11'FormDestroy'#7'OnPaint'#7#9'FormPaint'#10'LCLVersion'#6#6'0.9.29'#0 +#0 diff --git a/components/aggpas/lazarus/example/unit2.pas b/components/aggpas/lazarus/example/unit2.pas index 0771771976..852f1122af 100644 --- a/components/aggpas/lazarus/example/unit2.pas +++ b/components/aggpas/lazarus/example/unit2.pas @@ -33,6 +33,11 @@ procedure TForm1.FormCreate(Sender: TObject); var HasFont: Boolean; FontFilename: String; + s: String; + TxtW: integer; + TxtH: integer; + TxtX: Integer; + TxtY: Integer; begin Bitmap1:=TBitmap.Create; AggLCLCanvas:=TAggLCLCanvas.Create; @@ -53,7 +58,7 @@ begin if not FileExists(FontFilename) then raise Exception.Create('file not found: '+FontFilename+' CurDir='+GetCurrentDirUTF8); Font.LoadFromFile(FontFilename); Font.Size:=10; - Font.Color:=clRed; + Font.Color:=clBlack; end; // solid white background @@ -72,8 +77,15 @@ begin Ellipse(55,10,65,20); //GradientFill(Rect(70,10,80,20),clRed,clBlue,gdVertical); Frame(85,10,95,20); + //Arc(100,10,110,20,1000,2700); + //Arc(115,10,125,20,0,2700); - TextOut(10,40,'Font.Size='+IntToStr(Font.Size)); + s:='Font.Size='+IntToStr(Font.Size); + GetTextSize(s,TxtW,TxtH); + TxtX:=10; + TxtY:=40; + FillRect(TxtX,TxtY,TxtX+TxtW,TxtY+TxtH); + TextOut(TxtX,TxtY,s); end; // convert to LCL native pixel format @@ -82,7 +94,7 @@ begin // paint with widgetset to bitmap with Bitmap1.Canvas do begin Font.Size:=10; - Font.Color:=clRed; + Font.Color:=clBlack; Brush.Color:=clRed; Pen.Color:=clBlue; @@ -96,8 +108,15 @@ begin Ellipse(55,22,65,32); GradientFill(Rect(70,22,80,32),clRed,clBlue,gdVertical); Frame(85,22,95,32); + //Arc(100,22,110,32,1000,2700); + //Arc(115,22,125,32,0,2700); - TextOut(10,52,'Font.Size='+IntToStr(Font.Size)); + s:='Font.Size='+IntToStr(Font.Size); + GetTextSize(s,TxtW,TxtH); + TxtX:=10; + TxtY:=60; + FillRect(TxtX,TxtY,TxtX+TxtW,TxtY+TxtH); + TextOut(TxtX,TxtY,s); end; end; diff --git a/components/aggpas/src/agg_fpimage.pas b/components/aggpas/src/agg_fpimage.pas index 0f52a9a4e1..691f1a2d92 100644 --- a/components/aggpas/src/agg_fpimage.pas +++ b/components/aggpas/src/agg_fpimage.pas @@ -573,7 +573,7 @@ type procedure AggEllipse(const cx ,cy ,rx ,ry : double ); - procedure AggArc (const cx ,cy ,rx ,ry ,start ,sweep : double ); + procedure AggArc (const cx ,cy ,rx ,ry ,start ,sweep : double ); // start: 0 at 3'o clock, clockwise in rad: 180deg = 1pi procedure AggStar(const cx, cy, r1, r2, startAngle: double; numRays: integer); procedure AggCurve(const x1 ,y1 ,x2 ,y2 ,x3 ,y3 : double ); diff --git a/components/aggpas/src/agg_lcl.pas b/components/aggpas/src/agg_lcl.pas index f04bb82eb5..1c4c8b51ba 100644 --- a/components/aggpas/src/agg_lcl.pas +++ b/components/aggpas/src/agg_lcl.pas @@ -108,8 +108,9 @@ type procedure Changed; virtual; // extra drawing methods (there are more in the ancestor TFPCustomCanvas) - //procedure Arc(ALeft, ATop, ARight, ABottom, angle1, angle2: Integer); virtual; - //procedure Arc(ALeft, ATop, ARight, ABottom, SX, SY, EX, EY: Integer); virtual; + procedure Arc(ALeft, ATop, ARight, ABottom, StartAngle, AngleLength: Integer); virtual; + procedure Arc(ALeft, ATop, ARight, ABottom, SX, SY, EX, EY: Integer); virtual; + function LCLAngleToAggAngle(const angle: double): double; procedure FillRect(const ARect: TRect); virtual; // no border procedure FillRect(X1,Y1,X2,Y2: Integer); // no border @@ -264,6 +265,48 @@ begin if Assigned(FOnChange) then FOnChange(Self); end; +procedure TAggLCLCanvas.Arc(ALeft, ATop, ARight, ABottom, + StartAngle, AngleLength: Integer); +{ Use Arc to draw an elliptically curved line with the current Pen. + The angles angle1 and angle2 are 1/16th of a degree. For example, a full + circle equals 5760 (16*360). Positive values of Angle and AngleLength mean + counter-clockwise while negative values mean clockwise direction. + Zero degrees is at the 3'o clock position. +} +var + cx, cy, rx, ry, start, sweep, h: double; +begin + if AngleLength=0 then exit; + cx:=double(ALeft+ARight)/2; + cy:=double(ATop+ABottom)/2; + rx:=double(ARight-ALeft)/2; + ry:=double(ABottom-ATop)/2; + if AngleLength>0 then begin + // convert counter clockwise to clockwise + start:=LCLAngleToAggAngle(StartAngle+AngleLength); + sweep:=LCLAngleToAggAngle(AngleLength); + end else begin + // clockwise + start:=LCLAngleToAggAngle(StartAngle); + sweep:=LCLAngleToAggAngle(-AngleLength); + end; + AggArc(cx,cy,rx,ry,start,sweep); +end; + +procedure TAggLCLCanvas.Arc(ALeft, ATop, ARight, ABottom, SX, SY, EX, + EY: Integer); +begin + +end; + +function TAggLCLCanvas.LCLAngleToAggAngle(const angle: double): double; +// both: 0 = 3'o clock +// LCL: counter clockwise, Agg: clockwise +// full circle: LCL = 5760, Agg = 2*pi +begin + Result:=(angle * 2*pi) / 5760; +end; + procedure TAggLCLCanvas.FillRect(const ARect: TRect); begin Fillrect(ARect.Left,ARect.Top,ARect.Right,ARect.Bottom);