unit FlameIO; interface uses Controlpoint; function FlameToXML(const cp1: TControlPoint; sheep: boolean; compact: boolean = false): string; implementation uses Classes, SysUtils, xForm, xFormMan; function NumXForms(const cp: TControlPoint): integer; var i: integer; begin Result := NXFORMS; for i := 0 to NXFORMS - 1 do begin if cp.xform[i].density = 0 then begin Result := i; Break; end; end; end; function CleanXMLName(ident: string): string; var i: integer; begin for i := 0 to Length(ident) do begin if ident[i] = '*' then ident[i] := '_' else if ident[i] = '"' then ident[i] := #39; end; Result := ident; end; function ColorToXmlCompact(cp1: TControlPoint): string; var i: integer; begin Result := ' '; end; function ColorToXml(cp1: TControlPoint): string; var i: integer; begin Result := ''; for i := 0 to 255 do begin Result := Result + ' ' + #13#10; end; end; function FlameToXML(const cp1: TControlPoint; sheep: boolean; compact: boolean = false): string; var t, i, j: integer; FileList: TStringList; x, y, a, b, cc, d, e, f: double; varlist, nick, url, pal, hue: string; begin FileList := TStringList.create; x := cp1.center[0]; y := cp1.center[1]; pal := ''; hue := ''; if sheep then begin pal := 'palette="' + IntToStr(cp1.cmapindex) + '" '; hue := 'hue="' + format('%g', [cp1.hue_rotation]) + '" '; end; // if Trim(SheepNick) <> '' then nick := 'nick="' + Trim(SheepNick) + '"'; // if Trim(SheepURL) <> '' then url := 'url="' + Trim(SheepURL) + '" '; try FileList.Add(''); { Write transform parameters } t := NumXForms(cp1); for i := 0 to t - 1 do begin FileList.Add(cp1.xform[i].ToXMLString); end; { Write palette data } if not sheep then begin if not compact then FileList.Add(ColorToXml(cp1)); FileList.Add(ColorToXmlcompact(cp1)); end; FileList.Add(''); result := FileList.text; finally FileList.free end; end; end.