TAChart: More built-in colormap palettes

git-svn-id: trunk@56406 -
This commit is contained in:
wp 2017-11-14 14:49:55 +00:00
parent 8928e14292
commit 173cef239a

View File

@ -342,7 +342,7 @@ type
property OnGetPointerStyle; property OnGetPointerStyle;
end; end;
TColorMapPalette = (cmpHot); TColorMapPalette = (cmpHot, cmpCold, cmpRainbow, cmpMonochrome);
TFuncCalculate3DEvent = TFuncCalculate3DEvent =
procedure (const AX, AY: Double; out AZ: Double) of object; procedure (const AX, AY: Double; out AZ: Double) of object;
@ -434,7 +434,7 @@ type
implementation implementation
uses uses
ipf, GraphType, IntfGraphics, Math, StrUtils, SysUtils, ipf, GraphType, GraphUtil, IntfGraphics, Math, StrUtils, SysUtils,
TAChartStrConsts, TAGeometry, TAGraph, TAMath, TASources; TAChartStrConsts, TAGeometry, TAGraph, TAMath, TASources;
const const
@ -1823,6 +1823,9 @@ begin
end; end;
procedure TCustomColorMapSeries.BuildPalette(APalette: TColorMapPalette); procedure TCustomColorMapSeries.BuildPalette(APalette: TColorMapPalette);
var
i: Integer;
h,s,l: Byte;
begin begin
with FBuiltinColorSource as TListChartSource do begin with FBuiltinColorSource as TListChartSource do begin
BeginUpdate; BeginUpdate;
@ -1836,6 +1839,34 @@ begin
Add(2/3, 0, '', clYellow); Add(2/3, 0, '', clYellow);
Add(1, 0, '', clWhite); Add(1, 0, '', clWhite);
end; end;
cmpCold:
begin
ColorToHLS(clBlue, h, l, s);
i := 0;
while i <= 255 do begin
Add(i, 0, '', HLSToColor(h, i, s));
inc(i, 32);
end;
Add(255, 0, '', clWhite);
end;
cmpRainbow:
begin
i := 0;
while i <= 255 do begin // i is hue
Add(i, 0, '', HLSToColor(i, 128, 255));
inc(i, 32);
end;
Add(255, 0, '', HLSToColor(255, 128, 255));
end;
cmpMonochrome:
begin
i := 0;
while i <= 255 do begin
Add(i, 0, '', RgbToColor(i, i, i));
inc(i, 32);
end;
Add(255, 0, '', clWhite);
end;
else else
raise Exception.Create('Palette not supported'); raise Exception.Create('Palette not supported');
end; end;
@ -2105,16 +2136,21 @@ begin
FMinZ := 1E308; FMinZ := 1E308;
FMaxZ := -FMinZ; FMaxZ := -FMinZ;
iy := ARect.Top; iy := ARect.Top;
while iy <= ARect.Bottom - dy2 do begin try
ix := ARect.Left; while iy <= ARect.Bottom - dy2 do begin
while ix < ARect.Right - dx2 do begin ix := ARect.Left;
gp := ParentChart.ImageToGraph(Point(ix, iy)); while ix < ARect.Right - dx2 do begin
z := FunctionValue(gp.X + dx2, gp.Y + dy2); gp := ParentChart.ImageToGraph(Point(ix, iy));
FMinZ := Min(FMinZ, z); z := FunctionValue(gp.X + dx2, gp.Y + dy2);
FMaxZ := Max(FMaxZ, z); FMinZ := Min(FMinZ, z);
inc(ix, dx); FMaxZ := Max(FMaxZ, z);
inc(ix, dx);
end;
inc(iy, dy);
end; end;
inc(iy, dy); except
FActive := false;
raise;
end; end;
end; end;