This page illustrates the derivation of a specific version of TssCustomScaler for converting between Fahrenheit and Celsius temperatures.

interface

TssFahrenheitToCelsius = class(TssCustomScaler)
public
  constructor Create(AOwner: TComponent); override;
  function FtoC(const value: extended): extended;
  function CtoF(const value: extended): extended;
end;

implementation

{ TssFahrenheitToCelsius }

constructor TssFahrenheitToCelsius.Create(AOwner: TComponent);
begin
  inherited Create(AOwner);
  // create the Celsius scale
  Scale1.Name := 'Celsius';
  Scale1.SetRange(0, 100);

  // create the Fahrenheit scale, using the equivalent range
  Scale2.Name := 'Fahrenheit';
  Scale2.SetRange(32, 212);
end;

function TssFahrenheitToCelsius.CtoF(const value: extended): extended;
begin
  result := Convert(Value, Scale1, Scale2);
end;

function TssFahrenheitToCelsius.FtoC(const value: extended): extended;
begin
  result := Convert(Value, Scale2, Scale1);
end;