From 8dda7b592e3eb2c58515875dfcf265519815e687 Mon Sep 17 00:00:00 2001 From: mattias Date: Fri, 4 Dec 2009 15:48:16 +0000 Subject: [PATCH] aggpas: started chord git-svn-id: trunk@22965 - --- components/aggpas/lazarus/example/unit2.pas | 16 +++++++--- components/aggpas/src/agg_lcl.pas | 35 ++++++++++++++++++++- 2 files changed, 46 insertions(+), 5 deletions(-) diff --git a/components/aggpas/lazarus/example/unit2.pas b/components/aggpas/lazarus/example/unit2.pas index 56226ec9bf..37fd3fc726 100644 --- a/components/aggpas/lazarus/example/unit2.pas +++ b/components/aggpas/lazarus/example/unit2.pas @@ -77,8 +77,12 @@ 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,0,2700); - Arc(115,10,125,20,1000,2700); + Arc(100,10,110,20, 0,2700); + Arc(115,10,125,20, 1000,2700); + Arc(130,10,140,20, 135,5, 130,20); + //Chord(145,10,150,20, 0,2700); + //Chord(155,10,165,20, 1000,2700); + //Chord(170,10,180,20, 175,5, 170,20); s:='Font.Size='+IntToStr(Font.Size); GetTextSize(s,TxtW,TxtH); @@ -108,8 +112,12 @@ 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,0,2700); - Arc(115,22,125,32,1000,2700); + Arc(100,22,110,32, 0,2700); + Arc(115,22,125,32, 1000,2700); + Arc(130,22,140,32, 135,15, 130,32); + //Chord(145,22,150,32, 0,2700); + //Chord(155,22,165,32, 1000,2700); + //Chord(170,22,180,32, 175,5, 170,20); s:='Font.Size='+IntToStr(Font.Size); GetTextSize(s,TxtW,TxtH); diff --git a/components/aggpas/src/agg_lcl.pas b/components/aggpas/src/agg_lcl.pas index 77996177d0..6db3e70036 100644 --- a/components/aggpas/src/agg_lcl.pas +++ b/components/aggpas/src/agg_lcl.pas @@ -12,7 +12,7 @@ uses Windows , {$ENDIF} Classes ,Graphics, LCLProc, IntfGraphics, GraphType, FPimage, FPCanvas, - agg_fpimage; + GraphMath, agg_fpimage; type @@ -110,6 +110,8 @@ type // extra drawing methods (there are more in the ancestor TFPCustomCanvas) procedure Arc(ALeft, ATop, ARight, ABottom, StartAngle, AngleLength: Integer); virtual; procedure Arc(ALeft, ATop, ARight, ABottom, SX, SY, EX, EY: Integer); virtual; + procedure Chord(ALeft, ATop, ARight, ABottom, StartAngle, AngleLength: Integer); virtual; + procedure Chord(ALeft, ATop, ARight, ABottom, SX, SY, EX, EY: Integer); virtual; function LCLAngleToAggAngle(const angle: double): double; procedure FillRect(const ARect: TRect); virtual; // no border @@ -294,6 +296,37 @@ end; procedure TAggLCLCanvas.Arc(ALeft, ATop, ARight, ABottom, SX, SY, EX, EY: Integer); +var + StartAngle: Extended; + AngleLength: Extended; + cx, cy, rx, ry, start, endangle, h: double; +begin + Coords2Angles(ALeft, ATop, ARight-ALeft, ABottom-ATop, SX, SY, EX, EY, + StartAngle, AngleLength); + 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; + // counter clockwise to clockwise + start:=LCLAngleToAggAngle(StartAngle+AngleLength); + endangle:=LCLAngleToAggAngle(StartAngle); + if AngleLength<0 then begin + h:=start; + start:=endangle; + endangle:=h; + end; + AggArc(cx,cy,rx,ry,start,endangle); +end; + +procedure TAggLCLCanvas.Chord(ALeft, ATop, ARight, ABottom, StartAngle, + AngleLength: Integer); +begin + +end; + +procedure TAggLCLCanvas.Chord(ALeft, ATop, ARight, ABottom, SX, SY, EX, + EY: Integer); begin end;