aggpas: implemented GradientFill

git-svn-id: trunk@23000 -
This commit is contained in:
mattias 2009-12-06 12:20:25 +00:00
parent 98cdda2155
commit b6c860de16
3 changed files with 35 additions and 18 deletions

View File

@ -75,7 +75,7 @@ begin
FillRect(40,10,50,20);
Ellipse(55,10,65,20);
//GradientFill(Rect(70,10,80,20),clRed,clBlue,gdVertical);
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);

View File

@ -404,7 +404,7 @@ type
{ TAggFPCanvas }
TAggFPCanvas = class(TFPCustomCanvas)
private
protected
FAggBrush: TAggFPBrush;
FAggFont: TAggFPFont;
FAggPen: TAggFPPen;
@ -2096,8 +2096,6 @@ begin
m_fillGradientD1 :=0.0;
m_fillGradientD2 :=Sqrt((x2 - x1 ) * (x2 - x1 ) + (y2 - y1 ) * (y2 - y1 ) );
m_fillGradientFlag:=AGG_Linear;
Brush.FPColor:=colBlack; // Set some real color
end;
procedure TAggFPCanvas.AggLineLinearGradient(const x1, y1, x2, y2: double; c1,
@ -2230,8 +2228,6 @@ begin
m_fillGradientD1 :=0;
m_fillGradientFlag:=AGG_Radial;
Brush.FPColor:=colBlack; // Set some real color
end;
procedure TAggFPCanvas.AggLineRadialGradient(const x, y, r: double; c1,
@ -2343,8 +2339,6 @@ begin
m_fillGradientD1 :=0;
m_fillGradientFlag:=AGG_Radial;
Brush.FPColor:=colBlack; // Set some real color
end;
procedure TAggFPCanvas.AggLineRadialGradient(const x, y, r: double; c1, c2,
@ -3133,7 +3127,7 @@ begin
renSolid^.color_ (@clr );
render_scanlines(@m_rasterizer ,@m_scanline ,renSolid );
end;
end;
end;
procedure TAggFPCanvas.Agg2DRenderer_render(

View File

@ -117,10 +117,10 @@ type
procedure FillRect(const ARect: TRect); virtual; // no border
procedure FillRect(X1,Y1,X2,Y2: Integer); // no border
procedure Frame(const ARect: TRect); virtual; // ToDo: border using brush
procedure Frame(X1,Y1,X2,Y2: Integer); // ToDo: border using brush
procedure Frame(const ARect: TRect); virtual; // border using pen
procedure Frame(X1,Y1,X2,Y2: Integer); // border using pen
procedure GradientFill(ARect: TRect; AStart, AStop: TColor; ADirection: TGradientDirection);// ToDo
procedure GradientFill(ARect: TRect; AStart, AStop: TColor; ADirection: TGradientDirection);
procedure RadialPie(x1, y1, x2, y2,
StartAngle16Deg, Angle16DegLength: Integer); virtual;
@ -153,6 +153,7 @@ procedure InitAggPasRawImageDescriptor(APixelFormat: TAggFPImgPixelFormat;
AWidth, AHeight: cardinal; out Desc: TRawImageDescription);
function AggToLCLColor(const c: TAggColor): TColor;
function LCLToAggColor(const c: TColor): TAggColor;
function dbgs(const c: TAggColor): string; overload;
implementation
@ -188,15 +189,23 @@ end;
function AggToLCLColor(const c: TAggColor): TColor;
begin
Result:=RGBToColor(c.r,c.g,c.b);
if c.a<>0 then
Result:=RGBToColor(c.r,c.g,c.b)
else
Result:=clNone;
end;
function LCLToAggColor(const c: TColor): TAggColor;
begin
Result.a:=0;
Result.a:=255;
RedGreenBlue(ColorToRGB(c),Result.r,Result.g,Result.b);
end;
function dbgs(const c: TAggColor): string; overload;
begin
Result:='r='+IntToStr(c.r)+',g='+IntToStr(c.g)+',b='+IntToStr(c.b)+',a='+IntToStr(c.a);
end;
{ TAggLCLCanvas }
function TAggLCLCanvas.DoCreateDefaultBrush: TFPCustomBrush;
@ -449,11 +458,25 @@ end;
procedure TAggLCLCanvas.GradientFill(ARect: TRect; AStart, AStop: TColor;
ADirection: TGradientDirection);
var
x1,y1,x2,y2: double;
begin
raise Exception.Create('TAggLCLCanvas.GradientFill ToDo');
AggFillLinearGradient(ARect.Left,ARect.Top,ARect.Right,ARect.Bottom,
LCLToAggColor(AStart),LCLToAggColor(AStop));
FillRect(ARect);
x1:=ARect.Left+0.5;
y1:=ARect.Top+0.5;
x2:=ARect.Right+0.5;
y2:=ARect.Bottom+0.5;
if ADirection=gdVertical then
AggFillLinearGradient(x1,y1,x1,y2,LCLToAggColor(AStart),LCLToAggColor(AStop))
else
AggFillLinearGradient(x1,y1,x2,y1,LCLToAggColor(AStart),LCLToAggColor(AStop));
Path.m_path.remove_all;
Path.m_path.move_to(x1,y1);
Path.m_path.line_to(x2,y1);
Path.m_path.line_to(x2,y2);
Path.m_path.line_to(x1,y2);
AggClosePolygon;
AggDrawPath(AGG_FillOnly);
m_fillGradientFlag:=AGG_Solid;
end;
procedure TAggLCLCanvas.RadialPie(x1, y1, x2, y2, StartAngle16Deg,