"on/off" plot mode replaced with "opacity" value

"symmetry" renamed to "color_speed" (almost...)
This commit is contained in:
zueuk 2009-04-20 07:53:17 +00:00
parent 164690e28a
commit 054b513e0e
2 changed files with 74 additions and 66 deletions

View File

@ -170,7 +170,6 @@ type
function Clone: TControlPoint; function Clone: TControlPoint;
procedure Copy(cp1: TControlPoint; KeepSizes: boolean = false); procedure Copy(cp1: TControlPoint; KeepSizes: boolean = false);
// function HasNewVariants: boolean;
function HasFinalXForm: boolean; function HasFinalXForm: boolean;
// CP-specific functions moved from unit Main // CP-specific functions moved from unit Main
@ -327,8 +326,15 @@ begin
invalidXform.PrepareInvalidXForm; invalidXform.PrepareInvalidXForm;
if soloXform >= 0 then begin if soloXform >= 0 then begin
for i := 0 to n - 1 do xform[i].noPlot := true; for i := 0 to n - 1 do xform[i].plotMode := -1; //neverPlot;
xform[soloXform].noPlot := false; xform[soloXform].plotMode := 1; //alwaysPlot;
end
else begin
for i := 0 to n - 1 do with xform[i] do begin
if opacity = 0 then plotMode := -1 //neverPlot
else if opacity = 1 then plotMode := 1 //alwaysPlot
else plotMode := 0; //opacityPlot;
end;
end; end;
for k := 0 to n - 1 do begin for k := 0 to n - 1 do begin
@ -336,7 +342,7 @@ begin
SetLength(xform[k].PropTable, PROP_TABLE_SIZE); SetLength(xform[k].PropTable, PROP_TABLE_SIZE);
for i := 0 to n - 1 do begin for i := 0 to n - 1 do begin
tp[i] := xform[i].density * xform[k].modWeights[i]; tp[i] := xform[i].weight * xform[k].modWeights[i];
totValue := totValue + tp[i]; totValue := totValue + tp[i];
end; end;
@ -459,7 +465,9 @@ end;
xf := xf.PropTable[Random(PROP_TABLE_SIZE)]; xf := xf.PropTable[Random(PROP_TABLE_SIZE)];
xf.NextPoint(p); xf.NextPoint(p);
if xf.noPlot then if (xf.plotMode < 0) or
((xf.plotMode = 0) and (random > xf.opacity))
then
pPoint^.x := MaxDouble // hack pPoint^.x := MaxDouble // hack
else else
finalXform.NextPointTo(p, pPoint^); finalXform.NextPointTo(p, pPoint^);
@ -470,7 +478,10 @@ end;
for i := 0 to NrPoints - 1 do begin for i := 0 to NrPoints - 1 do begin
xf := xf.PropTable[Random(PROP_TABLE_SIZE)]; xf := xf.PropTable[Random(PROP_TABLE_SIZE)];
xf.NextPoint(p); xf.NextPoint(p);
if xf.noPlot then
if (xf.plotMode < 0) or
((xf.plotMode = 0) and (random > xf.opacity))
then
pPoint^.x := MaxDouble // hack pPoint^.x := MaxDouble // hack
else begin else begin
pPoint^ := p; pPoint^ := p;
@ -785,15 +796,15 @@ begin
// Inc(ParsePos); // Inc(ParsePos);
// cmapindex := StrToInt(ParseValues[ParsePos]); // cmapindex := StrToInt(ParseValues[ParsePos]);
OutputDebugString(Pchar('NYI import Palette')); OutputDebugString(Pchar('NYI import Palette'));
end else if AnsiCompareText(CurrentToken, 'density') = 0 then begin end else if AnsiCompareText(CurrentToken, 'weight') = 0 then begin
Inc(ParsePos); Inc(ParsePos);
xform[CurrentXForm].Density := StrToFloat(ParseValues[ParsePos]); xform[CurrentXForm].weight := StrToFloat(ParseValues[ParsePos]);
end else if AnsiCompareText(CurrentToken, 'color') = 0 then begin end else if AnsiCompareText(CurrentToken, 'color') = 0 then begin
Inc(ParsePos); Inc(ParsePos);
xform[CurrentXForm].color := StrToFloat(ParseValues[ParsePos]); xform[CurrentXForm].color := StrToFloat(ParseValues[ParsePos]);
end else if AnsiCompareText(CurrentToken, 'symmetry') = 0 then begin end else if AnsiCompareText(CurrentToken, 'color_speed') = 0 then begin
Inc(ParsePos); Inc(ParsePos);
xform[CurrentXForm].symmetry := StrToFloat(ParseValues[ParsePos]); xform[CurrentXForm].color_speed := StrToFloat(ParseValues[ParsePos]);
end else if AnsiCompareText(CurrentToken, 'coefs') = 0 then begin end else if AnsiCompareText(CurrentToken, 'coefs') = 0 then begin
Inc(ParsePos); Inc(ParsePos);
xform[CurrentXForm].c[0, 0] := StrToFloat(ParseValues[ParsePos]); xform[CurrentXForm].c[0, 0] := StrToFloat(ParseValues[ParsePos]);
@ -877,9 +888,9 @@ begin
Inc(i); Inc(i);
end; end;
end else if AnsiCompareText(CurrentToken, 'plotmode') = 0 then begin end else if AnsiCompareText(CurrentToken, 'opacity') = 0 then begin
Inc(ParsePos); Inc(ParsePos);
xform[CurrentXForm].noPlot := (StrToInt(ParseValues[ParsePos]) = 1); xform[CurrentXForm].opacity := StrToFloat(ParseValues[ParsePos]);
end else begin end else begin
OutputDebugString(Pchar('Unknown Token: ' + CurrentToken)); OutputDebugString(Pchar('Unknown Token: ' + CurrentToken));
end; end;
@ -903,13 +914,13 @@ begin
FillVarDisturb; FillVarDisturb;
VarPossible := false; VarPossible := false;
for j := 0 to NRVAR - 1 do begin for j := 0 to NRVAR - 1 do begin
VarPossible := VarPossible or Variations[j]; VarPossible := VarPossible or RandomVariations[j];
end; end;
if VarPossible then begin if VarPossible then begin
repeat repeat
rv := var_distrib[random(Length(var_distrib))]; rv := var_distrib[random(Length(var_distrib))];
until Variations[rv]; until RandomVariations[rv];
end else begin end else begin
rv := 0; rv := 0;
end; end;
@ -926,7 +937,7 @@ begin
if VarPossible 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 RandomVariations[v]; // Use only Variations set in options
end else begin end else begin
v := 0; v := 0;
end; end;
@ -959,23 +970,23 @@ begin
FillVarDisturb; FillVarDisturb;
VarPossible := false; VarPossible := false;
for j := 0 to NRVAR - 1 do begin for j := 0 to NRVAR - 1 do begin
VarPossible := VarPossible or Variations[j]; VarPossible := VarPossible or RandomVariations[j];
end; end;
if VarPossible then begin if VarPossible then begin
repeat repeat
rv := var_distrib[random(Length(var_distrib))]; rv := var_distrib[random(Length(var_distrib))];
until Variations[rv]; until RandomVariations[rv];
end else begin end else begin
rv := 0; rv := 0;
end; end;
for i := 0 to NXFORMS - 1 do begin for i := 0 to NXFORMS - 1 do begin
xform[i].density := 0; xform[i].weight := 0;
end; end;
for i := 0 to nrXforms - 1 do begin for i := 0 to nrXforms - 1 do begin
xform[i].density := 1.0 / nrXforms; xform[i].weight := 1.0 / nrXforms;
xform[i].color := i / (nrXforms - 1); xform[i].color := i / (nrXforms - 1);
xform[i].c[0][0] := 2 * random - 1; xform[i].c[0][0] := 2 * random - 1;
@ -997,7 +1008,7 @@ begin
if VarPossible 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 RandomVariations[v]; // use only variations set in options
end else begin end else begin
v := 0; v := 0;
end; end;
@ -1047,11 +1058,7 @@ begin
// RandSeed := 1234567; // RandSeed := 1234567;
try try
SetLength(Points, SUB_BATCH_SIZE); SetLength(Points, SUB_BATCH_SIZE);
{ case compatibility of
0: iterate_Old(SUB_BATCH_SIZE, points);
1: iterateXYC(SUB_BATCH_SIZE, points);
end;
}
cosa := cos(FAngle); cosa := cos(FAngle);
sina := sin(FAngle); sina := sin(FAngle);
@ -1462,7 +1469,7 @@ begin
end end
else begin else begin
cp1.xform[NXFORMS].Clear; cp1.xform[NXFORMS].Clear;
cp1.xform[NXFORMS].symmetry := 1; cp1.xform[NXFORMS].color_speed := 1;
end; end;
nXforms2 := cp2.NumXForms; nXforms2 := cp2.NumXForms;
@ -1476,13 +1483,13 @@ begin
end end
else begin else begin
cp2.xform[NXFORMS].Clear; cp2.xform[NXFORMS].Clear;
cp2.xform[NXFORMS].symmetry := 1; cp2.xform[NXFORMS].color_speed := 1;
end; end;
for i := 0 to NXFORMS do begin for i := 0 to NXFORMS do begin
Result.xform[i].density := c0 * cp1.xform[i].density + c1 * cp2.xform[i].density; Result.xform[i].weight := c0 * cp1.xform[i].weight + c1 * cp2.xform[i].weight;
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].color_speed := c0 * cp1.xform[i].color_speed + c1 * cp2.xform[i].color_speed;
// for j := 0 to NrVar - 1 do // for j := 0 to NrVar - 1 do
// 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];
for j := 0 to NrVar-1 do for j := 0 to NrVar-1 do
@ -1578,9 +1585,9 @@ begin
for i := 0 to Min(NumXForms+1, NXFORMS) do for i := 0 to Min(NumXForms+1, NXFORMS) do
with xform[i] do begin with xform[i] do begin
//if density = 0 then continue; - FinalXform has weight=0 //if weight = 0 then continue; - FinalXform has weight=0
sl.add(format('xform %d density %g color %g symmetry %g', [i, density, color, symmetry])); sl.add(format('xform %d weight %g color %g color_speed %g', [i, weight, color, color_speed]));
s := 'vars'; s := 'vars';
for j := 0 to NRVAR - 1 do begin for j := 0 to NRVAR - 1 do begin
s := format('%s %g', [s, vars[j]]); s := format('%s %g', [s, vars[j]]);
@ -1596,9 +1603,9 @@ begin
{$endif} {$endif}
end; end;
sl.add(s); sl.add(s);
sl.Add(format('coefs %.6f %.6f %.6f %.6f %.6f %.6f', sl.Add(format('coefs %g %g %g %g %g %g', // 'coefs %.6f %.6f %.6f %.6f %.6f %.6f',
[c[0][0], c[0][1], c[1][0], c[1][1], c[2][0], c[2][1]])); [c[0][0], c[0][1], c[1][0], c[1][1], c[2][0], c[2][1]]));
sl.Add(format('post %.6f %.6f %.6f %.6f %.6f %.6f', sl.Add(format('post %g %g %g %g %g %g', // 'post %.6f %.6f %.6f %.6f %.6f %.6f',
[p[0][0], p[0][1], p[1][0], p[1][1], p[2][0], p[2][1]])); [p[0][0], p[0][1], p[1][0], p[1][1], p[2][0], p[2][1]]));
if postXswap then if postXswap then
sl.Add('postxswap 1') sl.Add('postxswap 1')
@ -1611,7 +1618,7 @@ begin
end; end;
sl.Add(s); sl.Add(s);
sl.Add(Format('plotmode %d', [Ifthen(noPlot, 1, 0)])); sl.Add(Format('opacity %g', [opacity]));
end; end;
DecimalSeparator := OldDecimalSperator; DecimalSeparator := OldDecimalSperator;
@ -1709,7 +1716,7 @@ begin
begin begin
Result := (c[0,0]<>1) or (c[0,1]<>0) or (c[1,0]<>0) or (c[1,1]<>1) or (c[2,0]<>0) or (c[2,1]<>0) or Result := (c[0,0]<>1) or (c[0,1]<>0) or (c[1,0]<>0) or (c[1,1]<>1) or (c[2,0]<>0) or (c[2,1]<>0) or
(p[0,0]<>1) or (p[0,1]<>0) or (p[1,0]<>0) or (p[1,1]<>1) or (p[2,0]<>0) or (p[2,1]<>0) or (p[0,0]<>1) or (p[0,1]<>0) or (p[1,0]<>0) or (p[1,1]<>1) or (p[2,0]<>0) or (p[2,1]<>0) or
(symmetry <> 1) or (vars[0] <> 1); (color_speed <> 1) or (vars[0] <> 1);
if Result = false then if Result = false then
for i := 1 to NRVAR-1 do Result := Result or (vars[i] <> 0); for i := 1 to NRVAR-1 do Result := Result or (vars[i] <> 0);
end; end;
@ -1745,7 +1752,7 @@ begin
end; end;
for i := 0 to NXFORMS - 1 do for i := 0 to NXFORMS - 1 do
if (cp.xform[i].density = 0.0) then break; if (cp.xform[i].weight = 0.0) then break;
if (i = NXFORMS) then if (i = NXFORMS) then
begin begin
@ -1756,8 +1763,8 @@ begin
if (sym < 0) then if (sym < 0) then
begin begin
cp.xform[i].density := 1.0; cp.xform[i].weight := 1.0;
cp.xform[i].symmetry := 1; cp.xform[i].color_speed := 1;
cp.xform[i].vars[0] := 1.0; cp.xform[i].vars[0] := 1.0;
for j := 1 to NRVAR - 1 do for j := 1 to NRVAR - 1 do
cp.xform[i].vars[j] := 0; cp.xform[i].vars[j] := 0;
@ -1781,9 +1788,9 @@ begin
// while (k < sym) and (i < NXFORMS) do // while (k < sym) and (i < NXFORMS) do
while (k < sym) and (i < SymmetryNVars) do while (k < sym) and (i < SymmetryNVars) do
begin begin
cp.xform[i].density := 1.0; cp.xform[i].weight := 1.0;
cp.xform[i].vars[0] := 1.0; cp.xform[i].vars[0] := 1.0;
cp.xform[i].symmetry := 1; cp.xform[i].color_speed := 1;
for j := 1 to NRVAR - 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
@ -1994,7 +2001,7 @@ begin
Result := NXFORMS; Result := NXFORMS;
for i := 0 to NXFORMS - 1 do for i := 0 to NXFORMS - 1 do
begin begin
if xform[i].density = 0 then if xform[i].weight = 0 then
begin begin
Result := i; Result := i;
Break; Break;
@ -2095,7 +2102,7 @@ var
begin begin
t := NumXForms; t := NumXForms;
for i := 0 to t - 1 do for i := 0 to t - 1 do
xform[i].density := 0.5; xform[i].weight := 0.5;
end; end;
procedure TControlPoint.NormalizeWeights; procedure TControlPoint.NormalizeWeights;
@ -2105,12 +2112,12 @@ var
begin begin
td := 0.0; td := 0.0;
for i := 0 to NumXForms - 1 do for i := 0 to NumXForms - 1 do
td := td + xform[i].Density; td := td + xform[i].weight;
if (td < 0.001) then if (td < 0.001) then
EqualizeWeights EqualizeWeights
else else
for i := 0 to NumXForms - 1 do for i := 0 to NumXForms - 1 do
xform[i].Density := xform[i].Density / td; xform[i].weight := xform[i].weight / td;
end; end;
procedure TControlPoint.RandomizeWeights; procedure TControlPoint.RandomizeWeights;
@ -2118,7 +2125,7 @@ var
i: integer; i: integer;
begin begin
for i := 0 to Transforms - 1 do for i := 0 to Transforms - 1 do
xform[i].Density := Random; xform[i].weight := Random;
end; end;
procedure TControlPoint.ComputeWeights(Triangles: TTriangles; t: integer); procedure TControlPoint.ComputeWeights(Triangles: TTriangles; t: integer);
@ -2130,14 +2137,13 @@ begin
total_area := 0; total_area := 0;
for i := 0 to t - 1 do for i := 0 to t - 1 do
begin begin
xform[i].Density := triangle_area(Triangles[i]); xform[i].weight := triangle_area(Triangles[i]);
total_area := total_area + xform[i].Density; total_area := total_area + xform[i].weight;
end; end;
for i := 0 to t - 1 do for i := 0 to t - 1 do
begin begin
xform[i].Density := xform[i].Density / total_area; xform[i].weight := xform[i].weight / total_area;
end; end;
//? cp1.NormalizeWeights;
end; end;
procedure TControlPoint.GetFromTriangles(const Triangles: TTriangles; const t: integer); procedure TControlPoint.GetFromTriangles(const Triangles: TTriangles; const t: integer);

View File

@ -55,15 +55,17 @@ type
vars: array of double; // {normalized} interp coefs between variations vars: array 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
p: array[0..2, 0..1] of double; // post-transform coefs! p: array[0..2, 0..1] of double; // post-transform coefs!
density: double; // prob is this function is chosen weight: double; // prob is this function is chosen
color: double; // color coord for this function. 0 - 1 color: double; // color coord for this function. 0 - 1
color2: double; // Second color coord for this function. 0 - 1 color2: double; // Second color coord for this function. 0 - 1
symmetry: double; color_speed: double;
animate: double; // for flam3, use as 1/0 toggle in Apo?
c00, c01, c10, c11, c20, c21: double;// unnecessary duplicated variables c00, c01, c10, c11, c20, c21: double;// unnecessary duplicated variables
p00, p01, p10, p11, p20, p21: double;// :-) p00, p01, p10, p11, p20, p21: double;// :-)
postXswap: boolean; postXswap: boolean;
noPlot: boolean; opacity: double;
plotMode: integer; // (neverPlot = -1, opacityPlot = 0, alwaysPlot = 1);
// nx,ny,x,y: double; // nx,ny,x,y: double;
// script: TatPascalScripter; // script: TatPascalScripter;
@ -205,9 +207,9 @@ procedure TXForm.Clear;
var var
i: Integer; i: Integer;
begin begin
density := 0; weight := 0;
color := 0; color := 0;
symmetry := 0; color_speed := 0;
postXswap := false; postXswap := false;
c[0, 0] := 1; c[0, 0] := 1;
@ -231,7 +233,7 @@ begin
for i := 0 to NXFORMS do for i := 0 to NXFORMS do
modWeights[i] := 1; modWeights[i] := 1;
noPlot := false; opacity := 1;
end; end;
/////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////
@ -247,8 +249,8 @@ begin
c20 := c[2][0]; c20 := c[2][0];
c21 := c[2][1]; c21 := c[2][1];
colorC1 := (1 + symmetry)/2; colorC1 := (1 + color_speed)/2;
colorC2 := color*(1 - symmetry)/2; colorC2 := color*(1 - color_speed)/2;
FNrFunctions := 0; FNrFunctions := 0;
@ -2120,10 +2122,10 @@ begin
c := Xform.c; c := Xform.c;
p := Xform.p; p := Xform.p;
density := XForm.density; weight := XForm.weight;
color := XForm.color; color := XForm.color;
color2 := XForm.color2; color2 := XForm.color2;
symmetry := XForm.symmetry; color_speed := XForm.color_speed;
Orientationtype := XForm.Orientationtype; Orientationtype := XForm.Orientationtype;
postXswap := Xform.postXswap; postXswap := Xform.postXswap;
@ -2139,7 +2141,7 @@ begin
for i := 0 to High(modWeights) do for i := 0 to High(modWeights) do
modWeights[i] := xform.modWeights[i]; modWeights[i] := xform.modWeights[i];
noPlot := xform.noPlot; opacity := xform.opacity;
end; end;
/////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////
@ -2150,8 +2152,11 @@ var
Value: double; Value: double;
numChaos: integer; numChaos: integer;
begin begin
result := Format(' <xform weight="%g" color="%g" ', [density, color]); result := Format(' <xform weight="%g" color="%g" ', [weight, color]);
if symmetry <> 0 then result := result + format('symmetry="%g" ', [symmetry]); if color_speed <> 0 then
result := result + format('symmetry="%g" ', [color_speed]);
if opacity <> 1 then
Result := Result + Format('opacity="%g" ', [opacity]);
for i := 0 to nrvar - 1 do begin for i := 0 to nrvar - 1 do begin
if vars[i] <> 0 then if vars[i] <> 0 then
@ -2184,9 +2189,6 @@ begin
Result := Result + '" '; Result := Result + '" ';
end; end;
if noPlot = true then
Result := Result + 'plotmode="off" ';
Result := Result + '/>'; Result := Result + '/>';
end; end;
@ -2199,7 +2201,7 @@ begin
// result := Format(' <finalxform enabled="%d" color="%g" symmetry="%g" ', // result := Format(' <finalxform enabled="%d" color="%g" symmetry="%g" ',
// [ifthen(IsEnabled, 1, 0), color, symmetry]); // [ifthen(IsEnabled, 1, 0), color, symmetry]);
result := Format(' <finalxform color="%g" ', [color]); result := Format(' <finalxform color="%g" ', [color]);
if symmetry <> 0 then result := result + format('symmetry="%g" ', [symmetry]); if color_speed <> 0 then result := result + format('symmetry="%g" ', [color_speed]);
for i := 0 to nrvar - 1 do begin for i := 0 to nrvar - 1 do begin
if vars[i] <> 0 then if vars[i] <> 0 then
Result := Result + varnames(i) + format('="%g" ', [vars[i]]); Result := Result + varnames(i) + format('="%g" ', [vars[i]]);