make the new variants temporary unavailable
This commit is contained in:
parent
11a7b08bc3
commit
0ded6d7136
@ -25,7 +25,6 @@ uses
|
||||
|
||||
const
|
||||
EPS = 1E-10;
|
||||
NVARS = Xform.NVARS;
|
||||
NXFORMS = 12;
|
||||
SUB_BATCH_SIZE = 10000;
|
||||
PREFILTER_WHITE = (1 shl 26);
|
||||
@ -137,9 +136,8 @@ uses
|
||||
SysUtils, math, global;
|
||||
|
||||
var
|
||||
var_distrib: array[0..NVARS + 18] of integer;
|
||||
mixed_var_distrib: array[0..NVARS + 8] of integer;
|
||||
|
||||
var_distrib: array[0..NRVISVAR + 18] of integer;
|
||||
mixed_var_distrib: array[0..NRVISVAR + 8] of integer;
|
||||
|
||||
{ TControlPoint }
|
||||
|
||||
@ -822,7 +820,7 @@ begin
|
||||
Inc(ParsePos);
|
||||
xform[CurrentXForm].c[2, 1] := StrToFloat(ParseValues[ParsePos]);
|
||||
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;
|
||||
end;
|
||||
|
||||
@ -856,13 +854,23 @@ procedure TControlPoint.SetVariation(vari: TVariation);
|
||||
var
|
||||
i, j, v: integer;
|
||||
rv: integer;
|
||||
VarPossible: boolean;
|
||||
begin
|
||||
repeat
|
||||
rv := var_distrib[random(Length(var_distrib))];
|
||||
until Variations[rv];
|
||||
VarPossible := false;
|
||||
for j := 0 to NRVISVAR - 1 do begin
|
||||
VarPossible := VarPossible or Variations[j];
|
||||
end;
|
||||
|
||||
if VarPossible then begin
|
||||
repeat
|
||||
rv := var_distrib[random(Length(var_distrib))];
|
||||
until Variations[rv];
|
||||
end else begin
|
||||
rv := 0;
|
||||
end;
|
||||
|
||||
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;
|
||||
end;
|
||||
|
||||
@ -870,9 +878,13 @@ begin
|
||||
begin
|
||||
if rv < 0 then
|
||||
begin
|
||||
repeat
|
||||
v := Mixed_var_distrib[random(Length(mixed_var_distrib))];
|
||||
until Variations[v]; // Use only Variations set in options
|
||||
if VarPossible then begin
|
||||
repeat
|
||||
v := Mixed_var_distrib[random(Length(mixed_var_distrib))];
|
||||
until Variations[v]; // Use only Variations set in options
|
||||
end else begin
|
||||
v := 0;
|
||||
end;
|
||||
xform[i].vars[v] := 1
|
||||
end
|
||||
else
|
||||
@ -888,6 +900,7 @@ var
|
||||
nrXforms: integer;
|
||||
i, j: integer;
|
||||
v, rv: integer;
|
||||
VarPossible: boolean;
|
||||
begin
|
||||
//hue_rotation := random;
|
||||
hue_rotation := 1;
|
||||
@ -897,9 +910,19 @@ begin
|
||||
|
||||
//nrXforms := xform_distrib[random(13)];
|
||||
nrXforms := random(Max - (Min - 1)) + Min;
|
||||
repeat
|
||||
rv := var_distrib[random(Length(var_distrib))];
|
||||
until Variations[rv];
|
||||
|
||||
VarPossible := false;
|
||||
for j := 0 to NRVISVAR - 1 do begin
|
||||
VarPossible := VarPossible or Variations[j];
|
||||
end;
|
||||
|
||||
if VarPossible then begin
|
||||
repeat
|
||||
rv := var_distrib[random(Length(var_distrib))];
|
||||
until Variations[rv];
|
||||
end else begin
|
||||
rv := 0;
|
||||
end;
|
||||
|
||||
for i := 0 to NXFORMS - 1 do begin
|
||||
xform[i].density := 0;
|
||||
@ -916,18 +939,23 @@ begin
|
||||
xform[i].c[2][0] := 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;
|
||||
end;
|
||||
|
||||
for j := 0 to NVARS - 1 do begin
|
||||
for j := 0 to NRVAR - 1 do begin
|
||||
xform[i].vars[j] := 0;
|
||||
end;
|
||||
|
||||
if rv < 0 then begin
|
||||
repeat
|
||||
v := Mixed_var_distrib[random(Length(mixed_var_distrib))];
|
||||
until Variations[v]; // use only variations set in options
|
||||
if VarPossible then begin
|
||||
repeat
|
||||
v := Mixed_var_distrib[random(Length(mixed_var_distrib))];
|
||||
until Variations[v]; // use only variations set in options
|
||||
end else begin
|
||||
v := 0;
|
||||
end;
|
||||
|
||||
xform[i].vars[v] := 1
|
||||
end else
|
||||
xform[i].vars[rv] := 1;
|
||||
@ -943,7 +971,7 @@ var
|
||||
begin
|
||||
RandomCP;
|
||||
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;
|
||||
end;
|
||||
xform[i].vars[0] := 1;
|
||||
@ -1237,7 +1265,7 @@ 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].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];
|
||||
end;
|
||||
|
||||
@ -1352,7 +1380,7 @@ begin
|
||||
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].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];
|
||||
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]));
|
||||
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]]);
|
||||
end;
|
||||
sl.add(s);
|
||||
@ -1487,7 +1515,7 @@ begin
|
||||
xform[i].symmetry := 0;
|
||||
xform[i].color := 0;
|
||||
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;
|
||||
end;
|
||||
end;
|
||||
@ -1538,7 +1566,8 @@ begin
|
||||
cp.xform[i].density := 1.0;
|
||||
cp.xform[i].symmetry := 1;
|
||||
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].c[0][0] := -1.0;
|
||||
cp.xform[i].c[0][1] := 0.0;
|
||||
@ -1561,7 +1590,7 @@ begin
|
||||
cp.xform[i].density := 1.0;
|
||||
cp.xform[i].vars[0] := 1.0;
|
||||
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;
|
||||
if sym < 3 then
|
||||
cp.xform[i].color := 0
|
||||
|
@ -52,7 +52,7 @@ object EditForm: TEditForm
|
||||
Left = 0
|
||||
Top = 0
|
||||
Width = 394
|
||||
Height = 429
|
||||
Height = 422
|
||||
Align = alClient
|
||||
BevelOuter = bvLowered
|
||||
Color = clBlack
|
||||
@ -72,7 +72,7 @@ object EditForm: TEditForm
|
||||
end
|
||||
object StatusBar: TStatusBar
|
||||
Left = 0
|
||||
Top = 429
|
||||
Top = 422
|
||||
Width = 574
|
||||
Height = 15
|
||||
Panels = <
|
||||
@ -90,14 +90,14 @@ object EditForm: TEditForm
|
||||
Left = 394
|
||||
Top = 0
|
||||
Width = 180
|
||||
Height = 429
|
||||
Height = 422
|
||||
Align = alRight
|
||||
Alignment = taLeftJustify
|
||||
BevelOuter = bvNone
|
||||
TabOrder = 2
|
||||
DesignSize = (
|
||||
180
|
||||
429)
|
||||
422)
|
||||
object lblTransform: TLabel
|
||||
Left = 10
|
||||
Top = 128
|
||||
@ -136,7 +136,7 @@ object EditForm: TEditForm
|
||||
Width = 57
|
||||
Height = 21
|
||||
Style = csDropDownList
|
||||
ItemHeight = 13
|
||||
ItemHeight = 0
|
||||
TabOrder = 1
|
||||
OnChange = cbTransformsChange
|
||||
end
|
||||
|
@ -515,7 +515,7 @@ begin
|
||||
EditForm.txtXFormColor.Text := FloatToStr(EditForm.cp.xform[t].color);
|
||||
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]]);
|
||||
end;
|
||||
|
||||
@ -639,7 +639,7 @@ begin
|
||||
cp.xform[i].density := cp.xform[i + 1].density;
|
||||
cp.xform[i].color := cp.xform[i + 1].color;
|
||||
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];
|
||||
end;
|
||||
Transforms := Transforms - 1;
|
||||
@ -807,7 +807,7 @@ procedure TEditForm.FormCreate(Sender: TObject);
|
||||
var
|
||||
i: integer;
|
||||
begin
|
||||
for i:= 0 to NVars-1 do begin
|
||||
for i:= 0 to NRVISVAR - 1 do begin
|
||||
VEVars.InsertRow(Varnames[i], '0', True);
|
||||
end;
|
||||
|
||||
@ -1149,7 +1149,7 @@ begin
|
||||
SelectedTriangle := Transforms - 1;
|
||||
ComputeWeights(cp, MainTriangles, transforms);
|
||||
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;
|
||||
cbTransforms.clear;
|
||||
for i := 0 to Transforms - 1 do
|
||||
@ -1168,7 +1168,7 @@ begin
|
||||
Transforms := Transforms + 1;
|
||||
MainTriangles[Transforms - 1] := MainTriangles[SelectedTriangle];
|
||||
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];
|
||||
SelectedTriangle := Transforms - 1;
|
||||
cbTransforms.clear;
|
||||
|
@ -21,7 +21,7 @@ interface
|
||||
|
||||
uses
|
||||
SysUtils, Classes, SyncObjs, Controls, Graphics, Math,
|
||||
cmap, MyTypes, controlpoint;
|
||||
cmap, MyTypes, controlpoint, Xform;
|
||||
|
||||
type
|
||||
EFormatInvalid = class(Exception);
|
||||
@ -108,7 +108,7 @@ var
|
||||
defFlameFile: string;
|
||||
SymmetryType: integer;
|
||||
SymmetryOrder: integer;
|
||||
Variations: array[0..NVARS - 1] of boolean;
|
||||
Variations: array[0..NRVAR - 1] of boolean;
|
||||
VariationOptions: integer;
|
||||
{ For random gradients }
|
||||
MinNodes, MaxNodes, MinHue, MaxHue, MinSat, MaxSat, MinLum, MaxLum: integer;
|
||||
|
@ -27,7 +27,7 @@ uses
|
||||
Jpeg, SyncObjs, SysUtils, ClipBrd, Graphics, Math, Global, MyTypes,
|
||||
Registry, RenderThread, Cmap, ExtDlgs, AppEvnts, ShellAPI, IdComponent,
|
||||
IdTCPConnection, IdTCPClient, IdHTTP, IdBaseComponent, IdIntercept,
|
||||
IdLogBase, IdLogFile, LibXmlParser, LibXmlComps;
|
||||
IdLogBase, IdLogFile, LibXmlParser, LibXmlComps, Xform;
|
||||
|
||||
const
|
||||
PixelCountMax = 32768;
|
||||
@ -302,7 +302,7 @@ type
|
||||
Remainder: TDateTime;
|
||||
AnimPal: TColorMap;
|
||||
|
||||
VarMenus: array[0..NVARS] of TMenuItem;
|
||||
VarMenus: array[0..NRVISVAR] of TMenuItem;
|
||||
|
||||
procedure LoadXMLFlame(filename, name: string);
|
||||
procedure DisableFavorites;
|
||||
@ -363,7 +363,7 @@ implementation
|
||||
uses Editor, Options, Regstry, Gradient, Render,
|
||||
FullScreen, FormRender, Mutate, Adjust, Browser, Save, About, CmapData,
|
||||
HtmlHlp, ScriptForm, FormFavorites, Size, FormExport, msMultiPartFormData,
|
||||
Sheep, ImageColoring, RndFlame, XForm;
|
||||
Sheep, ImageColoring, RndFlame;
|
||||
|
||||
{$R *.DFM}
|
||||
|
||||
@ -375,7 +375,7 @@ begin
|
||||
for i := 0 to NXFORMS - 1 do
|
||||
begin
|
||||
totvar := 0;
|
||||
for j := 0 to NVARS - 1 do
|
||||
for j := 0 to NRVAR - 1 do
|
||||
begin
|
||||
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];
|
||||
@ -385,7 +385,7 @@ begin
|
||||
cp1.xform[i].vars[0] := 1;
|
||||
end
|
||||
else
|
||||
for j := 0 to NVARS - 1 do begin
|
||||
for j := 0 to NRVAR - 1 do begin
|
||||
if totVar <> 0 then
|
||||
cp1.xform[i].vars[j] := cp1.xform[i].vars[j] / totvar;
|
||||
end;
|
||||
@ -486,7 +486,7 @@ var
|
||||
r, i: cardinal;
|
||||
begin
|
||||
r := 0;
|
||||
for i := 0 to NVARS - 1 do
|
||||
for i := 0 to NRVAR - 1 do
|
||||
begin
|
||||
r := r or byte(Variations[i]) shl i;
|
||||
end;
|
||||
@ -498,7 +498,7 @@ procedure UnpackVariations(v: integer);
|
||||
var
|
||||
i: integer;
|
||||
begin
|
||||
for i := 0 to NVARS - 1 do
|
||||
for i := 0 to NRVAR - 1 do
|
||||
Variations[i] := boolean(v shr i and 1);
|
||||
end;
|
||||
|
||||
@ -587,7 +587,7 @@ var
|
||||
i: integer;
|
||||
begin
|
||||
for i := 0 to Transforms - 1 do
|
||||
MainCp.xform[x].vars[i] := 1.0 / NVARS;
|
||||
MainCp.xform[x].vars[i] := 1.0 / NRVAR;
|
||||
end;
|
||||
|
||||
procedure NormalVars(const x: integer);
|
||||
@ -614,13 +614,13 @@ begin
|
||||
RandSeed := MainSeed;
|
||||
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;
|
||||
repeat
|
||||
a := random(NVARS);
|
||||
a := random(NRVISVAR);
|
||||
until Variations[a];
|
||||
repeat
|
||||
b := random(NVARS);
|
||||
b := random(NRVISVAR);
|
||||
until Variations[b];
|
||||
if (a = b) then
|
||||
begin
|
||||
@ -646,7 +646,7 @@ begin
|
||||
else
|
||||
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[integer(Variation)] := 1;
|
||||
end;
|
||||
@ -1365,7 +1365,7 @@ begin
|
||||
e := c[2][0];
|
||||
f := c[2][1];
|
||||
varlist := '';
|
||||
for j := 0 to NVARS - 1 do
|
||||
for j := 0 to NRVAR - 1 do
|
||||
begin
|
||||
if vars[j] <> 0 then
|
||||
begin
|
||||
@ -1431,7 +1431,7 @@ begin
|
||||
e := c[2][0];
|
||||
f := c[2][1];
|
||||
varlist := '';
|
||||
for j := 0 to NVARS - 1 do
|
||||
for j := 0 to NRVAR - 1 do
|
||||
begin
|
||||
if vars[j] <> 0 then
|
||||
begin
|
||||
@ -2268,7 +2268,7 @@ begin
|
||||
'p_xf' + inttostr(m) + '_cfd=' + Format('%.6g ', [d]));
|
||||
Strings.Add(' p_xf' + inttostr(m) + '_cfe=' + Format('%.6g ', [e]) +
|
||||
' 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) + '=' +
|
||||
floatToStr(cp1.xform[m].vars[j]));
|
||||
end;
|
||||
@ -3992,7 +3992,7 @@ begin
|
||||
c[2][1] := StrToFloat(Tokens[5]);
|
||||
end;
|
||||
|
||||
for i := 0 to NVARS - 1 do
|
||||
for i := 0 to NRVAR - 1 do
|
||||
begin
|
||||
Parsecp.xform[nxform].vars[i] := 0;
|
||||
v := Attributes.Value(varnames[i]);
|
||||
@ -4003,17 +4003,17 @@ begin
|
||||
v := Attributes.Value('var1');
|
||||
if v <> '' then
|
||||
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[StrToInt(v)] := 1;
|
||||
end;
|
||||
v := Attributes.Value('var');
|
||||
if v <> '' then
|
||||
begin
|
||||
for i := 0 to NVARS - 1 do
|
||||
for i := 0 to NRVAR - 1 do
|
||||
Parsecp.xform[nxform].vars[i] := 0;
|
||||
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
|
||||
Parsecp.xform[nxform].vars[i] := StrToFloat(Tokens[i]);
|
||||
end;
|
||||
@ -4317,7 +4317,7 @@ var
|
||||
i: integer;
|
||||
NewMenuItem : TMenuItem;
|
||||
begin
|
||||
for i := 0 to NVARS - 1 do begin
|
||||
for i := 0 to NRVISVAR - 1 do begin
|
||||
NewMenuItem := TMenuItem.Create(self);
|
||||
NewMenuItem.Caption := uppercase(varnames[i][0]) + copy(varnames[i], 2, length(varnames[i])-1);
|
||||
NewMenuItem.OnClick := VariantMenuClick;
|
||||
|
@ -300,7 +300,7 @@ begin
|
||||
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][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];
|
||||
end;
|
||||
end;
|
||||
@ -354,7 +354,7 @@ var
|
||||
begin
|
||||
cmbTrend.Items.clear;
|
||||
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));
|
||||
end;
|
||||
|
||||
@ -482,7 +482,7 @@ begin
|
||||
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][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];
|
||||
end;
|
||||
end;
|
||||
|
@ -274,7 +274,7 @@ begin
|
||||
|
||||
{ Variations tab }
|
||||
UnpackVariations(VariationOptions);
|
||||
for i := 0 to NVars -1 do
|
||||
for i := 0 to NRVISVAR -1 do
|
||||
clbVarEnabled.Checked[i] := Variations[i];
|
||||
|
||||
{ Gradient tab }
|
||||
@ -318,7 +318,7 @@ begin
|
||||
|
||||
{ Variations tab }
|
||||
{ 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];
|
||||
|
||||
v := PackVariations;
|
||||
@ -471,7 +471,7 @@ procedure TOptionsForm.btnSetAllClick(Sender: TObject);
|
||||
var
|
||||
i: integer;
|
||||
begin
|
||||
for i := 0 to NVars - 1 do
|
||||
for i := 0 to NRVISVAR - 1 do
|
||||
clbVarEnabled.Checked[i] := True;
|
||||
end;
|
||||
|
||||
@ -479,7 +479,7 @@ procedure TOptionsForm.btnClearAllClick(Sender: TObject);
|
||||
var
|
||||
i: integer;
|
||||
begin
|
||||
for i := 0 to NVars - 1 do
|
||||
for i := 0 to NRVISVAR - 1 do
|
||||
clbVarEnabled.Checked[i] := False;
|
||||
end;
|
||||
|
||||
@ -582,7 +582,7 @@ procedure TOptionsForm.FormCreate(Sender: TObject);
|
||||
var
|
||||
i: integer;
|
||||
begin
|
||||
for i:= 0 to NVARS - 1 do begin
|
||||
for i:= 0 to NRVISVAR - 1 do begin
|
||||
clbVarEnabled.AddItem(varnames[i],nil);
|
||||
end;
|
||||
end;
|
||||
|
@ -33,7 +33,7 @@ procedure UnpackVariations(v: integer);
|
||||
var
|
||||
i: integer;
|
||||
begin
|
||||
for i := 0 to NVARS - 1 do
|
||||
for i := 0 to NRVAR - 1 do
|
||||
Variations[i] := boolean(v shr i and 1);
|
||||
end;
|
||||
|
||||
|
@ -28,7 +28,7 @@ function RandomFlame(SourceCP: TControlPoint= nil; algorithm: integer = 0): TCon
|
||||
implementation
|
||||
|
||||
uses
|
||||
SysUtils, Global, cmap, MyTypes, GradientHlpr;
|
||||
SysUtils, Global, cmap, MyTypes, GradientHlpr, XForm;
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
procedure RandomGradient(SourceCP, DestCP: TControlPoint);
|
||||
@ -80,18 +80,33 @@ procedure RandomVariation(cp: TControlPoint);
|
||||
{ Randomise variation parameters }
|
||||
var
|
||||
a, b, i, j: integer;
|
||||
VarPossible: boolean;
|
||||
begin
|
||||
inc(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 j := 0 to NVARS - 1 do
|
||||
for j := 0 to NRVAR - 1 do
|
||||
cp.xform[i].vars[j] := 0;
|
||||
repeat
|
||||
a := random(NVARS);
|
||||
until Variations[a];
|
||||
repeat
|
||||
b := random(NVARS);
|
||||
until Variations[b];
|
||||
|
||||
if VarPossible then begin
|
||||
repeat
|
||||
a := random(NRVISVAR);
|
||||
until Variations[a];
|
||||
|
||||
repeat
|
||||
b := random(NRVISVAR);
|
||||
until Variations[b];
|
||||
end else begin
|
||||
a := 0;
|
||||
b := 0;
|
||||
end;
|
||||
|
||||
if (a = b) then begin
|
||||
cp.xform[i].vars[a] := 1;
|
||||
end else begin
|
||||
@ -111,7 +126,7 @@ begin
|
||||
RandomVariation(cp);
|
||||
end else
|
||||
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[integer(Variation)] := 1;
|
||||
end;
|
||||
@ -310,7 +325,7 @@ begin
|
||||
Result.xform[i].color := 0;
|
||||
Result.xform[i].symmetry := 0;
|
||||
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].Translate(random * 2 - 1, random * 2 - 1);
|
||||
Result.xform[i].Rotate(random * 360);
|
||||
|
@ -165,7 +165,7 @@ object ScriptEditor: TScriptEditor
|
||||
'end;')
|
||||
MarkerList.UseDefaultMarkerImageIndex = False
|
||||
MarkerList.DefaultMarkerImageIndex = -1
|
||||
MarkerList.ImageTransparentColor = 33554432
|
||||
MarkerList.ImageTransparentColor = -1
|
||||
PrintOptions.MarginLeft = 0
|
||||
PrintOptions.MarginRight = 0
|
||||
PrintOptions.MarginTop = 0
|
||||
|
@ -784,7 +784,7 @@ begin
|
||||
with AMachine do
|
||||
begin
|
||||
i := GetArrayIndex(0);
|
||||
if (i >= 0) and (i < NVARS) then
|
||||
if (i >= 0) and (i < NRVAR) then
|
||||
ReturnOutPutArg(Variations[i]);
|
||||
end;
|
||||
end;
|
||||
@ -798,7 +798,7 @@ begin
|
||||
begin
|
||||
v := GetInputArgAsBoolean(0);
|
||||
i := GetArrayIndex(0);
|
||||
if (i >= 0) and (i < NVARS) then
|
||||
if (i >= 0) and (i < NRVAR) then
|
||||
begin
|
||||
Variations[i] := v;
|
||||
vars := PackVariations;
|
||||
@ -1649,7 +1649,7 @@ begin
|
||||
with AMachine do
|
||||
begin
|
||||
i := integer(Variation);
|
||||
if (i >= NVARS) or (i < 0) then
|
||||
if (i >= NRVAR) or (i < 0) then
|
||||
i := -1;
|
||||
ReturnOutputArg(i);
|
||||
end
|
||||
@ -1662,8 +1662,8 @@ begin
|
||||
with AMachine do
|
||||
begin
|
||||
i := GetInputArgAsInteger(0);
|
||||
if (i < 0) or (i >= NVARS) then
|
||||
i := NVARS;
|
||||
if (i < 0) or (i >= NRVAR) then
|
||||
i := NRVAR;
|
||||
Variation := TVariation(i);
|
||||
if i = -1 then
|
||||
MainForm.mnuVRandom.checked := True
|
||||
@ -1774,7 +1774,7 @@ begin
|
||||
ScriptEditor.cp.xform[ActiveTransform].color := 0;
|
||||
ScriptEditor.cp.xform[ActiveTransform].density := 1 / NumTransforms;
|
||||
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;
|
||||
end
|
||||
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].color := ScriptEditor.cp.xform[i + 1].color;
|
||||
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];
|
||||
end;
|
||||
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].color := ScriptEditor.cp.xform[old].color;
|
||||
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]
|
||||
end
|
||||
else raise EFormatInvalid.Create('Too many transforms.');
|
||||
@ -1939,7 +1939,7 @@ begin
|
||||
xform.color := 0;
|
||||
xform.density := 1 / NumTransforms;
|
||||
xform.vars[0] := 1;
|
||||
for i := 1 to NVARS - 1 do
|
||||
for i := 1 to NRVAR - 1 do
|
||||
xform.vars[i] := 0;
|
||||
end;
|
||||
|
||||
@ -2476,7 +2476,7 @@ begin
|
||||
begin
|
||||
v := GetInputArgAsFloat(0);
|
||||
i := GetArrayIndex(0);
|
||||
if (i >= 0) and (i < NVARS) then
|
||||
if (i >= 0) and (i < NRVAR) then
|
||||
cp.xform[ActiveTransform].vars[i] := v;
|
||||
end;
|
||||
end;
|
||||
@ -2648,7 +2648,7 @@ begin
|
||||
Scripter.AddLibrary(TatClassesLibrary);
|
||||
{ Variables and constants }
|
||||
Scripter.AddConstant('PI', pi);
|
||||
Scripter.AddConstant('NVARS', NVARS);
|
||||
Scripter.AddConstant('NVARS', NRVAR);
|
||||
Scripter.AddConstant('NXFORMS', NXFORMS);
|
||||
Scripter.AddConstant('INSTALLPATH', ExtractFilePath(Application.exename));
|
||||
Scripter.AddConstant('SYM_NONE', 0);
|
||||
@ -2960,7 +2960,7 @@ begin
|
||||
dest.c[2, 1] := source.c[2, 1];
|
||||
dest.color := source.color;
|
||||
dest.density := source.density;
|
||||
for i := 0 to NVARS - 1 do
|
||||
for i := 0 to NRVAR - 1 do
|
||||
dest.vars[i] := source.vars[i];
|
||||
end;
|
||||
|
||||
|
@ -3,13 +3,10 @@ unit XForm;
|
||||
interface
|
||||
|
||||
const
|
||||
{$IFDEF TESTVARIANT}
|
||||
NVARS = 28;
|
||||
{$ELSE}
|
||||
NVARS = 27;
|
||||
{$ENDIF}
|
||||
NRVISVAR = 23;
|
||||
NRVAR = 28;
|
||||
|
||||
varnames: array[0..NVARS -1] of PChar = (
|
||||
varnames: array[0..NRVAR - 1] of PChar = (
|
||||
'linear',
|
||||
'sinusoidal',
|
||||
'spherical',
|
||||
@ -36,10 +33,8 @@ const
|
||||
'triblob',
|
||||
'daisy',
|
||||
'checkers',
|
||||
'crot'
|
||||
{$IFDEF TESTVARIANT}
|
||||
,'test'
|
||||
{$ENDIF}
|
||||
'crot',
|
||||
'test'
|
||||
);
|
||||
|
||||
type
|
||||
@ -62,7 +57,7 @@ type
|
||||
TXForm = class
|
||||
private
|
||||
FNrFunctions: Integer;
|
||||
FFunctionList: array[0..NVARS] of TCalcMethod;
|
||||
FFunctionList: array[0..NRVAR-1] of TCalcMethod;
|
||||
|
||||
FTx, FTy: double;
|
||||
FPx, FPy: double;
|
||||
@ -108,7 +103,7 @@ type
|
||||
function Identity: TMatrix;
|
||||
|
||||
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
|
||||
density: double; // prob is this function is chosen. 0 - 1
|
||||
color: double; // color coord for this function. 0 - 1
|
||||
@ -153,7 +148,7 @@ begin
|
||||
density := 0;
|
||||
Color := 0;
|
||||
Vars[0] := 1;
|
||||
for i := 1 to NVARS - 1 do begin
|
||||
for i := 1 to NRVAR - 1 do begin
|
||||
Vars[i] := 0;
|
||||
end;
|
||||
c[0, 0] := 1;
|
||||
@ -313,12 +308,10 @@ begin
|
||||
Inc(FNrFunctions);
|
||||
end;
|
||||
|
||||
{$IFDEF TESTVARIANT}
|
||||
if (vars[NVARS -1] <> 0.0) then begin
|
||||
if (vars[NRVAR -1] <> 0.0) then begin
|
||||
FFunctionList[FNrFunctions] := TestVar;
|
||||
Inc(FNrFunctions);
|
||||
end;
|
||||
{$ENDIF}
|
||||
|
||||
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);
|
||||
@ -672,7 +665,6 @@ end;
|
||||
procedure TXForm.CRot;
|
||||
var
|
||||
r : double;
|
||||
dx, dy, dx2: double;
|
||||
Angle: double;
|
||||
begin
|
||||
r := sqrt(FTx * FTx + FTy * FTy);
|
||||
@ -695,7 +687,7 @@ end;
|
||||
procedure TXForm.TestVar;
|
||||
var
|
||||
r : double;
|
||||
dx, dy, dx2: double;
|
||||
// dx, dy, dx2: double;
|
||||
Angle: double;
|
||||
begin
|
||||
r := sqrt(FTx * FTx + FTy * FTy);
|
||||
@ -708,8 +700,8 @@ begin
|
||||
|
||||
// r:= R - 0.04 * sin(6.2 * R - 1) - 0.008 * R;
|
||||
|
||||
FPx := FPx + vars[NVars - 1] * r * cos(Angle);
|
||||
FPy := FPy + vars[NVars - 1] * r * sin(Angle);
|
||||
FPx := FPx + vars[NRVAR - 1] * r * cos(Angle);
|
||||
FPy := FPy + vars[NRVAR - 1] * r * sin(Angle);
|
||||
end;
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
Loading…
Reference in New Issue
Block a user