anchor.diff: +{
  +  Mollier Chart (ph-chart) generator
  +  Bruce Wernick, 13 December 2015
  +}
  +
   unit uMolChart;
   
   interface
   
   uses
     SysUtils, Windows, Graphics, Classes,
  -  superobject,
     cpIntf;
   
   type
  
positive.code:   xf := (x1-x0)/(R.Right-R.Left);
    lny0 := ln(y0);
    lny1 := ln(y1);
    yf := (lny1-lny0)/(R.Top-R.Bottom);
  end;
  
  function TMolChart.X2P(x: Double): Integer;
  {X scale value to chart pixel value}
  begin
    Result := Trunc(R.Left+(x-x0)/xf);
  end;
  
  function TMolChart.Y2P(y: Double): Integer;
  {Y scale value to chart pixel value}
  begin
    Result := Trunc(R.Bottom+(ln(y)-lny0)/yf);
  end;
  
  function TMolChart.P2X(p: Integer): Double;
  
negative.code:   y1 := y1+0.1*dy;
    CalcScaleFactor;
  
    DrawVec(hf, p, clGreen, 2); // liquid line
    DrawVec(hg, p, clRed, 2); // vapor line
    DrawPoint(hc, pc, clBlue) // critical point
  end;
  
  end.
  