make the new variants temporary unavailable

This commit is contained in:
ronaldhordijk 2005-06-19 05:47:55 +00:00
parent 11a7b08bc3
commit 0ded6d7136
12 changed files with 147 additions and 111 deletions

View File

@ -25,7 +25,6 @@ uses
const const
EPS = 1E-10; EPS = 1E-10;
NVARS = Xform.NVARS;
NXFORMS = 12; NXFORMS = 12;
SUB_BATCH_SIZE = 10000; SUB_BATCH_SIZE = 10000;
PREFILTER_WHITE = (1 shl 26); PREFILTER_WHITE = (1 shl 26);
@ -137,9 +136,8 @@ uses
SysUtils, math, global; SysUtils, math, global;
var var
var_distrib: array[0..NVARS + 18] of integer; var_distrib: array[0..NRVISVAR + 18] of integer;
mixed_var_distrib: array[0..NVARS + 8] of integer; mixed_var_distrib: array[0..NRVISVAR + 8] of integer;
{ TControlPoint } { TControlPoint }
@ -822,7 +820,7 @@ begin
Inc(ParsePos); Inc(ParsePos);
xform[CurrentXForm].c[2, 1] := StrToFloat(ParseValues[ParsePos]); xform[CurrentXForm].c[2, 1] := StrToFloat(ParseValues[ParsePos]);
end else if AnsiCompareText(CurrentToken, 'var') = 0 then begin end else if AnsiCompareText(CurrentToken, 'var') = 0 then begin
for i := 0 to NVARS - 1 do begin for i := 0 to NRVAR - 1 do begin
xform[CurrentXForm].vars[i] := 0; xform[CurrentXForm].vars[i] := 0;
end; end;
@ -856,13 +854,23 @@ procedure TControlPoint.SetVariation(vari: TVariation);
var var
i, j, v: integer; i, j, v: integer;
rv: integer; rv: integer;
VarPossible: boolean;
begin begin
VarPossible := false;
for j := 0 to NRVISVAR - 1 do begin
VarPossible := VarPossible or Variations[j];
end;
if VarPossible then begin
repeat repeat
rv := var_distrib[random(Length(var_distrib))]; rv := var_distrib[random(Length(var_distrib))];
until Variations[rv]; until Variations[rv];
end else begin
rv := 0;
end;
for i := 0 to NXFORMS - 1 do begin for i := 0 to NXFORMS - 1 do begin
for j := 0 to NVARS - 1 do begin for j := 0 to NRVAR - 1 do begin
xform[i].vars[j] := 0; xform[i].vars[j] := 0;
end; end;
@ -870,9 +878,13 @@ begin
begin begin
if rv < 0 then if rv < 0 then
begin begin
if VarPossible then begin
repeat repeat
v := Mixed_var_distrib[random(Length(mixed_var_distrib))]; v := Mixed_var_distrib[random(Length(mixed_var_distrib))];
until Variations[v]; // Use only Variations set in options until Variations[v]; // Use only Variations set in options
end else begin
v := 0;
end;
xform[i].vars[v] := 1 xform[i].vars[v] := 1
end end
else else
@ -888,6 +900,7 @@ var
nrXforms: integer; nrXforms: integer;
i, j: integer; i, j: integer;
v, rv: integer; v, rv: integer;
VarPossible: boolean;
begin begin
//hue_rotation := random; //hue_rotation := random;
hue_rotation := 1; hue_rotation := 1;
@ -897,9 +910,19 @@ begin
//nrXforms := xform_distrib[random(13)]; //nrXforms := xform_distrib[random(13)];
nrXforms := random(Max - (Min - 1)) + Min; nrXforms := random(Max - (Min - 1)) + Min;
VarPossible := false;
for j := 0 to NRVISVAR - 1 do begin
VarPossible := VarPossible or Variations[j];
end;
if VarPossible then begin
repeat repeat
rv := var_distrib[random(Length(var_distrib))]; rv := var_distrib[random(Length(var_distrib))];
until Variations[rv]; until Variations[rv];
end else begin
rv := 0;
end;
for i := 0 to NXFORMS - 1 do begin for i := 0 to NXFORMS - 1 do begin
xform[i].density := 0; xform[i].density := 0;
@ -916,18 +939,23 @@ begin
xform[i].c[2][0] := 4 * random - 2; xform[i].c[2][0] := 4 * random - 2;
xform[i].c[2][1] := 4 * random - 2; xform[i].c[2][1] := 4 * random - 2;
for j := 0 to NVARS - 1 do begin for j := 0 to NRVAR - 1 do begin
xform[i].vars[j] := 0; xform[i].vars[j] := 0;
end; end;
for j := 0 to NVARS - 1 do begin for j := 0 to NRVAR - 1 do begin
xform[i].vars[j] := 0; xform[i].vars[j] := 0;
end; end;
if rv < 0 then begin if rv < 0 then begin
if VarPossible then begin
repeat repeat
v := Mixed_var_distrib[random(Length(mixed_var_distrib))]; v := Mixed_var_distrib[random(Length(mixed_var_distrib))];
until Variations[v]; // use only variations set in options until Variations[v]; // use only variations set in options
end else begin
v := 0;
end;
xform[i].vars[v] := 1 xform[i].vars[v] := 1
end else end else
xform[i].vars[rv] := 1; xform[i].vars[rv] := 1;
@ -943,7 +971,7 @@ var
begin begin
RandomCP; RandomCP;
for i := 0 to NXFORMS - 1 do begin for i := 0 to NXFORMS - 1 do begin
for j := 0 to NVARS - 1 do begin for j := 0 to NRVAR - 1 do begin
xform[i].vars[j] := 0; xform[i].vars[j] := 0;
end; end;
xform[i].vars[0] := 1; xform[i].vars[0] := 1;
@ -1237,7 +1265,7 @@ begin
for i := 0 to NXFORMS - 1 do begin for i := 0 to NXFORMS - 1 do begin
Result.xform[i].density := c0 * cp1.xform[i].density + c1 * cp2.xform[i].density; Result.xform[i].density := c0 * cp1.xform[i].density + c1 * cp2.xform[i].density;
Result.xform[i].color := c0 * cp1.xform[i].color + c1 * cp2.xform[i].color; Result.xform[i].color := c0 * cp1.xform[i].color + c1 * cp2.xform[i].color;
for j := 0 to NVARS - 1 do begin for j := 0 to NRVAR - 1 do begin
Result.xform[i].vars[j] := c0 * cp1.xform[i].vars[j] + c1 * cp2.xform[i].vars[j]; Result.xform[i].vars[j] := c0 * cp1.xform[i].vars[j] + c1 * cp2.xform[i].vars[j];
end; end;
@ -1352,7 +1380,7 @@ begin
Result.xform[i].density := c0 * cp1.xform[i].density + c1 * cp2.xform[i].density; Result.xform[i].density := c0 * cp1.xform[i].density + c1 * cp2.xform[i].density;
Result.xform[i].color := c0 * cp1.xform[i].color + c1 * cp2.xform[i].color; Result.xform[i].color := c0 * cp1.xform[i].color + c1 * cp2.xform[i].color;
Result.xform[i].symmetry := c0 * cp1.xform[i].symmetry + c1 * cp2.xform[i].symmetry; Result.xform[i].symmetry := c0 * cp1.xform[i].symmetry + c1 * cp2.xform[i].symmetry;
for j := 0 to NVARS - 1 do begin for j := 0 to NRVAR - 1 do begin
Result.xform[i].vars[j] := c0 * cp1.xform[i].vars[j] + c1 * cp2.xform[i].vars[j]; Result.xform[i].vars[j] := c0 * cp1.xform[i].vars[j] + c1 * cp2.xform[i].vars[j];
end; end;
(* (*
@ -1419,7 +1447,7 @@ begin
sl.add(format('xform %d density %.3f color %f symmetry %f', [i, xform[i].density, xform[i].color, xform[i].symmetry])); sl.add(format('xform %d density %.3f color %f symmetry %f', [i, xform[i].density, xform[i].color, xform[i].symmetry]));
s := 'var'; s := 'var';
for j := 0 to NVARS - 1 do begin for j := 0 to NRVAR - 1 do begin
s := format('%s %f', [s, xform[i].vars[j]]); s := format('%s %f', [s, xform[i].vars[j]]);
end; end;
sl.add(s); sl.add(s);
@ -1487,7 +1515,7 @@ begin
xform[i].symmetry := 0; xform[i].symmetry := 0;
xform[i].color := 0; xform[i].color := 0;
xform[i].vars[0] := 1; xform[i].vars[0] := 1;
for j := 1 to NVARS - 1 do begin for j := 1 to NRVAR - 1 do begin
xform[i].vars[j] := 0; xform[i].vars[j] := 0;
end; end;
end; end;
@ -1538,7 +1566,8 @@ begin
cp.xform[i].density := 1.0; cp.xform[i].density := 1.0;
cp.xform[i].symmetry := 1; cp.xform[i].symmetry := 1;
cp.xform[i].vars[0] := 1.0; cp.xform[i].vars[0] := 1.0;
for j := 1 to NVARS - 1 do cp.xform[i].vars[j] := 0; for j := 1 to NRVAR - 1 do
cp.xform[i].vars[j] := 0;
cp.xform[i].color := 1.0; cp.xform[i].color := 1.0;
cp.xform[i].c[0][0] := -1.0; cp.xform[i].c[0][0] := -1.0;
cp.xform[i].c[0][1] := 0.0; cp.xform[i].c[0][1] := 0.0;
@ -1561,7 +1590,7 @@ begin
cp.xform[i].density := 1.0; cp.xform[i].density := 1.0;
cp.xform[i].vars[0] := 1.0; cp.xform[i].vars[0] := 1.0;
cp.xform[i].symmetry := 1; cp.xform[i].symmetry := 1;
for j := 1 to NVARS - 1 do for j := 1 to NRVAR - 1 do
cp.xform[i].vars[j] := 0; cp.xform[i].vars[j] := 0;
if sym < 3 then if sym < 3 then
cp.xform[i].color := 0 cp.xform[i].color := 0

View File

@ -52,7 +52,7 @@ object EditForm: TEditForm
Left = 0 Left = 0
Top = 0 Top = 0
Width = 394 Width = 394
Height = 429 Height = 422
Align = alClient Align = alClient
BevelOuter = bvLowered BevelOuter = bvLowered
Color = clBlack Color = clBlack
@ -72,7 +72,7 @@ object EditForm: TEditForm
end end
object StatusBar: TStatusBar object StatusBar: TStatusBar
Left = 0 Left = 0
Top = 429 Top = 422
Width = 574 Width = 574
Height = 15 Height = 15
Panels = < Panels = <
@ -90,14 +90,14 @@ object EditForm: TEditForm
Left = 394 Left = 394
Top = 0 Top = 0
Width = 180 Width = 180
Height = 429 Height = 422
Align = alRight Align = alRight
Alignment = taLeftJustify Alignment = taLeftJustify
BevelOuter = bvNone BevelOuter = bvNone
TabOrder = 2 TabOrder = 2
DesignSize = ( DesignSize = (
180 180
429) 422)
object lblTransform: TLabel object lblTransform: TLabel
Left = 10 Left = 10
Top = 128 Top = 128
@ -136,7 +136,7 @@ object EditForm: TEditForm
Width = 57 Width = 57
Height = 21 Height = 21
Style = csDropDownList Style = csDropDownList
ItemHeight = 13 ItemHeight = 0
TabOrder = 1 TabOrder = 1
OnChange = cbTransformsChange OnChange = cbTransformsChange
end end

View File

@ -515,7 +515,7 @@ begin
EditForm.txtXFormColor.Text := FloatToStr(EditForm.cp.xform[t].color); EditForm.txtXFormColor.Text := FloatToStr(EditForm.cp.xform[t].color);
EditForm.scrlXFormcolor.Position := Trunc(EditForm.cp.xform[t].color * 100); EditForm.scrlXFormcolor.Position := Trunc(EditForm.cp.xform[t].color * 100);
for i := 0 to NVars-1 do begin for i := 0 to NRVISVAR-1 do begin
EditForm.VEVars.Values[VarNames[i]] := Format('%.6g', [EditForm.cp.xform[SelectedTriangle].vars[i]]); EditForm.VEVars.Values[VarNames[i]] := Format('%.6g', [EditForm.cp.xform[SelectedTriangle].vars[i]]);
end; end;
@ -639,7 +639,7 @@ begin
cp.xform[i].density := cp.xform[i + 1].density; cp.xform[i].density := cp.xform[i + 1].density;
cp.xform[i].color := cp.xform[i + 1].color; cp.xform[i].color := cp.xform[i + 1].color;
cp.xform[i].symmetry := cp.xform[i + 1].symmetry; cp.xform[i].symmetry := cp.xform[i + 1].symmetry;
for j := 0 to NVARS - 1 do for j := 0 to NRVAR - 1 do
cp.xform[i].vars[j] := cp.xform[i + 1].vars[j]; cp.xform[i].vars[j] := cp.xform[i + 1].vars[j];
end; end;
Transforms := Transforms - 1; Transforms := Transforms - 1;
@ -807,7 +807,7 @@ procedure TEditForm.FormCreate(Sender: TObject);
var var
i: integer; i: integer;
begin begin
for i:= 0 to NVars-1 do begin for i:= 0 to NRVISVAR - 1 do begin
VEVars.InsertRow(Varnames[i], '0', True); VEVars.InsertRow(Varnames[i], '0', True);
end; end;
@ -1149,7 +1149,7 @@ begin
SelectedTriangle := Transforms - 1; SelectedTriangle := Transforms - 1;
ComputeWeights(cp, MainTriangles, transforms); ComputeWeights(cp, MainTriangles, transforms);
cp.xform[Transforms - 1].vars[0] := 1; cp.xform[Transforms - 1].vars[0] := 1;
for i := 1 to NVARS - 1 do for i := 1 to NRVAR - 1 do
cp.xform[Transforms - 1].vars[i] := 0; cp.xform[Transforms - 1].vars[i] := 0;
cbTransforms.clear; cbTransforms.clear;
for i := 0 to Transforms - 1 do for i := 0 to Transforms - 1 do
@ -1168,7 +1168,7 @@ begin
Transforms := Transforms + 1; Transforms := Transforms + 1;
MainTriangles[Transforms - 1] := MainTriangles[SelectedTriangle]; MainTriangles[Transforms - 1] := MainTriangles[SelectedTriangle];
ComputeWeights(cp, MainTriangles, transforms); ComputeWeights(cp, MainTriangles, transforms);
for i := 0 to NVARS - 1 do for i := 0 to NRVAR - 1 do
cp.xform[Transforms - 1].vars[i] := cp.xform[SelectedTriangle].vars[i]; cp.xform[Transforms - 1].vars[i] := cp.xform[SelectedTriangle].vars[i];
SelectedTriangle := Transforms - 1; SelectedTriangle := Transforms - 1;
cbTransforms.clear; cbTransforms.clear;

View File

@ -21,7 +21,7 @@ interface
uses uses
SysUtils, Classes, SyncObjs, Controls, Graphics, Math, SysUtils, Classes, SyncObjs, Controls, Graphics, Math,
cmap, MyTypes, controlpoint; cmap, MyTypes, controlpoint, Xform;
type type
EFormatInvalid = class(Exception); EFormatInvalid = class(Exception);
@ -108,7 +108,7 @@ var
defFlameFile: string; defFlameFile: string;
SymmetryType: integer; SymmetryType: integer;
SymmetryOrder: integer; SymmetryOrder: integer;
Variations: array[0..NVARS - 1] of boolean; Variations: array[0..NRVAR - 1] of boolean;
VariationOptions: integer; VariationOptions: integer;
{ For random gradients } { For random gradients }
MinNodes, MaxNodes, MinHue, MaxHue, MinSat, MaxSat, MinLum, MaxLum: integer; MinNodes, MaxNodes, MinHue, MaxHue, MinSat, MaxSat, MinLum, MaxLum: integer;

View File

@ -27,7 +27,7 @@ uses
Jpeg, SyncObjs, SysUtils, ClipBrd, Graphics, Math, Global, MyTypes, Jpeg, SyncObjs, SysUtils, ClipBrd, Graphics, Math, Global, MyTypes,
Registry, RenderThread, Cmap, ExtDlgs, AppEvnts, ShellAPI, IdComponent, Registry, RenderThread, Cmap, ExtDlgs, AppEvnts, ShellAPI, IdComponent,
IdTCPConnection, IdTCPClient, IdHTTP, IdBaseComponent, IdIntercept, IdTCPConnection, IdTCPClient, IdHTTP, IdBaseComponent, IdIntercept,
IdLogBase, IdLogFile, LibXmlParser, LibXmlComps; IdLogBase, IdLogFile, LibXmlParser, LibXmlComps, Xform;
const const
PixelCountMax = 32768; PixelCountMax = 32768;
@ -302,7 +302,7 @@ type
Remainder: TDateTime; Remainder: TDateTime;
AnimPal: TColorMap; AnimPal: TColorMap;
VarMenus: array[0..NVARS] of TMenuItem; VarMenus: array[0..NRVISVAR] of TMenuItem;
procedure LoadXMLFlame(filename, name: string); procedure LoadXMLFlame(filename, name: string);
procedure DisableFavorites; procedure DisableFavorites;
@ -363,7 +363,7 @@ implementation
uses Editor, Options, Regstry, Gradient, Render, uses Editor, Options, Regstry, Gradient, Render,
FullScreen, FormRender, Mutate, Adjust, Browser, Save, About, CmapData, FullScreen, FormRender, Mutate, Adjust, Browser, Save, About, CmapData,
HtmlHlp, ScriptForm, FormFavorites, Size, FormExport, msMultiPartFormData, HtmlHlp, ScriptForm, FormFavorites, Size, FormExport, msMultiPartFormData,
Sheep, ImageColoring, RndFlame, XForm; Sheep, ImageColoring, RndFlame;
{$R *.DFM} {$R *.DFM}
@ -375,7 +375,7 @@ begin
for i := 0 to NXFORMS - 1 do for i := 0 to NXFORMS - 1 do
begin begin
totvar := 0; totvar := 0;
for j := 0 to NVARS - 1 do for j := 0 to NRVAR - 1 do
begin begin
if cp1.xform[i].vars[j] < 0 then cp1.xform[i].vars[j] := cp1.xform[i].vars[j] * -1; if cp1.xform[i].vars[j] < 0 then cp1.xform[i].vars[j] := cp1.xform[i].vars[j] * -1;
totvar := totvar + cp1.xform[i].vars[j]; totvar := totvar + cp1.xform[i].vars[j];
@ -385,7 +385,7 @@ begin
cp1.xform[i].vars[0] := 1; cp1.xform[i].vars[0] := 1;
end end
else else
for j := 0 to NVARS - 1 do begin for j := 0 to NRVAR - 1 do begin
if totVar <> 0 then if totVar <> 0 then
cp1.xform[i].vars[j] := cp1.xform[i].vars[j] / totvar; cp1.xform[i].vars[j] := cp1.xform[i].vars[j] / totvar;
end; end;
@ -486,7 +486,7 @@ var
r, i: cardinal; r, i: cardinal;
begin begin
r := 0; r := 0;
for i := 0 to NVARS - 1 do for i := 0 to NRVAR - 1 do
begin begin
r := r or byte(Variations[i]) shl i; r := r or byte(Variations[i]) shl i;
end; end;
@ -498,7 +498,7 @@ procedure UnpackVariations(v: integer);
var var
i: integer; i: integer;
begin begin
for i := 0 to NVARS - 1 do for i := 0 to NRVAR - 1 do
Variations[i] := boolean(v shr i and 1); Variations[i] := boolean(v shr i and 1);
end; end;
@ -587,7 +587,7 @@ var
i: integer; i: integer;
begin begin
for i := 0 to Transforms - 1 do for i := 0 to Transforms - 1 do
MainCp.xform[x].vars[i] := 1.0 / NVARS; MainCp.xform[x].vars[i] := 1.0 / NRVAR;
end; end;
procedure NormalVars(const x: integer); procedure NormalVars(const x: integer);
@ -614,13 +614,13 @@ begin
RandSeed := MainSeed; RandSeed := MainSeed;
for i := 0 to NumXForms(cp) - 1 do for i := 0 to NumXForms(cp) - 1 do
begin begin
for j := 0 to NVARS - 1 do for j := 0 to NRVAR - 1 do
cp.xform[i].vars[j] := 0; cp.xform[i].vars[j] := 0;
repeat repeat
a := random(NVARS); a := random(NRVISVAR);
until Variations[a]; until Variations[a];
repeat repeat
b := random(NVARS); b := random(NRVISVAR);
until Variations[b]; until Variations[b];
if (a = b) then if (a = b) then
begin begin
@ -646,7 +646,7 @@ begin
else else
for i := 0 to NumXForms(cp) - 1 do for i := 0 to NumXForms(cp) - 1 do
begin begin
for j := 0 to NVARS - 1 do for j := 0 to NRVAR - 1 do
cp.xform[i].vars[j] := 0; cp.xform[i].vars[j] := 0;
cp.xform[i].vars[integer(Variation)] := 1; cp.xform[i].vars[integer(Variation)] := 1;
end; end;
@ -1365,7 +1365,7 @@ begin
e := c[2][0]; e := c[2][0];
f := c[2][1]; f := c[2][1];
varlist := ''; varlist := '';
for j := 0 to NVARS - 1 do for j := 0 to NRVAR - 1 do
begin begin
if vars[j] <> 0 then if vars[j] <> 0 then
begin begin
@ -1431,7 +1431,7 @@ begin
e := c[2][0]; e := c[2][0];
f := c[2][1]; f := c[2][1];
varlist := ''; varlist := '';
for j := 0 to NVARS - 1 do for j := 0 to NRVAR - 1 do
begin begin
if vars[j] <> 0 then if vars[j] <> 0 then
begin begin
@ -2268,7 +2268,7 @@ begin
'p_xf' + inttostr(m) + '_cfd=' + Format('%.6g ', [d])); 'p_xf' + inttostr(m) + '_cfd=' + Format('%.6g ', [d]));
Strings.Add(' p_xf' + inttostr(m) + '_cfe=' + Format('%.6g ', [e]) + Strings.Add(' p_xf' + inttostr(m) + '_cfe=' + Format('%.6g ', [e]) +
' p_xf' + inttostr(m) + '_cff=' + Format('%.6g ', [f])); ' p_xf' + inttostr(m) + '_cff=' + Format('%.6g ', [f]));
for j := 0 to NVARS - 1 do for j := 0 to NRVAR - 1 do
Strings.Add(' p_xf' + inttostr(m) + '_var' + inttostr(j) + '=' + Strings.Add(' p_xf' + inttostr(m) + '_var' + inttostr(j) + '=' +
floatToStr(cp1.xform[m].vars[j])); floatToStr(cp1.xform[m].vars[j]));
end; end;
@ -3992,7 +3992,7 @@ begin
c[2][1] := StrToFloat(Tokens[5]); c[2][1] := StrToFloat(Tokens[5]);
end; end;
for i := 0 to NVARS - 1 do for i := 0 to NRVAR - 1 do
begin begin
Parsecp.xform[nxform].vars[i] := 0; Parsecp.xform[nxform].vars[i] := 0;
v := Attributes.Value(varnames[i]); v := Attributes.Value(varnames[i]);
@ -4003,17 +4003,17 @@ begin
v := Attributes.Value('var1'); v := Attributes.Value('var1');
if v <> '' then if v <> '' then
begin begin
for i := 0 to NVARS - 1 do for i := 0 to NRVAR - 1 do
Parsecp.xform[nxform].vars[i] := 0; Parsecp.xform[nxform].vars[i] := 0;
Parsecp.xform[nxform].vars[StrToInt(v)] := 1; Parsecp.xform[nxform].vars[StrToInt(v)] := 1;
end; end;
v := Attributes.Value('var'); v := Attributes.Value('var');
if v <> '' then if v <> '' then
begin begin
for i := 0 to NVARS - 1 do for i := 0 to NRVAR - 1 do
Parsecp.xform[nxform].vars[i] := 0; Parsecp.xform[nxform].vars[i] := 0;
GetTokens(v, tokens); GetTokens(v, tokens);
if Tokens.Count > NVARS then ShowMessage('To many vars..crash?'); if Tokens.Count > NRVAR then ShowMessage('To many vars..crash?');
for i := 0 to Tokens.Count - 1 do for i := 0 to Tokens.Count - 1 do
Parsecp.xform[nxform].vars[i] := StrToFloat(Tokens[i]); Parsecp.xform[nxform].vars[i] := StrToFloat(Tokens[i]);
end; end;
@ -4317,7 +4317,7 @@ var
i: integer; i: integer;
NewMenuItem : TMenuItem; NewMenuItem : TMenuItem;
begin begin
for i := 0 to NVARS - 1 do begin for i := 0 to NRVISVAR - 1 do begin
NewMenuItem := TMenuItem.Create(self); NewMenuItem := TMenuItem.Create(self);
NewMenuItem.Caption := uppercase(varnames[i][0]) + copy(varnames[i], 2, length(varnames[i])-1); NewMenuItem.Caption := uppercase(varnames[i][0]) + copy(varnames[i], 2, length(varnames[i])-1);
NewMenuItem.OnClick := VariantMenuClick; NewMenuItem.OnClick := VariantMenuClick;

View File

@ -300,7 +300,7 @@ begin
mutants[i].xform[j].c[1][1] := cps[0].xform[j].c[1][1]; mutants[i].xform[j].c[1][1] := cps[0].xform[j].c[1][1];
mutants[i].xform[j].c[2][0] := cps[0].xform[j].c[2][0]; mutants[i].xform[j].c[2][0] := cps[0].xform[j].c[2][0];
mutants[i].xform[j].c[2][1] := cps[0].xform[j].c[2][1]; mutants[i].xform[j].c[2][1] := cps[0].xform[j].c[2][1];
for k := 0 to NVARS - 1 do for k := 0 to NRVISVAR - 1 do
mutants[i].xform[j].vars[k] := cps[0].xform[j].vars[k]; mutants[i].xform[j].vars[k] := cps[0].xform[j].vars[k];
end; end;
end; end;
@ -354,7 +354,7 @@ var
begin begin
cmbTrend.Items.clear; cmbTrend.Items.clear;
cmbTrend.AddItem('Random', Tobject(vRandom)); cmbTrend.AddItem('Random', Tobject(vRandom));
for i:= 0 to NVars -1 do begin for i:= 0 to NRVISVAR -1 do begin
cmbTrend.AddItem(varnames[i], Tobject(i)); cmbTrend.AddItem(varnames[i], Tobject(i));
end; end;
@ -482,7 +482,7 @@ begin
cps[0].xform[i].c[1][1] := cpt.xform[i].c[1][1]; cps[0].xform[i].c[1][1] := cpt.xform[i].c[1][1];
cps[0].xform[i].c[2][0] := cpt.xform[i].c[2][0]; cps[0].xform[i].c[2][0] := cpt.xform[i].c[2][0];
cps[0].xform[i].c[2][1] := cpt.xform[i].c[2][1]; cps[0].xform[i].c[2][1] := cpt.xform[i].c[2][1];
for j := 0 to NVARS - 1 do for j := 0 to NRVAR - 1 do
cps[0].xform[i].vars[j] := cpt.xform[i].vars[j]; cps[0].xform[i].vars[j] := cpt.xform[i].vars[j];
end; end;
end; end;

View File

@ -274,7 +274,7 @@ begin
{ Variations tab } { Variations tab }
UnpackVariations(VariationOptions); UnpackVariations(VariationOptions);
for i := 0 to NVars -1 do for i := 0 to NRVISVAR -1 do
clbVarEnabled.Checked[i] := Variations[i]; clbVarEnabled.Checked[i] := Variations[i];
{ Gradient tab } { Gradient tab }
@ -318,7 +318,7 @@ begin
{ Variations tab } { Variations tab }
{ Get option values from controls. Disallow bad values } { Get option values from controls. Disallow bad values }
for i := 0 to NVars -1 do for i := 0 to NRVISVAR -1 do
Variations[i] := clbVarEnabled.Checked[i]; Variations[i] := clbVarEnabled.Checked[i];
v := PackVariations; v := PackVariations;
@ -471,7 +471,7 @@ procedure TOptionsForm.btnSetAllClick(Sender: TObject);
var var
i: integer; i: integer;
begin begin
for i := 0 to NVars - 1 do for i := 0 to NRVISVAR - 1 do
clbVarEnabled.Checked[i] := True; clbVarEnabled.Checked[i] := True;
end; end;
@ -479,7 +479,7 @@ procedure TOptionsForm.btnClearAllClick(Sender: TObject);
var var
i: integer; i: integer;
begin begin
for i := 0 to NVars - 1 do for i := 0 to NRVISVAR - 1 do
clbVarEnabled.Checked[i] := False; clbVarEnabled.Checked[i] := False;
end; end;
@ -582,7 +582,7 @@ procedure TOptionsForm.FormCreate(Sender: TObject);
var var
i: integer; i: integer;
begin begin
for i:= 0 to NVARS - 1 do begin for i:= 0 to NRVISVAR - 1 do begin
clbVarEnabled.AddItem(varnames[i],nil); clbVarEnabled.AddItem(varnames[i],nil);
end; end;
end; end;

View File

@ -33,7 +33,7 @@ procedure UnpackVariations(v: integer);
var var
i: integer; i: integer;
begin begin
for i := 0 to NVARS - 1 do for i := 0 to NRVAR - 1 do
Variations[i] := boolean(v shr i and 1); Variations[i] := boolean(v shr i and 1);
end; end;

View File

@ -28,7 +28,7 @@ function RandomFlame(SourceCP: TControlPoint= nil; algorithm: integer = 0): TCon
implementation implementation
uses uses
SysUtils, Global, cmap, MyTypes, GradientHlpr; SysUtils, Global, cmap, MyTypes, GradientHlpr, XForm;
/////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////
procedure RandomGradient(SourceCP, DestCP: TControlPoint); procedure RandomGradient(SourceCP, DestCP: TControlPoint);
@ -80,18 +80,33 @@ procedure RandomVariation(cp: TControlPoint);
{ Randomise variation parameters } { Randomise variation parameters }
var var
a, b, i, j: integer; a, b, i, j: integer;
VarPossible: boolean;
begin begin
inc(MainSeed); inc(MainSeed);
RandSeed := MainSeed; RandSeed := MainSeed;
VarPossible := false;
for j := 0 to NRVISVAR - 1 do begin
VarPossible := VarPossible or Variations[j];
end;
for i := 0 to NumXForms(cp) - 1 do begin for i := 0 to NumXForms(cp) - 1 do begin
for j := 0 to NVARS - 1 do for j := 0 to NRVAR - 1 do
cp.xform[i].vars[j] := 0; cp.xform[i].vars[j] := 0;
if VarPossible then begin
repeat repeat
a := random(NVARS); a := random(NRVISVAR);
until Variations[a]; until Variations[a];
repeat repeat
b := random(NVARS); b := random(NRVISVAR);
until Variations[b]; until Variations[b];
end else begin
a := 0;
b := 0;
end;
if (a = b) then begin if (a = b) then begin
cp.xform[i].vars[a] := 1; cp.xform[i].vars[a] := 1;
end else begin end else begin
@ -111,7 +126,7 @@ begin
RandomVariation(cp); RandomVariation(cp);
end else end else
for i := 0 to NumXForms(cp) - 1 do begin for i := 0 to NumXForms(cp) - 1 do begin
for j := 0 to NVARS - 1 do for j := 0 to NRVAR - 1 do
cp.xform[i].vars[j] := 0; cp.xform[i].vars[j] := 0;
cp.xform[i].vars[integer(Variation)] := 1; cp.xform[i].vars[integer(Variation)] := 1;
end; end;
@ -310,7 +325,7 @@ begin
Result.xform[i].color := 0; Result.xform[i].color := 0;
Result.xform[i].symmetry := 0; Result.xform[i].symmetry := 0;
Result.xform[i].vars[0] := 1; Result.xform[i].vars[0] := 1;
for j := 1 to NVARS - 1 do for j := 1 to NRVAR - 1 do
Result.xform[i].vars[j] := 0; Result.xform[i].vars[j] := 0;
Result.xform[i].Translate(random * 2 - 1, random * 2 - 1); Result.xform[i].Translate(random * 2 - 1, random * 2 - 1);
Result.xform[i].Rotate(random * 360); Result.xform[i].Rotate(random * 360);

View File

@ -165,7 +165,7 @@ object ScriptEditor: TScriptEditor
'end;') 'end;')
MarkerList.UseDefaultMarkerImageIndex = False MarkerList.UseDefaultMarkerImageIndex = False
MarkerList.DefaultMarkerImageIndex = -1 MarkerList.DefaultMarkerImageIndex = -1
MarkerList.ImageTransparentColor = 33554432 MarkerList.ImageTransparentColor = -1
PrintOptions.MarginLeft = 0 PrintOptions.MarginLeft = 0
PrintOptions.MarginRight = 0 PrintOptions.MarginRight = 0
PrintOptions.MarginTop = 0 PrintOptions.MarginTop = 0

View File

@ -784,7 +784,7 @@ begin
with AMachine do with AMachine do
begin begin
i := GetArrayIndex(0); i := GetArrayIndex(0);
if (i >= 0) and (i < NVARS) then if (i >= 0) and (i < NRVAR) then
ReturnOutPutArg(Variations[i]); ReturnOutPutArg(Variations[i]);
end; end;
end; end;
@ -798,7 +798,7 @@ begin
begin begin
v := GetInputArgAsBoolean(0); v := GetInputArgAsBoolean(0);
i := GetArrayIndex(0); i := GetArrayIndex(0);
if (i >= 0) and (i < NVARS) then if (i >= 0) and (i < NRVAR) then
begin begin
Variations[i] := v; Variations[i] := v;
vars := PackVariations; vars := PackVariations;
@ -1649,7 +1649,7 @@ begin
with AMachine do with AMachine do
begin begin
i := integer(Variation); i := integer(Variation);
if (i >= NVARS) or (i < 0) then if (i >= NRVAR) or (i < 0) then
i := -1; i := -1;
ReturnOutputArg(i); ReturnOutputArg(i);
end end
@ -1662,8 +1662,8 @@ begin
with AMachine do with AMachine do
begin begin
i := GetInputArgAsInteger(0); i := GetInputArgAsInteger(0);
if (i < 0) or (i >= NVARS) then if (i < 0) or (i >= NRVAR) then
i := NVARS; i := NRVAR;
Variation := TVariation(i); Variation := TVariation(i);
if i = -1 then if i = -1 then
MainForm.mnuVRandom.checked := True MainForm.mnuVRandom.checked := True
@ -1774,7 +1774,7 @@ begin
ScriptEditor.cp.xform[ActiveTransform].color := 0; ScriptEditor.cp.xform[ActiveTransform].color := 0;
ScriptEditor.cp.xform[ActiveTransform].density := 1 / NumTransforms; ScriptEditor.cp.xform[ActiveTransform].density := 1 / NumTransforms;
ScriptEditor.cp.xform[ActiveTransform].vars[0] := 1; ScriptEditor.cp.xform[ActiveTransform].vars[0] := 1;
for i := 1 to NVARS - 1 do for i := 1 to NRVAR - 1 do
ScriptEditor.cp.xform[ActiveTransform].vars[i] := 0; ScriptEditor.cp.xform[ActiveTransform].vars[i] := 0;
end end
else raise EFormatInvalid.Create('Too many transforms.'); else raise EFormatInvalid.Create('Too many transforms.');
@ -1809,7 +1809,7 @@ begin
ScriptEditor.cp.xform[i].density := ScriptEditor.cp.xform[i + 1].density; ScriptEditor.cp.xform[i].density := ScriptEditor.cp.xform[i + 1].density;
ScriptEditor.cp.xform[i].color := ScriptEditor.cp.xform[i + 1].color; ScriptEditor.cp.xform[i].color := ScriptEditor.cp.xform[i + 1].color;
ScriptEditor.cp.xform[i].symmetry := ScriptEditor.cp.xform[i + 1].symmetry; ScriptEditor.cp.xform[i].symmetry := ScriptEditor.cp.xform[i + 1].symmetry;
for j := 0 to NVARS - 1 do for j := 0 to NRVAR - 1 do
ScriptEditor.cp.xform[i].vars[j] := ScriptEditor.cp.xform[i + 1].vars[j]; ScriptEditor.cp.xform[i].vars[j] := ScriptEditor.cp.xform[i + 1].vars[j];
end; end;
NumTransforms := NumTransforms - 1; NumTransforms := NumTransforms - 1;
@ -1845,7 +1845,7 @@ begin
ScriptEditor.cp.xform[ActiveTransform].c[2, 1] := ScriptEditor.cp.xform[old].c[2, 1]; ScriptEditor.cp.xform[ActiveTransform].c[2, 1] := ScriptEditor.cp.xform[old].c[2, 1];
ScriptEditor.cp.xform[ActiveTransform].color := ScriptEditor.cp.xform[old].color; ScriptEditor.cp.xform[ActiveTransform].color := ScriptEditor.cp.xform[old].color;
ScriptEditor.cp.xform[ActiveTransform].density := ScriptEditor.cp.xform[old].density; ScriptEditor.cp.xform[ActiveTransform].density := ScriptEditor.cp.xform[old].density;
for i := 0 to NVARS - 1 do for i := 0 to NRVAR - 1 do
ScriptEditor.cp.xform[ActiveTransform].vars[i] := ScriptEditor.cp.xform[old].vars[i] ScriptEditor.cp.xform[ActiveTransform].vars[i] := ScriptEditor.cp.xform[old].vars[i]
end end
else raise EFormatInvalid.Create('Too many transforms.'); else raise EFormatInvalid.Create('Too many transforms.');
@ -1939,7 +1939,7 @@ begin
xform.color := 0; xform.color := 0;
xform.density := 1 / NumTransforms; xform.density := 1 / NumTransforms;
xform.vars[0] := 1; xform.vars[0] := 1;
for i := 1 to NVARS - 1 do for i := 1 to NRVAR - 1 do
xform.vars[i] := 0; xform.vars[i] := 0;
end; end;
@ -2476,7 +2476,7 @@ begin
begin begin
v := GetInputArgAsFloat(0); v := GetInputArgAsFloat(0);
i := GetArrayIndex(0); i := GetArrayIndex(0);
if (i >= 0) and (i < NVARS) then if (i >= 0) and (i < NRVAR) then
cp.xform[ActiveTransform].vars[i] := v; cp.xform[ActiveTransform].vars[i] := v;
end; end;
end; end;
@ -2648,7 +2648,7 @@ begin
Scripter.AddLibrary(TatClassesLibrary); Scripter.AddLibrary(TatClassesLibrary);
{ Variables and constants } { Variables and constants }
Scripter.AddConstant('PI', pi); Scripter.AddConstant('PI', pi);
Scripter.AddConstant('NVARS', NVARS); Scripter.AddConstant('NVARS', NRVAR);
Scripter.AddConstant('NXFORMS', NXFORMS); Scripter.AddConstant('NXFORMS', NXFORMS);
Scripter.AddConstant('INSTALLPATH', ExtractFilePath(Application.exename)); Scripter.AddConstant('INSTALLPATH', ExtractFilePath(Application.exename));
Scripter.AddConstant('SYM_NONE', 0); Scripter.AddConstant('SYM_NONE', 0);
@ -2960,7 +2960,7 @@ begin
dest.c[2, 1] := source.c[2, 1]; dest.c[2, 1] := source.c[2, 1];
dest.color := source.color; dest.color := source.color;
dest.density := source.density; dest.density := source.density;
for i := 0 to NVARS - 1 do for i := 0 to NRVAR - 1 do
dest.vars[i] := source.vars[i]; dest.vars[i] := source.vars[i];
end; end;

View File

@ -3,13 +3,10 @@ unit XForm;
interface interface
const const
{$IFDEF TESTVARIANT} NRVISVAR = 23;
NVARS = 28; NRVAR = 28;
{$ELSE}
NVARS = 27;
{$ENDIF}
varnames: array[0..NVARS -1] of PChar = ( varnames: array[0..NRVAR - 1] of PChar = (
'linear', 'linear',
'sinusoidal', 'sinusoidal',
'spherical', 'spherical',
@ -36,10 +33,8 @@ const
'triblob', 'triblob',
'daisy', 'daisy',
'checkers', 'checkers',
'crot' 'crot',
{$IFDEF TESTVARIANT} 'test'
,'test'
{$ENDIF}
); );
type type
@ -62,7 +57,7 @@ type
TXForm = class TXForm = class
private private
FNrFunctions: Integer; FNrFunctions: Integer;
FFunctionList: array[0..NVARS] of TCalcMethod; FFunctionList: array[0..NRVAR-1] of TCalcMethod;
FTx, FTy: double; FTx, FTy: double;
FPx, FPy: double; FPx, FPy: double;
@ -108,7 +103,7 @@ type
function Identity: TMatrix; function Identity: TMatrix;
public public
vars: array[0..NVARS - 1] of double; // normalized interp coefs between variations vars: array[0..NRVAR - 1] of double; // normalized interp coefs between variations
c: array[0..2, 0..1] of double; // the coefs to the affine part of the function c: array[0..2, 0..1] of double; // the coefs to the affine part of the function
density: double; // prob is this function is chosen. 0 - 1 density: double; // prob is this function is chosen. 0 - 1
color: double; // color coord for this function. 0 - 1 color: double; // color coord for this function. 0 - 1
@ -153,7 +148,7 @@ begin
density := 0; density := 0;
Color := 0; Color := 0;
Vars[0] := 1; Vars[0] := 1;
for i := 1 to NVARS - 1 do begin for i := 1 to NRVAR - 1 do begin
Vars[i] := 0; Vars[i] := 0;
end; end;
c[0, 0] := 1; c[0, 0] := 1;
@ -313,12 +308,10 @@ begin
Inc(FNrFunctions); Inc(FNrFunctions);
end; end;
{$IFDEF TESTVARIANT} if (vars[NRVAR -1] <> 0.0) then begin
if (vars[NVARS -1] <> 0.0) then begin
FFunctionList[FNrFunctions] := TestVar; FFunctionList[FNrFunctions] := TestVar;
Inc(FNrFunctions); Inc(FNrFunctions);
end; end;
{$ENDIF}
CalculateAngle := (vars[5] <> 0.0) or (vars[6] <> 0.0) or (vars[7] <> 0.0) or (vars[8] <> 0.0) or CalculateAngle := (vars[5] <> 0.0) or (vars[6] <> 0.0) or (vars[7] <> 0.0) or (vars[8] <> 0.0) or
(vars[12] <> 0.0) or (vars[13] <> 0.0) or (vars[21] <> 0.0) or (vars[22] <> 0.0); (vars[12] <> 0.0) or (vars[13] <> 0.0) or (vars[21] <> 0.0) or (vars[22] <> 0.0);
@ -672,7 +665,6 @@ end;
procedure TXForm.CRot; procedure TXForm.CRot;
var var
r : double; r : double;
dx, dy, dx2: double;
Angle: double; Angle: double;
begin begin
r := sqrt(FTx * FTx + FTy * FTy); r := sqrt(FTx * FTx + FTy * FTy);
@ -695,7 +687,7 @@ end;
procedure TXForm.TestVar; procedure TXForm.TestVar;
var var
r : double; r : double;
dx, dy, dx2: double; // dx, dy, dx2: double;
Angle: double; Angle: double;
begin begin
r := sqrt(FTx * FTx + FTy * FTy); r := sqrt(FTx * FTx + FTy * FTy);
@ -708,8 +700,8 @@ begin
// r:= R - 0.04 * sin(6.2 * R - 1) - 0.008 * R; // r:= R - 0.04 * sin(6.2 * R - 1) - 0.008 * R;
FPx := FPx + vars[NVars - 1] * r * cos(Angle); FPx := FPx + vars[NRVAR - 1] * r * cos(Angle);
FPy := FPy + vars[NVars - 1] * r * sin(Angle); FPy := FPy + vars[NRVAR - 1] * r * sin(Angle);
end; end;
/////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////