many changes, mostly in editor and adjust

This commit is contained in:
zueuk 2005-10-19 18:51:05 +00:00
parent 4cb9c04f1e
commit 4576862b26
9 changed files with 644 additions and 724 deletions

View File

@ -677,6 +677,7 @@ object AdjustForm: TAdjustForm
Height = 45
Align = alTop
BevelOuter = bvLowered
Color = clAppWorkSpace
TabOrder = 0
object GradientImage: TImage
Left = 1

View File

@ -257,44 +257,42 @@ type
cp: TControlPoint;
// --Z-- // gradient stuff
private // --Z-- // gradient stuff
Palette: TColorMap;
BackupPal: TColorMap;
scrollMode: (modeRotate, modeHue, modeSaturation, modeBrightness, modeContrast,
modeBlur, modeFrequency);
scrollMode: (modeRotate,
modeHue, modeSaturation, modeBrightness, modeContrast,
modeBlur, modeFrequency);
imgDrag, GradientChanged: boolean;
dragX, oldX: integer;
offset: integer; // for display... :-\
offset: integer; // for display...? :-\
procedure Apply;
function Blur(const radius: integer; const pal: TColorMap): TColorMap;
function Frequency(const times: Integer; const pal: TColorMap): TColorMap;
procedure SaveMap(FileName: string);
// --Z-- // image size stuff
procedure UpdateGradient(Pal: TColorMap);
private // --Z-- // image size stuff
ImageHeight, ImageWidth: integer;
Preset: array[1..3] of record
Left, Top, Width, Height: integer;
end;
ratio: double;
// gradient stuff again
procedure Apply;
function Blur(const radius: integer; const pal: TColorMap): TColorMap;
function Frequency(const times: Integer; const pal: TColorMap): TColorMap;
procedure SaveMap(FileName: string);
// and image size stuff again
procedure ReadPreset(n: integer);
procedure WritePreset(n: integer);
function PresetToStr(n: integer): string;
procedure UpdateGradient(Pal: TColorMap);
// --
public
PreviewDensity: double;
// cmap: TColorMap;
// Sample_Density, Zoom: double;
// Center: array[0..1] of double;
procedure UpdateDisplay;
procedure UpdateDisplay(PreviewOnly: boolean = false);
procedure UpdateFlame;
end;
@ -317,14 +315,15 @@ uses
{$R *.DFM}
procedure TAdjustForm.UpdateDisplay;
procedure TAdjustForm.UpdateDisplay(PreviewOnly: boolean = false);
var
pw, ph: integer;
r: double;
begin
cp.copy(MainCp);
pw := PrevPnl.Width - 2;
ph := PrevPnl.Height - 2;
cp.copy(MainCp);
if (cp.width / cp.height) > (PrevPnl.Width / PrevPnl.Height) then
begin
PreviewImage.Width := pw;
@ -333,16 +332,19 @@ begin
PreviewImage.Left := 1;
PreviewImage.Top := (ph - PreviewImage.Height) div 2;
end
else
begin
else begin
PreviewImage.Height := ph;
r := cp.height / PreviewImage.height;
PreviewImage.Width := round(cp.Width / r);
PreviewImage.Top := 1;
PreviewImage.Left := (pw - PreviewImage.Width) div 2;
end;
cp.cmap := MainCp.cmap;
AdjustScale(cp, PreviewImage.Width, PreviewImage.Height);
cp.cmap := MainCp.cmap;
if not PreviewOnly then begin //***
// zoom := MainForm.zoom;
// cp.zoom := zoom;
Resetting := True; // So the preview doesn't get drawn with these changes..
@ -368,14 +370,14 @@ begin
// gradient
if cp.cmapindex >= 0 then
cmbPalette.ItemIndex := cp.cmapindex;
// ScrollBar.Position := 0;
ScrollBar.Position := 0;
Palette := cp.cmap;
BackupPal := cp.cmap;
Resetting := False;
DrawPreview;
//DrawPalette;
end; //***
DrawPreview;
end;
procedure TAdjustForm.UpdateFlame;
@ -398,49 +400,45 @@ var
Row: pRGBTripleArray;
BitMap: TBitMap;
begin
if not Resetting then begin
Render.Stop;
// AdjustScale(cp, PreviewImage.Width, PreviewImage.Height);
cp.sample_density := PreviewDensity;
cp.spatial_oversample := defOversample;
cp.spatial_filter_radius := defFilterRadius;
// cp.Zoom := Zoom;
// cp.center[0] := Center[0];
// cp.center[1] := Center[1];
Render.Compatibility := compatibility;
Render.SetCP(cp);
Render.Render;
BM.Assign(Render.GetImage);
PreviewImage.Picture.Graphic := bm;
if Resetting then exit;
if mnuInstantPreview.Checked then
PreviewImage.Refresh;
Render.Stop;
// AdjustScale(cp, PreviewImage.Width, PreviewImage.Height);
cp.sample_density := PreviewDensity;
cp.spatial_oversample := defOversample;
cp.spatial_filter_radius := defFilterRadius;
// cp.Zoom := Zoom;
// cp.center[0] := Center[0];
// cp.center[1] := Center[1];
Render.Compatibility := compatibility;
Render.SetCP(cp);
Render.Render;
BM.Assign(Render.GetImage);
PreviewImage.Picture.Graphic := bm;
if mnuInstantPreview.Checked then PreviewImage.Refresh;
//--begin DrawPalette
BitMap := TBitMap.Create;
try
Bitmap.PixelFormat := pf24bit;
BitMap.Width := 256;
BitMap.Height := 1;
Row := Bitmap.Scanline[0];
for i := 0 to 255 do
BitMap := TBitMap.Create;
try
Bitmap.PixelFormat := pf24bit;
BitMap.Width := 256;
BitMap.Height := 1;
Row := Bitmap.Scanline[0];
for i := 0 to 255 do
with Row[i] do
begin
with Row[i] do
begin
rgbtRed := Palette[i][0];
rgbtGreen := Palette[i][1];
rgbtBlue := Palette[i][2];
end;
rgbtRed := Palette[i][0];
rgbtGreen := Palette[i][1];
rgbtBlue := Palette[i][2];
end;
GradientImage.Picture.Graphic := Bitmap;
GradientImage.Refresh;
finally
BitMap.Free;
end;
//--end DrawPalette
GradientImage.Picture.Graphic := Bitmap;
GradientImage.Refresh;
finally
BitMap.Free;
end;
//--end DrawPalette
end;
procedure TAdjustForm.FormCreate(Sender: TObject);
@ -494,23 +492,6 @@ begin
Render.free;
end;
{
procedure TAdjustForm.btnOKClick(Sender: TObject);
begin
ModalResult := mrOK;
end;
procedure TAdjustForm.btnCancelClick(Sender: TObject);
begin
ModalResult := mrCancel;
end;
procedure TAdjustForm.btnCanelClick(Sender: TObject);
begin
ModalResult := mrCancel;
end;
}
procedure TAdjustForm.FormShow(Sender: TObject);
var
Registry: TRegistry;
@ -535,7 +516,6 @@ begin
if Registry.OpenKey('Software\' + APP_NAME + '\ImageSizePresets', False) then
begin
// --Zueuk-- // image size presets
for i:=1 to 3 do begin
strx:='Preset'+IntToStr(i)+'Left';
stry:='Preset'+IntToStr(i)+'Top';
@ -1044,8 +1024,7 @@ begin
if EditForm.visible then EditForm.UpdateDisplay;
if MutateForm.Visible then MutateForm.UpdateDisplay;
if mnuInstantPreview.Checked then
DrawPreview; //hmm
if mnuInstantPreview.Checked then DrawPreview;
MainForm.RedrawTimer.enabled := true;
end;
@ -1086,10 +1065,10 @@ begin
BackupPal := Pal;
// DrawPalette;
cp.copy(MainCp);
cp.cmap := pal;
// cp.copy(MainCp);
if mnuInstantPreview.Checked then
DrawPreview; //hmm
if mnuInstantPreview.Checked then DrawPreview;
end;
procedure HSVToRGB(H, S, V: real; var Rb, Gb, Bb: integer);
@ -1333,100 +1312,82 @@ var
intens, i, r, g, b: integer;
h, s, v: real;
begin
GradientChanged:=true; // hmm
lblVal.Caption := IntToStr(ScrollBar.Position);
lblVal.Refresh;
{
wtf???? this is ridiculous!
=>> if btnMenu.Caption = 'Hue' then <<= (and 6 more like this follows...)
}
case scrollMode of
modeHue:
begin
for i := 0 to 255 do
begin
RGBToHSV(BackupPal[i][0], BackupPal[i][1], BackupPal[i][2], h, s, v);
if s <> 0 then // --Z-- //(?)
if Resetting then exit;
GradientChanged:=true; // hmm
case scrollMode of
modeHue:
for i := 0 to 255 do
begin
h := Round(360 + h + ScrollBar.Position) mod 360;
HSVToRGB(h, s, v, Palette[i][0], Palette[i][1], Palette[i][2]);
RGBToHSV(BackupPal[i][0], BackupPal[i][1], BackupPal[i][2], h, s, v);
if s <> 0 then // --Z-- //(?)
begin
h := Round(360 + h + ScrollBar.Position) mod 360;
HSVToRGB(h, s, v, Palette[i][0], Palette[i][1], Palette[i][2]);
end;
end;
modeSaturation:
for i := 0 to 255 do
begin
RGBToHSV(BackupPal[i][0], BackupPal[i][1], BackupPal[i][2], h, s, v);
if s <> 0 then // --Z-- //(?)
begin
s := s + ScrollBar.Position;
if s > 100 then s := 100;
if s < 0 then s := 0;
HSVToRGB(h, s, v, Palette[i][0], Palette[i][1], Palette[i][2]);
end;
end;
modeContrast:
begin
intens := scrollBar.Position;
if intens > 0 then intens := intens * 2;
for i := 0 to 255 do
begin
r := BackupPal[i][0];
g := BackupPal[i][1];
b := BackupPal[i][2];
r := round(r + intens / 100 * (r - 127));
g := round(g + intens / 100 * (g - 127));
b := round(b + intens / 100 * (b - 127));
if R > 255 then R := 255 else if R < 0 then R := 0;
if G > 255 then G := 255 else if G < 0 then G := 0;
if B > 255 then B := 255 else if B < 0 then B := 0;
Palette[i][0] := r;
Palette[i][1] := g;
Palette[i][2] := b;
end;
end;
modeBrightness:
for i := 0 to 255 do
begin
Palette[i][0] := BackupPal[i][0] + ScrollBar.Position;
if Palette[i][0] > 255 then Palette[i][0] := 255;
if Palette[i][0] < 0 then Palette[i][0] := 0;
Palette[i][1] := BackupPal[i][1] + ScrollBar.Position;
if Palette[i][1] > 255 then Palette[i][1] := 255;
if Palette[i][1] < 0 then Palette[i][1] := 0;
Palette[i][2] := BackupPal[i][2] + ScrollBar.Position;
if Palette[i][2] > 255 then Palette[i][2] := 255;
if Palette[i][2] < 0 then Palette[i][2] := 0;
end;
modeRotate:
for i := 0 to 255 do
begin
Palette[i][0] := BackupPal[(255 + i - ScrollBar.Position) mod 256][0];
Palette[i][1] := BackupPal[(255 + i - ScrollBar.Position) mod 256][1];
Palette[i][2] := BackupPal[(255 + i - ScrollBar.Position) mod 256][2];
end;
modeBlur:
Palette := Blur(ScrollBar.Position, BackupPal);
modeFrequency:
Palette := Frequency(ScrollBar.Position, BackupPal);
end;
modeSaturation:
begin
for i := 0 to 255 do
begin
RGBToHSV(BackupPal[i][0], BackupPal[i][1], BackupPal[i][2], h, s, v);
// if s <> 0 then // --Z-- //(?)
// begin
s := s + ScrollBar.Position;
if s > 100 then s := 100;
if s < 0 then s := 0;
HSVToRGB(h, s, v, Palette[i][0], Palette[i][1], Palette[i][2]);
// end;
end;
end;
modeContrast:
begin
intens := scrollBar.Position;
if intens > 0 then intens := intens * 2;
for i := 0 to 255 do
begin
r := BackupPal[i][0];
g := BackupPal[i][1];
b := BackupPal[i][2];
r := round(r + intens / 100 * (r - 127));
g := round(g + intens / 100 * (g - 127));
b := round(b + intens / 100 * (b - 127));
if R > 255 then R := 255 else if R < 0 then R := 0;
if G > 255 then G := 255 else if G < 0 then G := 0;
if B > 255 then B := 255 else if B < 0 then B := 0;
Palette[i][0] := r;
Palette[i][1] := g;
Palette[i][2] := b;
end;
end;
// if btnMenu.Caption = 'Brightness' then
modeBrightness:
begin
for i := 0 to 255 do
begin
Palette[i][0] := BackupPal[i][0] + ScrollBar.Position;
if Palette[i][0] > 255 then Palette[i][0] := 255;
if Palette[i][0] < 0 then Palette[i][0] := 0;
Palette[i][1] := BackupPal[i][1] + ScrollBar.Position;
if Palette[i][1] > 255 then Palette[i][1] := 255;
if Palette[i][1] < 0 then Palette[i][1] := 0;
Palette[i][2] := BackupPal[i][2] + ScrollBar.Position;
if Palette[i][2] > 255 then Palette[i][2] := 255;
if Palette[i][2] < 0 then Palette[i][2] := 0;
end;
end;
modeRotate:
begin
for i := 0 to 255 do
begin
Palette[i][0] := BackupPal[(255 + i - ScrollBar.Position) mod 256][0];
Palette[i][1] := BackupPal[(255 + i - ScrollBar.Position) mod 256][1];
Palette[i][2] := BackupPal[(255 + i - ScrollBar.Position) mod 256][2];
end;
end;
// if scrollMode = modeBlur then
// if btnMenu.Caption = 'Blur' then
modeBlur:
begin
Palette := Blur(ScrollBar.Position, BackupPal);
end;
// if scrollMode = modeFrequency then
modeFrequency:
begin
Palette := Frequency(ScrollBar.Position, BackupPal);
end;
end;
// DrawPalette;
cp.cmap:=Palette;
DrawPreview;
end;

View File

@ -1930,6 +1930,7 @@ begin
end;
end;
// I don't like this... :-/
for j := -1 to Result-1 do
for i := 0 to 2 do
triangles[j].y[i] := -triangles[j].y[i];
@ -1993,14 +1994,14 @@ begin
for i := 0 to t-1 do
begin
solve3(Triangles[-1].x[0], -Triangles[-1].y[0], Triangles[i].x[0],
Triangles[-1].x[1], -Triangles[-1].y[1], Triangles[i].x[1],
Triangles[-1].x[2], -Triangles[-1].y[2], Triangles[i].x[2],
xform[i].c[0][0], xform[i].c[1][0], xform[i].c[2][0]);
Triangles[-1].x[1], -Triangles[-1].y[1], Triangles[i].x[1],
Triangles[-1].x[2], -Triangles[-1].y[2], Triangles[i].x[2],
xform[i].c[0][0], xform[i].c[1][0], xform[i].c[2][0]);
solve3(Triangles[-1].x[0], -Triangles[-1].y[0], -Triangles[i].y[0],
Triangles[-1].x[1], -Triangles[-1].y[1], -Triangles[i].y[1],
Triangles[-1].x[2], -Triangles[-1].y[2], -Triangles[i].y[2],
xform[i].c[0][1], xform[i].c[1][1], xform[i].c[2][1]);
Triangles[-1].x[1], -Triangles[-1].y[1], -Triangles[i].y[1],
Triangles[-1].x[2], -Triangles[-1].y[2], -Triangles[i].y[2],
xform[i].c[0][1], xform[i].c[1][1], xform[i].c[2][1]);
end;
end;

View File

@ -1,8 +1,8 @@
object EditForm: TEditForm
Left = 350
Top = 163
Left = 279
Top = 240
Width = 586
Height = 586
Height = 576
Caption = 'Transform Editor'
Color = clBtnFace
Constraints.MinHeight = 400
@ -54,7 +54,7 @@ object EditForm: TEditForm
TextHeight = 13
object StatusBar: TStatusBar
Left = 0
Top = 544
Top = 533
Width = 578
Height = 15
Panels = <
@ -265,92 +265,19 @@ object EditForm: TEditForm
ShowHint = True
end
end
object PreviewToolBar: TToolBar
Left = 443
Top = 1
Width = 134
Height = 22
Align = alRight
Caption = 'PreviewToolBar'
EdgeBorders = []
Flat = True
Images = MainForm.Buttons
TabOrder = 1
Visible = False
object tbFullView: TToolButton
Left = 0
Top = 0
Caption = 'tbFullView'
ImageIndex = 52
OnClick = tbFullViewClick
end
object ToolButton7: TToolButton
Left = 23
Top = 0
Width = 8
Caption = 'ToolButton7'
ImageIndex = 3
Style = tbsSeparator
end
object tbLowQ: TToolButton
Left = 31
Top = 0
Caption = 'tbLowQ'
Grouped = True
ImageIndex = 45
Style = tbsCheck
OnClick = mnuLowQualityClick
end
object tbMedQ: TToolButton
Left = 54
Top = 0
Caption = 'tbMedQ'
Down = True
Grouped = True
ImageIndex = 45
Style = tbsCheck
OnClick = mnuMediumQualityClick
end
object tbHiQ: TToolButton
Left = 77
Top = 0
Caption = 'tbHiQ'
Grouped = True
ImageIndex = 45
Style = tbsCheck
OnClick = mnuHighQualityClick
end
object ToolButton9: TToolButton
Left = 100
Top = 0
Width = 8
Caption = 'ToolButton9'
ImageIndex = 14
Style = tbsSeparator
end
object tbResetLoc: TToolButton
Left = 108
Top = 0
Hint = 'Reset location on/off'
Caption = 'tbResetLoc'
Down = True
ImageIndex = 12
OnClick = mnuResetLocClick
end
end
end
object EditPnl: TPanel
Left = 0
Top = 24
Width = 578
Height = 520
Height = 509
Align = alClient
TabOrder = 1
object Splitter1: TSplitter
Left = 396
Top = 1
Width = 9
Height = 518
Height = 507
Align = alRight
AutoSnap = False
Beveled = True
@ -361,7 +288,7 @@ object EditForm: TEditForm
Left = 1
Top = 1
Width = 395
Height = 518
Height = 507
Align = alClient
BevelOuter = bvNone
Color = clAppWorkSpace
@ -371,14 +298,14 @@ object EditForm: TEditForm
Left = 405
Top = 1
Width = 172
Height = 518
Height = 507
Align = alRight
Alignment = taLeftJustify
BevelOuter = bvNone
TabOrder = 1
object Splitter2: TSplitter
Left = 0
Top = 128
Top = 130
Width = 172
Height = 8
Cursor = crVSplit
@ -392,7 +319,7 @@ object EditForm: TEditForm
Left = 0
Top = 0
Width = 172
Height = 128
Height = 130
Align = alTop
BevelOuter = bvLowered
Color = clAppWorkSpace
@ -401,17 +328,16 @@ object EditForm: TEditForm
Left = 1
Top = 1
Width = 170
Height = 126
Height = 130
IncrementalDisplay = True
PopupMenu = QualityPopup
OnDblClick = PreviewImageDblClick
end
end
object ControlPanel: TPanel
Left = 0
Top = 136
Top = 138
Width = 172
Height = 382
Height = 369
Align = alClient
TabOrder = 0
object lblTransform: TLabel
@ -442,10 +368,10 @@ object EditForm: TEditForm
end
object PageControl: TPageControl
Left = 1
Top = 27
Top = 24
Width = 170
Height = 354
ActivePage = tabXForm
Height = 344
ActivePage = TriangleTab
Align = alBottom
Anchors = [akLeft, akTop, akRight, akBottom]
MultiLine = True
@ -457,7 +383,7 @@ object EditForm: TEditForm
Left = 0
Top = 0
Width = 162
Height = 308
Height = 298
HorzScrollBar.Visible = False
VertScrollBar.Smooth = True
VertScrollBar.Style = ssFlat
@ -470,8 +396,8 @@ object EditForm: TEditForm
object TrianglePanel: TPanel
Left = 0
Top = 0
Width = 158
Height = 305
Width = 162
Height = 277
BevelOuter = bvNone
TabOrder = 0
object Label9: TLabel
@ -497,7 +423,7 @@ object EditForm: TEditForm
end
object btTrgRotateRight: TSpeedButton
Left = 106
Top = 102
Top = 78
Width = 23
Height = 24
Hint = 'Rotate triangle clockwise'
@ -517,7 +443,7 @@ object EditForm: TEditForm
end
object btTrgRotateLeft: TSpeedButton
Left = 32
Top = 102
Top = 78
Width = 23
Height = 24
Hint = 'Rotate triangle counter clockwise'
@ -555,7 +481,7 @@ object EditForm: TEditForm
end
object btTrgMoveUp: TSpeedButton
Left = 68
Top = 129
Top = 105
Width = 25
Height = 25
Hint = 'Move triangle up'
@ -593,7 +519,7 @@ object EditForm: TEditForm
end
object btTrgMoveRight: TSpeedButton
Left = 106
Top = 154
Top = 130
Width = 25
Height = 25
Hint = 'Move triangle right'
@ -631,7 +557,7 @@ object EditForm: TEditForm
end
object btTrgMoveLeft: TSpeedButton
Left = 30
Top = 154
Top = 130
Width = 25
Height = 25
Hint = 'Move triangle left'
@ -669,7 +595,7 @@ object EditForm: TEditForm
end
object btTrgMoveDown: TSpeedButton
Left = 68
Top = 179
Top = 155
Width = 25
Height = 25
Hint = 'Move triangle down'
@ -707,7 +633,7 @@ object EditForm: TEditForm
end
object btTrgScaleUp: TSpeedButton
Left = 106
Top = 206
Top = 182
Width = 23
Height = 24
Hint = 'Scale triangle up'
@ -727,7 +653,7 @@ object EditForm: TEditForm
end
object btTrgScaleDown: TSpeedButton
Left = 32
Top = 206
Top = 182
Width = 23
Height = 24
Hint = 'Scale triangle down'
@ -746,8 +672,8 @@ object EditForm: TEditForm
OnClick = btTrgScaleDownClick
end
object btTrgRotateRight90: TSpeedButton
Left = 132
Top = 102
Left = 130
Top = 78
Width = 23
Height = 24
Hint = 'Rotate triangle clockwise 90'#176
@ -800,8 +726,8 @@ object EditForm: TEditForm
OnClick = btTrgRotateRight90Click
end
object btTrgRotateLeft90: TSpeedButton
Left = 6
Top = 102
Left = 8
Top = 78
Width = 23
Height = 24
Hint = 'Rotate triangle counter clockwise 90'#176
@ -855,7 +781,7 @@ object EditForm: TEditForm
end
object btTrgMoveLU: TSpeedButton
Left = 42
Top = 129
Top = 105
Width = 25
Height = 25
Hint = 'Move triangle left-up'
@ -893,7 +819,7 @@ object EditForm: TEditForm
end
object btTrgMoveLD: TSpeedButton
Left = 42
Top = 179
Top = 155
Width = 25
Height = 25
Hint = 'Move triangle left-down'
@ -931,7 +857,7 @@ object EditForm: TEditForm
end
object btTrgMoveRU: TSpeedButton
Left = 94
Top = 129
Top = 105
Width = 25
Height = 25
Hint = 'Move triangle right-up'
@ -969,7 +895,7 @@ object EditForm: TEditForm
end
object btTrgMoveRD: TSpeedButton
Left = 94
Top = 179
Top = 155
Width = 25
Height = 25
Hint = 'Move triangle right-down'
@ -1008,7 +934,7 @@ object EditForm: TEditForm
object txtCy: TEdit
Left = 88
Top = 52
Width = 66
Width = 65
Height = 21
AutoSelect = False
TabOrder = 5
@ -1071,19 +997,9 @@ object EditForm: TEditForm
OnExit = CornerEditExit
OnKeyPress = CornerEditKeyPress
end
object chkPreserve: TCheckBox
Left = 32
Top = 80
Width = 105
Height = 17
Caption = 'Preserve weights'
Checked = True
State = cbChecked
TabOrder = 6
end
object rgPivot: TRadioGroup
Left = 16
Top = 240
Top = 210
Width = 129
Height = 65
BiDiMode = bdLeftToRight
@ -1096,21 +1012,21 @@ object EditForm: TEditForm
'B'
'C'
'Center'
'(0;0)')
'( 0; 0 )')
ParentBiDiMode = False
ParentCtl3D = False
TabOrder = 7
TabOrder = 6
OnClick = rgPivotClicked
end
object txtTrgMoveValue: TComboBox
Left = 56
Top = 156
Top = 132
Width = 49
Height = 21
AutoComplete = False
ItemHeight = 13
ItemIndex = 3
TabOrder = 9
TabOrder = 8
Text = '0.1'
OnExit = txtValidateValue
OnKeyPress = txtValKeyPress
@ -1125,13 +1041,12 @@ object EditForm: TEditForm
end
object txtTrgRotateValue: TComboBox
Left = 56
Top = 104
Top = 80
Width = 49
Height = 21
AutoComplete = False
ItemHeight = 13
ItemIndex = 1
TabOrder = 8
TabOrder = 7
Text = '15'
OnExit = txtValidateValue
OnKeyPress = txtValKeyPress
@ -1140,23 +1055,24 @@ object EditForm: TEditForm
'15'
'30'
'45'
'60'
'90'
'120'
'180')
end
object txtTrgScaleValue: TComboBox
Left = 56
Top = 208
Top = 184
Width = 49
Height = 21
AutoComplete = False
ItemHeight = 13
ItemIndex = 1
TabOrder = 10
Text = '110'
TabOrder = 9
Text = '125'
OnExit = txtValidateValue
OnKeyPress = txtValKeyPress
Items.Strings = (
'105'
'110'
'125'
'150'
@ -1164,74 +1080,107 @@ object EditForm: TEditForm
'200')
end
end
object chkPreserve: TCheckBox
Left = 30
Top = 280
Width = 105
Height = 17
Caption = 'Preserve weights'
Checked = True
State = cbChecked
TabOrder = 1
end
end
end
object tabXForm: TTabSheet
Caption = 'Transform'
object lbla: TLabel
Left = 4
Top = 8
Width = 10
Height = 13
Caption = 'a:'
end
object Label1: TLabel
Left = 82
Top = 8
Width = 10
Height = 13
Caption = 'b:'
end
object Label2: TLabel
Left = 4
Top = 32
Width = 9
Height = 13
Caption = 'c:'
end
object Label3: TLabel
Left = 82
Top = 32
Width = 10
Height = 13
Caption = 'd:'
end
object Label4: TLabel
Left = 4
Top = 56
Width = 10
Height = 13
Caption = 'e:'
end
object Label5: TLabel
Left = 82
Top = 56
Width = 8
Height = 13
Caption = 'f:'
end
object Label6: TLabel
Left = 36
Top = 84
Top = 100
Width = 38
Height = 13
Caption = 'Weight:'
end
object Label29: TLabel
Left = 36
Top = 108
Top = 124
Width = 52
Height = 13
Caption = 'Symmetry:'
end
object btnResetCoefs: TSpeedButton
Left = 8
Top = 148
Width = 145
Height = 22
Hint = 'Reset all vectors to default'
Caption = 'Reset Coefs'
ParentShowHint = False
ShowHint = False
OnClick = mnuResetClick
end
object btnXcoefs: TSpeedButton
Left = 8
Top = 4
Width = 25
Height = 21
Hint = 'Reset point A'
Caption = 'A'
ParentShowHint = False
ShowHint = False
OnClick = btnXcoefsClick
end
object btnYcoefs: TSpeedButton
Left = 8
Top = 28
Width = 25
Height = 21
Hint = 'Reset point C'
Caption = 'C'
ParentShowHint = False
ShowHint = False
OnClick = btnYcoefsClick
end
object btnOcoefs: TSpeedButton
Left = 8
Top = 52
Width = 25
Height = 21
Hint = 'Reset point B'
Caption = 'B'
ParentShowHint = False
ShowHint = False
OnClick = btnOcoefsClick
end
object btnCoefsRect: TSpeedButton
Left = 8
Top = 76
Width = 71
Height = 17
GroupIndex = 1
Down = True
Caption = 'Rectangular'
Flat = True
OnClick = btnCoefsModeClick
end
object btnCoefsPolar: TSpeedButton
Left = 82
Top = 76
Width = 71
Height = 17
GroupIndex = 1
Caption = 'Polar (deg)'
Flat = True
OnClick = btnCoefsModeClick
end
object txtA: TEdit
Left = 20
Left = 36
Top = 4
Width = 57
Height = 21
TabOrder = 0
Text = '0'
OnExit = CoefExit
OnExit = CoefValidate
OnKeyPress = CoefKeyPress
end
object txtB: TEdit
@ -1241,17 +1190,17 @@ object EditForm: TEditForm
Height = 21
TabOrder = 1
Text = '0'
OnExit = CoefExit
OnExit = CoefValidate
OnKeyPress = CoefKeyPress
end
object txtC: TEdit
Left = 20
Left = 36
Top = 28
Width = 57
Height = 21
TabOrder = 2
Text = '0'
OnExit = CoefExit
OnExit = CoefValidate
OnKeyPress = CoefKeyPress
end
object txtD: TEdit
@ -1261,17 +1210,17 @@ object EditForm: TEditForm
Height = 21
TabOrder = 3
Text = '0'
OnExit = CoefExit
OnExit = CoefValidate
OnKeyPress = CoefKeyPress
end
object txtE: TEdit
Left = 20
Left = 36
Top = 52
Width = 57
Height = 21
TabOrder = 4
Text = '0'
OnExit = CoefExit
OnExit = CoefValidate
OnKeyPress = CoefKeyPress
end
object txtF: TEdit
@ -1281,12 +1230,12 @@ object EditForm: TEditForm
Height = 21
TabOrder = 5
Text = '0'
OnExit = CoefExit
OnExit = CoefValidate
OnKeyPress = CoefKeyPress
end
object txtP: TEdit
Left = 96
Top = 80
Top = 96
Width = 57
Height = 21
TabOrder = 6
@ -1296,7 +1245,7 @@ object EditForm: TEditForm
end
object txtSymmetry: TEdit
Left = 96
Top = 104
Top = 120
Width = 57
Height = 21
TabOrder = 7
@ -1311,7 +1260,7 @@ object EditForm: TEditForm
Left = 0
Top = 0
Width = 162
Height = 308
Height = 298
Align = alClient
ScrollBars = ssVertical
TabOrder = 0
@ -1337,7 +1286,7 @@ object EditForm: TEditForm
Left = 0
Top = 0
Width = 162
Height = 308
Height = 298
Align = alClient
ScrollBars = ssVertical
TabOrder = 0
@ -1543,20 +1492,6 @@ object EditForm: TEditForm
ImageIndex = 1
OnClick = mnuAddClick
end
object MenuItem2: TMenuItem
Caption = '-'
end
object mnuReset: TMenuItem
Caption = 'Reset Triangle'
Hint = 'Reset triangle to reference position'
OnClick = mnuResetClick
end
object mnuResetAll: TMenuItem
Caption = 'Reset All'
Hint = 'Reset all triangles to reference position'
ImageIndex = 0
OnClick = mnuResetAllClick
end
object N4: TMenuItem
Caption = '-'
end
@ -1640,7 +1575,7 @@ object EditForm: TEditForm
Left = 353
Top = 80
Bitmap = {
494C01010E001300040010001000FFFFFFFFFF10FFFFFFFFFFFFFFFF424D3600
494C01010E001300040010001000FFFFFFFFFF00FFFFFFFFFFFFFFFF424D3600
0000000000003600000028000000400000005000000001002000000000000050
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
@ -1916,7 +1851,7 @@ object EditForm: TEditForm
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
000000000000000000005C5C5C00000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
00000000000000000000000000000000000000000000000000005C5C5C000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000008000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
@ -1924,8 +1859,8 @@ object EditForm: TEditForm
5C00000000000000000000000000000000000000000000000000000000005C5C
5C00000000000000000000000000000000000000000000000000000000000000
00000000000000000000000000005C5C5C000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
00005C5C5C000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000005C5C
5C00000000005C5C5C0000000000000000000000000000000000000000000000
0000000000000000000000000000000000008000000080000000000000000000
0000000000000000000000000000800080000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
@ -1933,7 +1868,7 @@ object EditForm: TEditForm
0000000000000000000000000000000000000000000000000000000000000000
0000600000006000000000000000000000005C5C5C0000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000005C5C5C0000000000000000000000000000000000000000000000
00005C5C5C00000000005C5C5C00000000000000000000000000000000000000
0000000000000000000000000000000000008000000080606000800000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000005C5C5C0000000000000000000000000000000000000000000000
@ -1941,7 +1876,7 @@ object EditForm: TEditForm
0000000000000000000000000000000000000000000000000000000000006000
000000000000000000000000000000000000000000005C5C5C00000000000000
0000000000000000000000000000000000000000000000000000000000000000
000000000000000000005C5C5C00000000000000000000000000000000000000
0000000000005C5C5C00000000005C5C5C000000000000000000000000000000
0000000000000000000000000000000000008000000000000000806060008000
0000000000000000000000000000800080000000000000000000000000000000
00005C5C5C000000000000000000000000000000000000000000000000000000
@ -1949,7 +1884,7 @@ object EditForm: TEditForm
0000000000000000000000000000000000000000000000000000000000006000
00000000000000000000000000000000000000000000000000005C5C5C000000
0000000000000000000000000000000000000000000000000000000000000000
00000000000000000000000000005C5C5C000000000000000000000000000000
000000000000000000005C5C5C00000000005C5C5C0000000000000000000000
0000000000000000000000000000000000008000000000000000000000008060
6000800000000000000000000000000000000000000000000000000000005C5C
5C00000000000000000000000000000000000000000000000000000000000000
@ -1957,7 +1892,7 @@ object EditForm: TEditForm
0000000000000000000000000000000000000000000000000000600000000000
0000000000000000000000000000000000000000000000000000000000005C5C
5C00000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000005C5C5C0000000000000000000000
00000000000000000000000000005C5C5C00000000005C5C5C00000000000000
0000000000000000000000000000000000008000000000000000000000000000
00008060600080000000000000008000800000000000000000005C5C5C000000
0000000000000000000000000000000000000000000000000000000000000000
@ -1965,7 +1900,7 @@ object EditForm: TEditForm
0000000000000000000000000000000000000000000000000000600000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
000000000000000000000000000000000000000000005C5C5C00000000000000
0000000000000000000000000000000000005C5C5C00000000005C5C5C000000
0000000000000000000000000000000000008000000000000000000000000000
000000000000806060008000000000000000000000005C5C5C00000000000000
0000000000000000000000000000000000008000800000000000800080000000
@ -1973,24 +1908,24 @@ object EditForm: TEditForm
0000800080000000000080008000000000000000000000000000600000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
00000000000000000000000000000000000000000000000000005C5C5C000000
0000000000000000000000000000000000008000000000000000000000000000
000000000000000000000000000000000000000000005C5C5C00000000005C5C
5C00000000000000000000000000000000008000000000000000000000000000
00008060600080000000000000008000800000000000000000005C5C5C000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000800000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000600000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000005C5C
5C00000000000000000000000000000000008000000000000000000000008060
00000000000000000000000000000000000000000000000000005C5C5C000000
00005C5C5C000000000000000000000000008000000000000000000000008060
6000800000000000000000000000000000000000000000000000000000005C5C
5C00000000000000000000000000000000000000000000000000000000000000
0000000000000000000080000000806060008000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000006000
0000000000000000000000000000000000000000000000000000600000006000
0000600000006000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
00005C5C5C000000000000000000000000008000000000000000806060008000
0000000000000000000000000000000000000000000000000000000000005C5C
5C00000000000000000000000000000000008000000000000000806060008000
0000000000000000000000000000800080000000000000000000000000000000
00005C5C5C000000000000000000000000000000000000000000000000000000
0000000000008000000080606000000000008060600080000000000000000000
@ -1998,7 +1933,7 @@ object EditForm: TEditForm
0000000000000000000000000000000000000000000000000000000000000000
0000600000006000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000008000000080606000800000000000
00005C5C5C000000000000000000000000008000000080606000800000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000005C5C5C0000000000000000000000000000000000000000000000
0000800000008060600000000000000000000000000080606000800000000000
@ -2006,7 +1941,7 @@ object EditForm: TEditForm
0000600000006000000000000000000000000000000000000000600000006000
0000000000006000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000008000000080000000000000000000
0000000000005C5C5C0000000000000000008000000080000000000000000000
0000000000000000000000000000800080000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000008000
0000806060000000000000000000000000000000000000000000806060008000
@ -2293,9 +2228,9 @@ object EditForm: TEditForm
FF73F3E700000000FF73F3E700000000FB73000000000000F363F3E700000000
E007F3E700000000E00FF1C700000000F37FF80F00000000FB7FFC1F00000000
FF7FFFFF00000000FF7FFFFF00000000FFFFFFFFFFFFFFFFF0070001FEFF8003
F9F780017FFDCFE7FCF7C7F93EF9E7CFF277E3F91FF1F39FEF37F1F94EE5F93F
EF97F8F967CDFC7FDFC7FC79729DFEFFDFE7FE39793D5555DFF7FF19729DFEFF
DFFFFF8967CDFC7FEFC3FFC14EE5F93FEFF3FFE11FF1F39FF3CBFFF13EF9E7CF
F9F79FFD7FFDCFE7FCF7C8053EF9E7CFF277E4F51FF1F39FEF37F2754EE5F93F
EF97F93567CDFC7FDFC7FC95729DFEFFDFE7FE45793D5555DFF7FF25729DFEFF
DFFFFF9567CDFC7FEFC3FFCD4EE5F93FEFF3FFE51FF1F39FF3CBFFF13EF9E7CF
FC3BFFF97FFDCFE7FFFFFFFDFEFF8003FFFFFFFFFFCFFFFFFFFFFFFFFF87FEFF
FFFFFFFFF787FC7FFFFFFFFFF30FF83FFFF7EFFFF00FFEFFC1F7EF83F01FFEFF
C3FBDFC3F003DEF7C7FBDFE3F0079EF3CBFBDFD3F00F0001DCF7EF3BF01F9EF3
@ -2304,7 +2239,6 @@ object EditForm: TEditForm
C003E001E001E001C003F1F9F1F9F1F9C003F8F90009D8D9C003FC7980098C09
C003F239C609C619C003F319E309E219C003F389F189F009C003F3C1F8C1F8C1
C0030021FC41F061C0070031FE01E231C00FF3F9FF09C719C01FF3FDFF8D8F8D
C03FF3FFFFCFDFDFFFFFF3FFFFEFFFFF00000000000000000000000000000000
000000000000}
C03FF3FFFFCFDFDFFFFFF3FFFFEFFFFF}
end
end

View File

@ -46,7 +46,6 @@ type
MenuItem1: TMenuItem;
mnuDelete: TMenuItem;
mnuDuplicate: TMenuItem;
MenuItem2: TMenuItem;
mnuAdd: TMenuItem;
mnuAutoZoom: TMenuItem;
N1: TMenuItem;
@ -65,12 +64,6 @@ type
PageControl: TPageControl;
TriangleTab: TTabSheet;
tabXForm: TTabSheet;
lbla: TLabel;
Label1: TLabel;
Label2: TLabel;
Label3: TLabel;
Label4: TLabel;
Label5: TLabel;
Label6: TLabel;
Label29: TLabel;
txtA: TEdit;
@ -106,7 +99,6 @@ type
Label9: TLabel;
Label7: TLabel;
Label11: TLabel;
chkPreserve: TCheckBox;
btTrgRotateRight: TSpeedButton;
btTrgRotateLeft: TSpeedButton;
btTrgMoveUp: TSpeedButton;
@ -148,21 +140,18 @@ type
Label8: TLabel;
pnlGridColor1: TPanel;
pnlGridColor2: TPanel;
PreviewToolBar: TToolBar;
tbFullView: TToolButton;
tbLowQ: TToolButton;
tbMedQ: TToolButton;
ToolButton7: TToolButton;
tbResetLoc: TToolButton;
tbHiQ: TToolButton;
ToolButton9: TToolButton;
TabSheet4: TTabSheet;
vleVariables: TValueListEditor;
mnuReset: TMenuItem;
mnuResetAll: TMenuItem;
tbResetAll: TToolButton;
Label10: TLabel;
pnlHelpersColor: TPanel;
btnResetCoefs: TSpeedButton;
btnXcoefs: TSpeedButton;
btnYcoefs: TSpeedButton;
btnOcoefs: TSpeedButton;
btnCoefsRect: TSpeedButton;
btnCoefsPolar: TSpeedButton;
chkPreserve: TCheckBox;
procedure ValidateVariable;
procedure vleVariablesValidate(Sender: TObject; ACol, ARow: Integer; const KeyName, KeyValue: string);
procedure vleVariablesKeyPress(Sender: TObject; var Key: Char);
@ -178,7 +167,7 @@ type
Shift: TShiftState; X, Y: integer);
procedure TriangleViewMouseWheel(Sender: TObject; Shift: TShiftState;
WheelDelta: Integer; MousePos: TPoint; var Handled: Boolean);
procedure TriangleViewDblClick(Sender: TObject);
// procedure TriangleViewDblClick(Sender: TObject);
procedure TriangleViewKeyDown(Sender: TObject; var Key: Word;
Shift: TShiftState);
procedure TriangleViewKeyUp(Sender: TObject; var Key: Word;
@ -212,7 +201,7 @@ type
procedure mnuFlipHorizontalClick(Sender: TObject);
procedure cbTransformsChange(Sender: TObject);
procedure CoefKeyPress(Sender: TObject; var Key: Char);
procedure CoefExit(Sender: TObject);
procedure CoefValidate(Sender: TObject);
procedure scrlXFormColorScroll(Sender: TObject;
ScrollCode: TScrollCode; var ScrollPos: Integer);
procedure scrlXFormColorChange(Sender: TObject);
@ -242,7 +231,6 @@ type
procedure btTrgScaleDownClick(Sender: TObject);
procedure splitterMoved(Sender: TObject);
procedure tbSelectClick(Sender: TObject);
procedure PreviewImageDblClick(Sender: TObject);
procedure EditKeyPress(Sender: TObject; var Key: Char);
procedure rgPivotClicked(Sender: TObject);
procedure tbEditModeClick(Sender: TObject);
@ -269,7 +257,6 @@ type
Rect: TRect; State: TOwnerDrawState);
procedure tbFullViewClick(Sender: TObject);
{
procedure ColorImageMouseDown(Sender: TObject; Button: TMouseButton;
Shift: TShiftState; X, Y: Integer);
@ -285,6 +272,10 @@ type
procedure mnuResetClick(Sender: TObject);
procedure mnuResetAllClick(Sender: TObject);
procedure pnlHelpersColorClick(Sender: TObject);
procedure btnXcoefsClick(Sender: TObject);
procedure btnYcoefsClick(Sender: TObject);
procedure btnOcoefsClick(Sender: TObject);
procedure btnCoefsModeClick(Sender: TObject);
private
TriangleView: TCustomDrawControl;
@ -307,6 +298,11 @@ type
varDragPos, varDragOld: integer;
varMM: boolean; //hack?
spinnerMode: boolean;
spinnerOld, spinnerPos: integer;
spinnerValue: double;
SpinnerAssoc: TEdit;
// --Z-- variables moved from outside
GraphZoom: double;
TriangleCaught, CornerCaught: boolean;
@ -347,7 +343,8 @@ type
SelectedTriangle: integer;
procedure UpdateDisplay(preview_only: boolean = false);
procedure UpdatePreview;
procedure UpdateDisplay(PreviewOnly: boolean = false); //(?)
procedure AutoZoom;
procedure TriangleViewPaint(Sender: TObject);
end;
@ -372,7 +369,7 @@ function Centroid(t: TTriangle): TSPoint;
function OffsetTriangleRandom(t: TTriangle): TTriangle;
function ScaleTriangleCenter(t: TTriangle; scale: double): TTriangle;
function ScaleTrianglePoint(t: TTriangle; x, y, scale: double): TTriangle;
procedure ScaleAll;
//procedure ScaleAll;
implementation
@ -489,6 +486,7 @@ begin
end;
end;
{
procedure ScaleAll;
var
i, j: integer;
@ -505,6 +503,7 @@ begin
MainTriangles[j].x[i] := MainTriangles[j].x[i] * 0.2;
end;
end;
}
function RotateTriangleCenter(t: TTriangle; rad: double): TTriangle;
var
@ -549,22 +548,11 @@ begin
result := c[i][2] shl 16 + c[i][1] shl 8 + c[i][0];
end;
procedure TEditForm.UpdateDisplay(preview_only: boolean = false);
procedure TEditForm.UpdatePreview;
var
i: integer;
pw, ph: integer;
r: double;
begin
// currently EditForm does not really know if we selected another
// flame in the Main Window - which is kinda not good...
if NumXForms(cp) <> NumXForms(MainCp) then
begin
SelectedTriangle := 0;
mouseOverTriangle := -1;
end;
cp.copy(MainCp);
pw := PrevPnl.Width - 2;
ph := PrevPnl.Height - 2;
if (cp.width / cp.height) > (PrevPnl.Width / PrevPnl.Height) then
@ -582,21 +570,53 @@ begin
PreviewImage.Top := 1;
PreviewImage.Left := (pw - PreviewImage.Width) div 2;
end;
AdjustScale(cp, PreviewImage.Width, PreviewImage.Height);
DrawPreview;
if preview_only then exit;
end;
procedure TEditForm.UpdateDisplay(PreviewOnly: boolean = false);
var
i: integer;
pw, ph: integer;
r: double;
begin
// currently EditForm does not really know if we select another
// flame in the Main Window - which is not good...
{
if NumXForms(cp) <> NumXForms(MainCp) then
begin
SelectedTriangle := 0;
mouseOverTriangle := -1;
end;
}
cp.copy(MainCp);
if SelectedTriangle >= NumXForms(cp) then
begin
SelectedTriangle := NumXForms(cp)-1;
mouseOverTriangle := -1;
end;
UpdatePreview;
if PreviewOnly then exit;
cp.cmap := MainCp.cmap;
cmap := MainCp.cmap;
cbTransforms.Clear;
for i := 0 to Transforms - 1 do
cbTransforms.Items.Add(IntToStr(i + 1));
for i := 1 to Transforms do cbTransforms.Items.Add(IntToStr(i));
// just in case:
SetCaptureControl(nil);
HasChanged := false;
viewDragMode := false;
varDragMode := false;
CornerCaught := false;
TriangleCaught := false;
ShowSelectedInfo;
AutoZoom;
if MainForm.UndoIndex = 0 then AutoZoom // auto-zoom only on 'new' flame - hmm...?
else TriangleView.Invalidate;
end;
procedure TEditForm.DrawPreview;
@ -655,74 +675,71 @@ end;
procedure TEditForm.ShowSelectedInfo;
var
t: integer;
i: integer;
a, b, c, d, e, f: double;
v: double;
strval: string;
begin
t := SelectedTriangle; // why 't' ?
if (SelectedTriangle >= Transforms) then SelectedTriangle := Transforms - 1;
if (t >= Transforms) then t := Transforms - 1;
//if EditForm.cbTransforms.ItemIndex <> t then EditForm.cbTransforms.ItemIndex := t;
EditForm.cbTransforms.ItemIndex := t;
//select combobox item
EditForm.txtAx.text := Format('%.6g', [MainTriangles[t].x[0]]);
EditForm.txtAy.text := Format('%.6g', [MainTriangles[t].y[0]]);
EditForm.txtBx.text := Format('%.6g', [MainTriangles[t].x[1]]);
EditForm.txtBy.text := Format('%.6g', [MainTriangles[t].y[1]]);
EditForm.txtCx.text := Format('%.6g', [MainTriangles[t].x[2]]);
EditForm.txtCy.text := Format('%.6g', [MainTriangles[t].y[2]]);
EditForm.lblTransform.Refresh;
EditForm.txtAx.Refresh;
EditForm.txtAy.Refresh;
EditForm.txtBx.Refresh;
EditForm.txtBy.Refresh;
EditForm.txtCx.Refresh;
EditForm.txtCy.Refresh;
a := EditForm.cp.xform[t].c[0][0];
b := EditForm.cp.xform[t].c[1][0];
c := EditForm.cp.xform[t].c[0][1];
d := EditForm.cp.xform[t].c[1][1];
e := EditForm.cp.xform[t].c[2][0];
f := EditForm.cp.xform[t].c[2][1];
cbTransforms.ItemIndex := SelectedTriangle;
cbTransforms.Refresh;
EditForm.txtA.text := Format('%.6g', [a]);
EditForm.txtB.text := Format('%.6g', [b]);
EditForm.txtC.text := Format('%.6g', [c]);
EditForm.txtD.text := Format('%.6g', [d]);
EditForm.txtE.text := Format('%.6g', [e]);
EditForm.txtF.text := Format('%.6g', [f]);
with MainTriangles[SelectedTriangle] do
begin
txtAx.text := Format('%.6g', [x[0]]);
txtAy.text := Format('%.6g', [y[0]]);
txtBx.text := Format('%.6g', [x[1]]);
txtBy.text := Format('%.6g', [y[1]]);
txtCx.text := Format('%.6g', [x[2]]);
txtCy.text := Format('%.6g', [y[2]]);
end;
EditForm.txtP.text := Format('%.6g', [EditForm.cp.xform[t].density]);
EditForm.txtSymmetry.text := Format('%.6g', [EditForm.cp.xform[t].symmetry]);
EditForm.txtA.Refresh;
EditForm.txtB.Refresh;
EditForm.txtC.Refresh;
EditForm.txtD.Refresh;
EditForm.txtE.Refresh;
EditForm.txtF.Refresh;
EditForm.txtP.Refresh;
EditForm.pnlXFormColor.Color := ColorValToColor(EditForm.cp.cmap, EditForm.cp.xform[t].color);
EditForm.txtXFormColor.Text := Format('%1.3f', [cp.xform[t].color]);//FloatToStr(EditForm.cp.xform[t].color);
EditForm.scrlXFormcolor.Position := Trunc(EditForm.cp.xform[t].color * scrlXFormColor.Max);
with cp.xform[SelectedTriangle] do
begin
// OMG. and now these coefs are stored with inverse sign? :-\
if btnCoefsRect.Down then begin
txtA.text := Format('%.6g', [ c[0][0]]);
txtB.text := Format('%.6g', [-c[0][1]]);
txtC.text := Format('%.6g', [-c[1][0]]);
txtD.text := Format('%.6g', [ c[1][1]]);
txtE.text := Format('%.6g', [ c[2][0]]);
txtF.text := Format('%.6g', [-c[2][1]]);
end
else begin
txtA.text := Format('%.6g', [Hypot(c[0][0], c[0][1])]);
txtB.text := Format('%.6g', [arctan2(-c[0][1], c[0][0])*180/PI]);
txtC.text := Format('%.6g', [Hypot(c[1][0], c[1][1])]);
txtD.text := Format('%.6g', [arctan2(c[1][1], -c[1][0])*180/PI]);
txtE.text := Format('%.6g', [Hypot(c[2][0], c[2][1])]);
txtF.text := Format('%.6g', [arctan2(-c[2][1], c[2][0])*180/PI]);
end;
for i := 0 to NRVAR-1 do begin
v:=EditForm.cp.xform[SelectedTriangle].vars[i];
if v <> VarsCache[i] then
begin
VarsCache[i]:=v;
EditForm.VEVars.Values[VarNames(i)] := Format('%.6g', [v]);
txtP.text := Format('%.6g', [density]);
txtSymmetry.text := Format('%.6g', [symmetry]);
pnlXFormColor.Color := ColorValToColor(cp.cmap, color);
txtXFormColor.Text := Format('%1.3f', [color]);
scrlXFormcolor.Position := Trunc(color * scrlXFormColor.Max);
for i := 0 to NRVAR-1 do begin
v := vars[i];
if v <> VarsCache[i] then
begin
VarsCache[i]:=v;
VEVars.Values[VarNames(i)] := Format('%.6g', [v]);
end;
end;
for i:= 0 to GetNrVariableNames - 1 do begin
GetVariable(GetVariableNameAt(i), v);
strval := Format('%.6g', [v]);
// kinda funny, but it really helped...
if vleVariables.Values[GetVariableNameAt(i)] <> strval then
vleVariables.Values[GetVariableNameAt(i)] := strval;
end;
end;
for i:= 0 to GetNrVariableNames - 1 do begin
cp.xform[SelectedTriangle].GetVariable(GetVariableNameAt(i), v);
strval := Format('%.6g', [v]);
// kinda funny, but it's really helped...
if vleVariables.Values[GetVariableNameAt(i)] <> strval then
vleVariables.Values[GetVariableNameAt(i)] := strval;
end;
PageControl.Refresh;
end;
procedure TEditForm.Scale(var fx, fy: double; x, y: integer);
@ -760,13 +777,9 @@ begin
gCentery := yminz + gylength / 2;
if gxlength >= gylength then
begin
GraphZoom := TriangleView.Width / 60 / gxlength;
end
GraphZoom := TriangleView.Width / 60 / gxlength
else
begin
GraphZoom := TriangleView.Height / 60 / gylength;
end;
EditForm.StatusBar.Panels[2].Text := Format('Zoom: %f', [GraphZoom]);
TriangleView.Invalidate;//Refresh;
@ -776,21 +789,21 @@ procedure TEditForm.UpdateFlameX;
var
i: integer;
begin
for i := 0 to transforms - 1 do
for i := 0 to Transforms - 1 do
begin
// CP_compute(cp1, Triangles[i], Triangles[-1], i);
solve3(MainTriangles[-1].x[0], MainTriangles[-1].y[0], MainTriangles[i].x[0],
MainTriangles[-1].x[1], MainTriangles[-1].y[1], MainTriangles[i].x[1],
MainTriangles[-1].x[2], MainTriangles[-1].y[2], MainTriangles[i].x[2],
cp.xform[i].c[0][0], cp.xform[i].c[1][0], cp.xform[i].c[2][0]);
MainTriangles[-1].x[1], MainTriangles[-1].y[1], MainTriangles[i].x[1],
MainTriangles[-1].x[2], MainTriangles[-1].y[2], MainTriangles[i].x[2],
cp.xform[i].c[0][0], cp.xform[i].c[1][0], cp.xform[i].c[2][0]);
solve3(MainTriangles[-1].x[0], MainTriangles[-1].y[0], MainTriangles[i].y[0],
MainTriangles[-1].x[1], MainTriangles[-1].y[1], MainTriangles[i].y[1],
MainTriangles[-1].x[2], MainTriangles[-1].y[2], MainTriangles[i].y[2],
cp.xform[i].c[0][1], cp.xform[i].c[1][1], cp.xform[i].c[2][1]);
MainTriangles[-1].x[1], MainTriangles[-1].y[1], MainTriangles[i].y[1],
MainTriangles[-1].x[2], MainTriangles[-1].y[2], MainTriangles[i].y[2],
cp.xform[i].c[0][1], cp.xform[i].c[1][1], cp.xform[i].c[2][1]);
end;
cp.GetFromTriangles(MainTriangles, transforms);
cp.GetFromTriangles(MainTriangles, Transforms);
// if not chkPreserve.checked then ComputeWeights(cp, MainTriangles, transforms);
DrawPreview;
ShowSelectedInfo;
@ -855,8 +868,7 @@ begin
UpdateFlame(True);
end;
cbTransforms.clear;
for i := 0 to Transforms - 1 do
cbTransforms.Items.Add(IntToStr(i + 1));
for i := 1 to Transforms do cbTransforms.Items.Add(IntToStr(i));
cbTransforms.ItemIndex := SelectedTriangle;
end;
end;
@ -1290,7 +1302,7 @@ begin
TriangleView.OnPaint := TriangleViewPaint;
TriangleView.OnDblClick := TriangleViewDblClick;
TriangleView.OnDblClick := mnuAutoZoomClick;//TriangleViewDblClick;
TriangleView.OnMouseDown := TriangleViewMouseDown;
TriangleView.OnMouseMove := TriangleViewMouseMove;
TriangleView.OnMouseUp := TriangleViewMouseUp;
@ -1394,7 +1406,7 @@ begin
// -- from MouseDown -- for highlighting:
// TODO: optimize...
if j = rgPivot.ItemIndex then
if (j = 1) and ((rgPivot.ItemIndex = 1) or (rgPivot.ItemIndex = 4)) then
begin
Pivot.x := 0;
Pivot.y := 0;
@ -1417,7 +1429,7 @@ begin
i := InsideTriangle(fx, fy);
if i >= 0 then mouseOverTriangle:=i
else mouseOverTriangle:=-2;
else mouseOverTriangle:=-1;
FoundCorner:
end;
@ -1467,10 +1479,10 @@ Skip1:
if LocalAxisLocked then with MainTriangles[SelectedTriangle] do
begin
assert(SelectedCorner = 1);
x[0] := x[0] + vx-x[1];
y[0] := y[0] + vy-y[1];
x[2] := x[2] + vx-x[1];
y[2] := y[2] + vy-y[1];
x[0] := OldTriangle.x[0] + vx - OldTriangle.x[1];
y[0] := OldTriangle.y[0] + vy - OldTriangle.y[1];
x[2] := OldTriangle.x[2] + vx - OldTriangle.x[1];
y[2] := OldTriangle.y[2] + vy - OldTriangle.y[1];
end;
MainTriangles[SelectedTriangle].x[SelectedCorner] := Pivot.X+vx;
MainTriangles[SelectedTriangle].y[SelectedCorner] := Pivot.Y+vy;
@ -1488,20 +1500,35 @@ Skip1:
else if (editMode = modeScale) then
begin // move point along vector ("scale")
if olddist<>0 then begin
vy := (oldx*(fx-Pivot.X) + oldy*(fy-Pivot.Y))/(olddist*olddist);
d := (oldx*(fx-Pivot.X) + oldy*(fy-Pivot.Y))/olddist;
if ssShift in Shift then // 'snapped' scale
begin
try // use move-value for 'scaling' point:
t := abs(StrToFloat(txtTrgMoveValue.Text));
//assert(t<>0);
except
t := 0.1;
txtTrgMoveValue.Text := '0.1';
end;
if t <> 0 then d := Trunc(d/t)*t;
end;
vx := oldx*d/olddist;
vy := oldy*d/olddist;
if LocalAxisLocked then with MainTriangles[SelectedTriangle] do
begin
assert(SelectedCorner = 1);
x[0] := x[0] + oldx*vy-x[1];
y[0] := y[0] + oldy*vy-y[1];
x[2] := x[2] + oldx*vy-x[1];
y[2] := y[2] + oldy*vy-y[1];
x[0] := OldTriangle.x[0] + vx - OldTriangle.x[1];
y[0] := OldTriangle.y[0] + vy - OldTriangle.y[1];
x[2] := OldTriangle.x[2] + vx - OldTriangle.x[1];
y[2] := OldTriangle.y[2] + vy - OldTriangle.y[1];
end;
MainTriangles[SelectedTriangle].x[SelectedCorner] := Pivot.X + vx;
MainTriangles[SelectedTriangle].y[SelectedCorner] := Pivot.Y + vy;
MainTriangles[SelectedTriangle].x[SelectedCorner] := Pivot.X + oldx*vy;
MainTriangles[SelectedTriangle].y[SelectedCorner] := Pivot.Y + oldy*vy;
StatusBar.Panels[2].Text := Format('Scale: %3.2f%%', [vy*100]);
StatusBar.Panels[2].Text := Format('Distance: %3.3f Scale: %3.2f%%',
[Hypot(vx, vy), d*100/olddist]);
end
else begin
MainTriangles[SelectedTriangle].x[SelectedCorner] := Pivot.X;
@ -1569,6 +1596,19 @@ Skip2:
begin
if olddist<>0 then begin
vy := (oldx*(fx-Pivot.X) + oldy*(fy-Pivot.Y))/(olddist*olddist);
if ssShift in Shift then // 'snapped' scale
begin
try
t := abs(StrToFloat(txtTrgScaleValue.Text)/100.0 - 1.0);
//assert(t<>0);
except
t := 0.1;
txtTrgRotateValue.Text := '0.1';
end;
if t <> 0 then vy := Trunc(vy/t)*t;
end;
MainTriangles[SelectedTriangle] :=
ScaleTrianglePoint(OldTriangle, Pivot.X, Pivot.Y, vy);
StatusBar.Panels[2].Text := Format('Scale: %3.2f%%', [vy*100]);
@ -1647,7 +1687,7 @@ begin
SelectedCorner := j;
// Pivot := GetPivot;
if j = rgPivot.ItemIndex then // hmm
if (j = 1) and ((rgPivot.ItemIndex = 1) or (rgPivot.ItemIndex = 4)) then
begin
Pivot.x := 0;
Pivot.y := 0;
@ -1658,6 +1698,7 @@ begin
Pivot := GetPivot;
LocalAxisLocked := false;
end;
OldTriangle := MainTriangles[SelectedTriangle];
oldx := MainTriangles[SelectedTriangle].x[j] - Pivot.X;
oldy := MainTriangles[SelectedTriangle].y[j] - Pivot.Y;
olddist := sqrt(oldx*oldx + oldy*oldy);
@ -1792,7 +1833,7 @@ begin
if Registry.ValueExists('ResetLocation') then
mnuResetLoc.checked := Registry.ReadBool('ResetLocation')
else mnuResetLoc.checked := true;
tbResetLoc.Down := mnuResetLoc.checked;
//tbResetLoc.Down := mnuResetLoc.checked;
end
else begin
UseTransformColors := False;
@ -1803,7 +1844,7 @@ begin
HelpersColor := $808080;
ReferenceTriangleColor := integer(clGray);
mnuResetLoc.checked := true;
tbResetLoc.Down := true;
//tbResetLoc.Down := true;
end;
Registry.CloseKey;
finally
@ -1832,17 +1873,15 @@ begin
if Transforms < NXFORMS then
begin
MainForm.UpdateUndo;
Transforms := Transforms + 1;
MainTriangles[Transforms - 1] := MainTriangles[-1];
SelectedTriangle := Transforms - 1;
// ComputeWeights(cp, MainTriangles, transforms);
cp.xform[Transforms - 1].density := 0.5;
cp.xform[Transforms - 1].vars[0] := 1;
MainTriangles[Transforms] := MainTriangles[-1];
SelectedTriangle := Transforms;
cp.xform[Transforms].density := 0.5;
cp.xform[Transforms].vars[0] := 1;
for i := 1 to NRVAR - 1 do
cp.xform[Transforms - 1].vars[i] := 0;
cp.xform[Transforms].vars[i] := 0;
Inc(Transforms);
cbTransforms.clear;
for i := 0 to Transforms - 1 do
cbTransforms.Items.Add(IntToStr(i + 1));
for i := 1 to Transforms do cbTransforms.Items.Add(IntToStr(i));
UpdateFlame(True);
end;
end;
@ -1854,16 +1893,14 @@ begin
if Transforms < NXFORMS then
begin
MainForm.UpdateUndo;
Transforms := Transforms + 1;
MainTriangles[Transforms - 1] := MainTriangles[SelectedTriangle];
// ComputeWeights(cp, MainTriangles, transforms);
cp.xform[Transforms - 1].density := cp.xform[SelectedTriangle].density;
MainTriangles[Transforms] := MainTriangles[SelectedTriangle];
cp.xform[Transforms].density := cp.xform[SelectedTriangle].density;
for i := 0 to NRVAR - 1 do
cp.xform[Transforms - 1].vars[i] := cp.xform[SelectedTriangle].vars[i];
SelectedTriangle := Transforms - 1;
cp.xform[Transforms].vars[i] := cp.xform[SelectedTriangle].vars[i];
SelectedTriangle := Transforms;
Inc(Transforms);
cbTransforms.clear;
for i := 0 to Transforms - 1 do
cbTransforms.Items.Add(IntToStr(i + 1));
for i := 1 to Transforms do cbTransforms.Items.Add(IntToStr(i));
UpdateFlame(True);
end;
end;
@ -2128,7 +2165,7 @@ end;
procedure TEditForm.mnuLowQualityClick(Sender: TObject);
begin
mnuLowQuality.Checked := True;
tbLowQ.Down := true;
//tbLowQ.Down := true;
PreviewDensity := prevLowQuality;
EditPrevQual := 0;
DrawPreview;
@ -2137,7 +2174,7 @@ end;
procedure TEditForm.mnuHighQualityClick(Sender: TObject);
begin
mnuHighQuality.Checked := True;
tbHiQ.Down := true;
//tbHiQ.Down := true;
PreviewDensity := prevHighQuality;
EditPrevQual := 2;
DrawPreview;
@ -2146,7 +2183,7 @@ end;
procedure TEditForm.mnuMediumQualityClick(Sender: TObject);
begin
mnuMediumQuality.Checked := True;
tbMedQ.Down := true;
//tbMedQ.Down := true;
PreviewDensity := prevMediumQuality;
EditPrevQual := 1;
DrawPreview;
@ -2158,7 +2195,7 @@ var
begin
reset:= not mnuResetLoc.Checked;
mnuResetLoc.Checked := reset;
tbResetLoc.Down := reset;
//tbResetLoc.Down := reset;
if reset then
begin
cp.width := MainCp.width;
@ -2203,14 +2240,14 @@ var
p: double;
begin
MainForm.UpdateUndo;
with MainTriangles[SelectedTriangle] do // --Z--
with MainTriangles[SelectedTriangle] do
begin
p := GetPivot.y * 2;
y[0] := p - y[0];
y[1] := p - y[1];
y[2] := p - y[2];
end;
AutoZoom;
//AutoZoom;
UpdateFlame(True);
end;
@ -2219,21 +2256,23 @@ var
p: double;
begin
MainForm.UpdateUndo;
with MainTriangles[SelectedTriangle] do // --Z--
with MainTriangles[SelectedTriangle] do
begin
p := GetPivot.x * 2;
x[0] := p - x[0];
x[1] := p - x[1];
x[2] := p - x[2];
end;
AutoZoom;
//AutoZoom;
UpdateFlame(True);
end;
{
procedure TEditForm.TriangleViewDblClick(Sender: TObject);
begin
AutoZoom;
end;
}
procedure TEditForm.cbTransformsChange(Sender: TObject);
begin
@ -2272,127 +2311,88 @@ begin
end;
procedure TEditForm.CoefKeyPress(Sender: TObject; var Key: Char);
var
Allow: boolean;
i: integer;
OldVal, NewVal: double;
begin
i := 0; OldVal := 0;
if key = #13 then
begin
key := #0;
Allow := True;
if Sender = txtA then
i := 0
else if Sender = txtB then
i := 1
else if Sender = txtC then
i := 2
else if Sender = txtD then
i := 3
else if Sender = txtE then
i := 4
else if Sender = txtF then
i := 5;
case i of
0: OldVal := Round6(cp.xform[SelectedTriangle].c[0][0]); //a
1: OldVal := Round6(cp.xform[SelectedTriangle].c[1][0]); //b
2: OldVal := Round6(cp.xform[SelectedTriangle].c[0][1]); //c
3: OldVal := Round6(cp.xform[SelectedTriangle].c[1][1]); //d
4: OldVal := Round6(cp.xform[SelectedTriangle].c[2][0]); //e
5: OldVal := Round6(cp.xform[SelectedTriangle].c[2][1]); //f
end;
// OldText := Val;
{ Test that it's a valid floating point number }
try
StrToFloat(TEdit(Sender).Text);
except on Exception do
begin
{ It's not, so we restore the old value }
TEdit(Sender).Text := Format('%.6g', [OldVal]);
Allow := False;
end;
end;
NewVal := Round6(StrToFloat(TEdit(Sender).Text));
TEdit(Sender).Text := Format('%.6g', [NewVal]);
{ If it's not the same as the old value and it was valid }
if (NewVal <> OldVal) and Allow then
begin
MainForm.UpdateUndo;
case i of
0: cp.xform[SelectedTriangle].c[0][0] := NewVal; //a
1: cp.xform[SelectedTriangle].c[1][0] := NewVal; //b
2: cp.xform[SelectedTriangle].c[0][1] := NewVal; //c
3: cp.xform[SelectedTriangle].c[1][1] := NewVal; //d
4: cp.xform[SelectedTriangle].c[2][0] := NewVal; //e
5: cp.xform[SelectedTriangle].c[2][1] := NewVal; //f
end;
cp.TrianglesFromCP(MainTriangles);
ShowSelectedInfo;
UpdateFlame(true);
end;
end;
if key <> #13 then exit;
key := #0;
CoefValidate(Sender);
end;
procedure TEditForm.CoefExit(Sender: TObject);
procedure TEditForm.CoefValidate(Sender: TObject);
var
Allow: boolean;
i: integer;
NewVal, OldVal: double;
NewVal: double;
x, y, r, a: double; // dumb... must optimize
begin
i := 0; OldVal := 0;
Allow := True;
if Sender = txtA then
i := 0
else if Sender = txtB then
i := 1
else if Sender = txtC then
i := 2
else if Sender = txtD then
i := 3
else if Sender = txtE then
i := 4
else if Sender = txtF then
i := 5;
case i of
0: OldVal := Round6(cp.xform[SelectedTriangle].c[0][0]); //a
1: OldVal := Round6(cp.xform[SelectedTriangle].c[1][0]); //b
2: OldVal := Round6(cp.xform[SelectedTriangle].c[0][1]); //c
3: OldVal := Round6(cp.xform[SelectedTriangle].c[1][1]); //d
4: OldVal := Round6(cp.xform[SelectedTriangle].c[2][0]); //e
5: OldVal := Round6(cp.xform[SelectedTriangle].c[2][1]); //f
end;
// OldText := Val;
{ Test that it's a valid floating point number }
try
StrToFloat(TEdit(Sender).Text);
NewVal := Round6(StrToFloat(TEdit(Sender).Text));
except on Exception do
begin
{ It's not, so we restore the old value }
TEdit(Sender).Text := Format('%.6g', [OldVal]);
Allow := False;
ShowSelectedInfo; //TEdit(Sender).Text := Format('%.6g', [pVal^]);
exit;
end;
end;
NewVal := Round6(StrToFloat(TEdit(Sender).Text));
TEdit(Sender).Text := Format('%.6g', [NewVal]);
{ If it's not the same as the old value and it was valid }
if (NewVal <> OldVal) and Allow then
//TEdit(Sender).Text := Format('%.6g', [NewVal]);
MainForm.UpdateUndo; // TODO - prevent unnecessary UpdateUndo...
with cp.xform[SelectedTriangle] do
begin
if btnCoefsRect.Down = true then
begin
MainForm.UpdateUndo;
case i of
0: cp.xform[SelectedTriangle].c[0][0] := NewVal; //a
1: cp.xform[SelectedTriangle].c[1][0] := NewVal; //b
2: cp.xform[SelectedTriangle].c[0][1] := NewVal; //c
3: cp.xform[SelectedTriangle].c[1][1] := NewVal; //d
4: cp.xform[SelectedTriangle].c[2][0] := NewVal; //e
5: cp.xform[SelectedTriangle].c[2][1] := NewVal; //f
if Sender = txtA then
cp.xform[SelectedTriangle].c[0][0] := NewVal
else if Sender = txtB then
cp.xform[SelectedTriangle].c[0][1] := -NewVal
else if Sender = txtC then
cp.xform[SelectedTriangle].c[1][0] := -NewVal
else if Sender = txtD then
cp.xform[SelectedTriangle].c[1][1] := NewVal
else if Sender = txtE then
cp.xform[SelectedTriangle].c[2][0] := NewVal
else if Sender = txtF then
cp.xform[SelectedTriangle].c[2][1] := -NewVal;
end
else begin
if (Sender = txtA) or (Sender = txtB) then begin
x := c[0][0];
y := -c[0][1];
end else
if (Sender = txtC) or (Sender = txtD) then begin
x := -c[1][0];
y := c[1][1];
end else
{if (Sender = txtE) or (Sender = txtF) then}
begin
x := c[2][0];
y := -c[2][1];
end;
r := Hypot(x, y);
a := arctan2(y, x);
if (Sender = txtA) or (Sender = txtC) or (Sender = txtE) then
r := NewVal
else
a := NewVal*PI/180;
x := r * cos(a);
y := r * sin(a);
if (Sender = txtA) or (Sender = txtB) then begin
c[0][0] := x;
c[0][1] := -y;
end else
if (Sender = txtC) or (Sender = txtD) then begin
c[1][0] := -x;
c[1][1] := y;
end else
{if (Sender = txtE) or (Sender = txtF) then}
begin
c[2][0] := x;
c[2][1] := -y;
end;
cp.TrianglesFromCP(MainTriangles);
ShowSelectedInfo;
UpdateFlame(true);
end;
end;
cp.TrianglesFromCP(MainTriangles);
ShowSelectedInfo;
UpdateFlame(true);
end;
procedure TEditForm.scrlXFormColorScroll(Sender: TObject;
@ -3176,7 +3176,7 @@ end;
procedure TEditForm.splitterMoved(Sender: TObject);
begin
UpdateDisplay;
UpdatePreview;
end;
procedure TEditForm.tbSelectClick(Sender: TObject);
@ -3209,14 +3209,6 @@ begin
Handled := true;
end;
procedure TEditForm.PreviewImageDblClick(Sender: TObject);
begin
MainForm.UpdateUndo;
MainForm.ResetLocation;
MainForm.RedrawTimer.enabled := true;
MainForm.UpdateWindows;
end;
procedure TEditForm.rgPivotClicked(Sender: TObject);
begin
TriangleView.Invalidate;
@ -3390,11 +3382,9 @@ var
begin
MainForm.UpdateUndo;
MainTriangles[SelectedTriangle] := MainTriangles[-1];
cp.xform[SelectedTriangle].vars[0] := 1;
for i := 1 to NRVAR - 1 do
begin
cp.xform[SelectedTriangle].vars[i] := 0;
end;
// cp.xform[SelectedTriangle].vars[0] := 1;
// for i := 1 to NRVAR - 1 do
// cp.xform[SelectedTriangle].vars[i] := 0;
UpdateFlame(True);
end;
@ -3426,5 +3416,50 @@ begin
UpdateFlame(True);
end;
// -----------------------------------------------------------------------------
procedure TEditForm.btnXcoefsClick(Sender: TObject);
begin
with cp.xform[SelectedTriangle] do
begin
if (c[0][0] = 1) and (c[0][1] = 0) then exit;
MainForm.UpdateUndo;
c[0][0] := 1;
c[0][1] := 0;
end;
cp.TrianglesFromCP(MainTriangles);
UpdateFlame(True);
end;
procedure TEditForm.btnYcoefsClick(Sender: TObject);
begin
if (cp.xform[SelectedTriangle].c[1][0] = 0) and
(cp.xform[SelectedTriangle].c[1][1] = 1) then exit;
MainForm.UpdateUndo;
cp.xform[SelectedTriangle].c[1][0] := 0;
cp.xform[SelectedTriangle].c[1][1] := 1;
cp.TrianglesFromCP(MainTriangles);
UpdateFlame(True);
end;
procedure TEditForm.btnOcoefsClick(Sender: TObject);
begin
if (cp.xform[SelectedTriangle].c[2][0] = 0) and
(cp.xform[SelectedTriangle].c[2][1] = 0) then exit;
MainForm.UpdateUndo;
cp.xform[SelectedTriangle].c[2][0] := 0;
cp.xform[SelectedTriangle].c[2][1] := 0;
cp.TrianglesFromCP(MainTriangles);
UpdateFlame(True);
end;
procedure TEditForm.btnCoefsModeClick(Sender: TObject);
begin
ShowSelectedInfo;
end;
end.

View File

@ -181,8 +181,8 @@ begin
end;
function dist(x1, y1, x2, y2: double): double;
var
d2: double;
//var
// d2: double;
begin
(*
{ From FDesign source

View File

@ -27,7 +27,7 @@ object MainForm: TMainForm
Left = 160
Top = 28
Width = 4
Height = 522
Height = 520
end
object ToolBar: TToolBar
Left = 0
@ -284,7 +284,7 @@ object MainForm: TMainForm
Left = 0
Top = 28
Width = 160
Height = 522
Height = 520
Align = alLeft
Columns = <
item
@ -303,7 +303,7 @@ object MainForm: TMainForm
Left = 164
Top = 28
Width = 433
Height = 522
Height = 520
Align = alClient
BevelInner = bvLowered
BevelOuter = bvNone
@ -314,7 +314,7 @@ object MainForm: TMainForm
Left = 1
Top = 1
Width = 431
Height = 520
Height = 518
Align = alClient
AutoSize = True
PopupMenu = DisplayPopup
@ -327,7 +327,7 @@ object MainForm: TMainForm
end
object StatusBar: TStatusBar
Left = 0
Top = 550
Top = 548
Width = 597
Height = 19
Panels = <
@ -2626,7 +2626,7 @@ object MainForm: TMainForm
Caption = 'Full Screen'
Hint = 'Show the flame in fullscreen mode'
ImageIndex = 52
ShortCut = 16454
ShortCut = 114
OnClick = mnuFullScreenClick
end
object N4: TMenuItem
@ -2636,44 +2636,44 @@ object MainForm: TMainForm
Caption = '&Editor'
Hint = 'Show the Transform Editor'
ImageIndex = 19
ShortCut = 16453
ShortCut = 115
OnClick = mnuEditorClick
end
object mnuAdjust: TMenuItem
Caption = 'Adjust'
Hint = 'Show the Adjust window'
ImageIndex = 18
ShortCut = 16449
ShortCut = 116
OnClick = mnuAdjustClick
end
object mnuGrad: TMenuItem
Caption = 'Gradient'
Hint = 'Show the Gradient window'
ImageIndex = 11
ShortCut = 16455
ShortCut = 117
OnClick = mnuGradClick
end
object mnuMutate: TMenuItem
Caption = 'Mutation'
Hint = 'Show the Mutation window'
ImageIndex = 17
ShortCut = 16461
ShortCut = 118
OnClick = mnuMutateClick
end
object mnuimage: TMenuItem
Caption = 'Image '
Visible = False
OnClick = mnuimageClick
end
object N5: TMenuItem
Caption = '-'
end
object mnuImageSize: TMenuItem
Caption = 'Image Size'
ImageIndex = 51
ShortCut = 16457
ShortCut = 119
OnClick = mnuImageSizeClick
end
object mnuimage: TMenuItem
Caption = 'Image '
Visible = False
OnClick = mnuimageClick
end
end
object F1: TMenuItem
Caption = 'Flame'
@ -2691,25 +2691,21 @@ object MainForm: TMainForm
object mnuRandom: TMenuItem
Caption = '&Randomize'
Hint = 'Randomize flame parameters'
ShortCut = 120
OnClick = mnuRandomClick
end
object mnuRWeights: TMenuItem
Caption = 'Random &Weights'
Hint = 'Randomize transform weights'
ShortCut = 116
OnClick = mnuRWeightsClick
end
object mnuEqualize: TMenuItem
Caption = '&Equalize Weights'
Hint = 'Set all weights to the same value'
ShortCut = 117
OnClick = mnuEqualizeClick
end
object mnuNormalWeights: TMenuItem
Caption = 'Compute Weights'
Hint = 'Compute weights from triangle areas'
ShortCut = 118
OnClick = mnuNormalWeightsClick
end
object N7: TMenuItem
@ -2745,7 +2741,7 @@ object MainForm: TMainForm
Checked = True
GroupIndex = 2
RadioItem = True
ShortCut = 121
ShortCut = 122
OnClick = mnuVRandomClick
end
object N8: TMenuItem
@ -2756,16 +2752,16 @@ object MainForm: TMainForm
object mnuScript: TMenuItem
Caption = 'Script'
object mnuRun: TMenuItem
Caption = 'Run "Default Animation"'
Caption = 'Run script'
Hint = 'Run the currently loaded script'
ImageIndex = 43
ShortCut = 119
ShortCut = 120
OnClick = mnuRunClick
end
object mnuStop: TMenuItem
Caption = 'Stop'
Caption = 'Stop script'
ImageIndex = 36
ShortCut = 16468
ShortCut = 121
OnClick = mnuStopClick
end
object N15: TMenuItem

View File

@ -1810,9 +1810,9 @@ begin
if (MainCp.width <> Image.Width) or (MainCp.height <> Image.height) then
begin
AdjustScale(MainCp, Image.width, Image.height);
if EditForm.Visible then EditForm.UpdateDisplay(true); // preview only
if EditForm.Visible then EditForm.UpdateDisplay(true); // preview only?
end;
if AdjustForm.Visible then AdjustForm.UpdateDisplay;
if AdjustForm.Visible then AdjustForm.UpdateDisplay(true); // preview only!
// following needed ?
// cp.Zoom := Zoom;
// cp.center[0] := center[0];
@ -2223,8 +2223,7 @@ begin
IntToStr(RandomIndex);
Transforms := MainCp.TrianglesFromCP(MainTriangles);
if AdjustForm.visible then
AdjustForm.UpdateDisplay;
if AdjustForm.visible then AdjustForm.UpdateDisplay;
StatusBar.Panels[2].text := maincp.name;
ResetLocation;
@ -2825,7 +2824,7 @@ begin
// Zoom := maincp.zoom;
Center[0] := maincp.Center[0];
Center[1] := maincp.Center[1];
MainCP.NormalizeWeights;
// MainCP.NormalizeWeights;
mnuSaveUndo.Enabled := false;
mnuUndo.Enabled := False;
mnuPopUndo.Enabled := False;
@ -2866,14 +2865,8 @@ end;
procedure TMainForm.UpdateWindows;
begin
if AdjustForm.visible then
AdjustForm.UpdateDisplay;
if AdjustForm.visible then AdjustForm.UpdateDisplay;
if EditForm.visible then EditForm.UpdateDisplay;
// hmm I think I still have some problems with EditForm updating
// several times in a row with all these calls :-\
// if AdjustForm.visible then AdjustForm.UpdateDisplay;
if MutateForm.visible then MutateForm.UpdateDisplay;
end;
@ -2937,15 +2930,13 @@ begin
Center[0] := maincp.Center[0];
Center[1] := maincp.Center[1];
// cp.CalcBoundbox;
MainCP.NormalizeWeights;
// MainCP.NormalizeWeights;
Transforms := MainCp.TrianglesFromCP(MainTriangles);
// Trim undo index from title
maincp.name := Copy(Fstrings[0], 6, length(Fstrings[0]) - 7);
if SavedPal then
maincp.cmap := palette;
if AdjustForm.visible then
AdjustForm.UpdateDisplay;
if SavedPal then maincp.cmap := palette;
if AdjustForm.visible then AdjustForm.UpdateDisplay;
RedrawTimer.Enabled := True;
UpdateWindows;
@ -3636,7 +3627,7 @@ begin
if nxform < NXFORMS then
for i := nxform to NXFORMS - 1 do
cp1.xform[i].density := 0;
cp1.NormalizeWeights;
// cp1.NormalizeWeights;
// Check for symmetry parameter
if ParseCp.symmetry <> 0 then
begin

View File

@ -19,7 +19,7 @@ implementation
uses
math;
// TVariationEyefish
// TVariationEyefish, the correct "fish-eye" variation
///////////////////////////////////////////////////////////////////////////////
procedure TVariationEyefish.CalcFunction;
@ -61,6 +61,7 @@ asm
fadd qword ptr [ecx]
fstp qword ptr [ecx]
fwait
{$ifend}
end;