1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29
|
uses SysUtils, CastleVectors, CastleFilesUtils, CastleCurves;
var
FirstCurve: TCurve;
Curves: TCurveList;
begin
FirstCurve := TCurve.LoadFromFile(ApplicationData('my_curves.xml'));
try
// That's it, you loaded the 1st curve from XML file.
// Write some initial curve points.
Writeln(FirstCurve.Point(0.0).ToString);
Writeln(FirstCurve.Point(0.1).ToString);
finally FreeAndNil(FirstCurve) end;
{ in more complicated scenarios, my_curves.xml may keep many curves
inside. Load them like this: }
Curves := TCurveList.Create(true { free objects });
try
Curves.LoadFromFile(ApplicationData('my_curves.xml'));
if Curves.Count = 0 then
raise Exception.Create('No curves defined in file');
FirstCurve := Curves[0];
// That's it, you have the 1st curve from XML file.
// Write some initial curve points.
Writeln(FirstCurve.Point(0.0).ToString);
Writeln(FirstCurve.Point(0.1).ToString);
Writeln(FirstCurve.Point(0.2).ToString);
finally FreeAndNil(Curves) end;
end.
|