optimized renderer

added drag-edit controls in forms: editor, adjust, postprocess
This commit is contained in:
zueuk 2006-03-06 15:34:54 +00:00
parent 0fbd6a6ff6
commit b81d9ee0dd
16 changed files with 1475 additions and 1085 deletions

View File

@ -61,6 +61,7 @@ object AdjustForm: TAdjustForm
Top = 5
Width = 23
Height = 22
Hint = 'Undo'
Flat = True
Glyph.Data = {
36040000424D3604000000000000360000002800000010000000100000000100
@ -106,6 +107,7 @@ object AdjustForm: TAdjustForm
Top = 5
Width = 23
Height = 22
Hint = 'Redo'
Flat = True
Glyph.Data = {
36040000424D3604000000000000360000002800000010000000100000000100
@ -170,62 +172,14 @@ object AdjustForm: TAdjustForm
end
object PageControl: TPageControl
Left = 0
Top = 131
Top = 132
Width = 388
Height = 130
Height = 129
ActivePage = TabSheet1
Align = alBottom
TabOrder = 1
object TabSheet1: TTabSheet
Caption = 'Camera'
object btnZoom: TSpeedButton
Left = 4
Top = 4
Width = 61
Height = 21
Hint = 'Reset value'
Caption = 'Zoom'
Flat = True
ParentShowHint = False
ShowHint = True
OnClick = btnZoomClick
end
object btnXpos: TSpeedButton
Left = 4
Top = 28
Width = 61
Height = 21
Hint = 'Reset value'
Caption = 'X position'
Flat = True
ParentShowHint = False
ShowHint = True
OnClick = btnXposClick
end
object btnYpos: TSpeedButton
Left = 4
Top = 52
Width = 61
Height = 21
Hint = 'Reset value'
Caption = 'Y position'
Flat = True
ParentShowHint = False
ShowHint = True
OnClick = btnYposClick
end
object btnAngle: TSpeedButton
Left = 4
Top = 76
Width = 61
Height = 21
Hint = 'Reset value'
Caption = 'Rotation'
Flat = True
ParentShowHint = False
ShowHint = True
OnClick = btnAngleClick
end
object scrollZoom: TScrollBar
Left = 72
Top = 7
@ -307,8 +261,7 @@ object AdjustForm: TAdjustForm
Width = 257
Height = 15
LargeChange = 1500
Max = 18000
Min = -18000
Max = 36000
PageSize = 0
SmallChange = 100
TabOrder = 6
@ -326,6 +279,74 @@ object AdjustForm: TAdjustForm
OnExit = txtAngleExit
OnKeyPress = txtAngleKeyPress
end
object pnlZoom: TPanel
Left = 4
Top = 4
Width = 61
Height = 21
Cursor = crHandPoint
Hint = 'Click and drag to change value'
BevelOuter = bvLowered
Caption = 'Zoom'
ParentShowHint = False
ShowHint = True
TabOrder = 8
OnDblClick = DragPanelDblClick
OnMouseDown = DragPanelMouseDown
OnMouseMove = DragPanelMouseMove
OnMouseUp = DragPanelMouseUp
end
object pnlXpos: TPanel
Left = 4
Top = 28
Width = 61
Height = 21
Cursor = crHandPoint
Hint = 'Click and drag to change value'
BevelOuter = bvLowered
Caption = 'X position'
ParentShowHint = False
ShowHint = True
TabOrder = 9
OnDblClick = DragPanelDblClick
OnMouseDown = DragPanelMouseDown
OnMouseMove = DragPanelMouseMove
OnMouseUp = DragPanelMouseUp
end
object pnlYpos: TPanel
Left = 4
Top = 52
Width = 61
Height = 21
Cursor = crHandPoint
Hint = 'Click and drag to change value'
BevelOuter = bvLowered
Caption = 'Y position'
ParentShowHint = False
ShowHint = True
TabOrder = 10
OnDblClick = DragPanelDblClick
OnMouseDown = DragPanelMouseDown
OnMouseMove = DragPanelMouseMove
OnMouseUp = DragPanelMouseUp
end
object pnlAngle: TPanel
Left = 4
Top = 76
Width = 61
Height = 21
Cursor = crHandPoint
Hint = 'Click and drag to change value'
BevelOuter = bvLowered
Caption = 'Rotation'
ParentShowHint = False
ShowHint = True
TabOrder = 11
OnDblClick = DragPanelDblClick
OnMouseDown = DragPanelMouseDown
OnMouseMove = DragPanelMouseMove
OnMouseUp = DragPanelMouseUp
end
end
object TabSheet2: TTabSheet
Caption = 'Rendering'
@ -338,48 +359,40 @@ object AdjustForm: TAdjustForm
AutoSize = False
Caption = 'Background'
end
object btnGamma: TSpeedButton
object pnlMasterScale: TPanel
Left = 232
Top = 76
Width = 73
Height = 21
Cursor = crHandPoint
Hint = 'Click and drag to change value'
Alignment = taLeftJustify
BevelOuter = bvLowered
Caption = ' Master Scale'
ParentShowHint = False
ShowHint = True
TabOrder = 9
OnDblClick = DragPanelDblClick
OnMouseDown = DragPanelMouseDown
OnMouseMove = DragPanelMouseMove
OnMouseUp = DragPanelMouseUp
end
object pnlGamma: TPanel
Left = 4
Top = 4
Width = 61
Height = 21
Hint = 'Reset value'
Cursor = crHandPoint
Hint = 'Click and drag to change value'
BevelOuter = bvLowered
Caption = 'Gamma'
Flat = True
ParentShowHint = False
ShowHint = True
OnClick = btnGammaClick
end
object btnBritghtness: TSpeedButton
Left = 4
Top = 28
Width = 61
Height = 21
Hint = 'Reset value'
Caption = 'Brightness'
Flat = True
ParentShowHint = False
ShowHint = True
OnClick = btnBritghtnessClick
end
object btnVibrancy: TSpeedButton
Left = 4
Top = 52
Width = 61
Height = 21
Hint = 'Reset value'
Caption = 'Vibrancy'
Flat = True
ParentShowHint = False
ShowHint = True
OnClick = btnVibrancyClick
end
object Label1: TLabel
Left = 236
Top = 80
Width = 62
Height = 13
Caption = 'Master Scale'
TabOrder = 10
OnDblClick = DragPanelDblClick
OnMouseDown = DragPanelMouseDown
OnMouseMove = DragPanelMouseMove
OnMouseUp = DragPanelMouseUp
end
object scrollGamma: TScrollBar
Left = 72
@ -481,6 +494,40 @@ object AdjustForm: TAdjustForm
OnExit = editPPUValidate
OnKeyPress = editPPUKeyPress
end
object pnlBrightness: TPanel
Left = 4
Top = 28
Width = 61
Height = 21
Cursor = crHandPoint
Hint = 'Click and drag to change value'
BevelOuter = bvLowered
Caption = 'Brightness'
ParentShowHint = False
ShowHint = True
TabOrder = 11
OnDblClick = DragPanelDblClick
OnMouseDown = DragPanelMouseDown
OnMouseMove = DragPanelMouseMove
OnMouseUp = DragPanelMouseUp
end
object pnlVibrancy: TPanel
Left = 4
Top = 52
Width = 61
Height = 21
Cursor = crHandPoint
Hint = 'Click and drag to change value'
BevelOuter = bvLowered
Caption = 'Vibrancy'
ParentShowHint = False
ShowHint = True
TabOrder = 12
OnDblClick = DragPanelDblClick
OnMouseDown = DragPanelMouseDown
OnMouseMove = DragPanelMouseMove
OnMouseUp = DragPanelMouseUp
end
end
object TabSheet3: TTabSheet
Caption = 'Gradient'
@ -499,7 +546,6 @@ object AdjustForm: TAdjustForm
Height = 21
Hint = 'Click for menu'
Caption = 'Rotate'
Flat = True
ParentShowHint = False
ShowHint = True
OnClick = btnMenuClick
@ -682,7 +728,7 @@ object AdjustForm: TAdjustForm
object GradientImage: TImage
Left = 1
Top = 1
Width = 380
Width = 378
Height = 47
Cursor = crHandPoint
Align = alClient

View File

@ -63,13 +63,6 @@ type
TabSheet3: TTabSheet;
scrollAngle: TScrollBar;
txtAngle: TEdit;
btnZoom: TSpeedButton;
btnXpos: TSpeedButton;
btnYpos: TSpeedButton;
btnAngle: TSpeedButton;
btnGamma: TSpeedButton;
btnBritghtness: TSpeedButton;
btnVibrancy: TSpeedButton;
GradientPnl: TPanel;
GradientImage: TImage;
lblVal: TLabel;
@ -130,8 +123,15 @@ type
Bevel2: TBevel;
N8: TMenuItem;
mnuInstantPreview: TMenuItem;
Label1: TLabel;
editPPU: TEdit;
pnlMasterScale: TPanel;
pnlZoom: TPanel;
pnlXpos: TPanel;
pnlYpos: TPanel;
pnlAngle: TPanel;
pnlGamma: TPanel;
pnlBrightness: TPanel;
pnlVibrancy: TPanel;
procedure FormCreate(Sender: TObject);
procedure FormClose(Sender: TObject; var Action: TCloseAction);
procedure FormDestroy(Sender: TObject);
@ -188,13 +188,6 @@ type
procedure txtAngleEnter(Sender: TObject);
procedure txtAngleExit(Sender: TObject);
procedure txtAngleKeyPress(Sender: TObject; var Key: Char);
procedure btnZoomClick(Sender: TObject);
procedure btnXposClick(Sender: TObject);
procedure btnYposClick(Sender: TObject);
procedure btnAngleClick(Sender: TObject);
procedure btnGammaClick(Sender: TObject);
procedure btnBritghtnessClick(Sender: TObject);
procedure btnVibrancyClick(Sender: TObject);
// --Z-- // gradient functions
procedure cmbPaletteChange(Sender: TObject);
@ -252,6 +245,14 @@ type
procedure editPPUKeyPress(Sender: TObject; var Key: Char);
procedure editPPUValidate(Sender: TObject);
procedure DragPanelMouseDown(Sender: TObject; Button: TMouseButton;
Shift: TShiftState; X, Y: Integer);
procedure DragPanelMouseMove(Sender: TObject; Shift: TShiftState; X,
Y: Integer);
procedure DragPanelMouseUp(Sender: TObject; Button: TMouseButton;
Shift: TShiftState; X, Y: Integer);
procedure DragPanelDblClick(Sender: TObject);
private
Resetting: boolean;
Render: TRenderer;
@ -260,6 +261,11 @@ type
cp: TControlPoint;
pnlDragMode, pnlDragged, pnlMM: boolean;
pnlDragPos, pnlDragOld: integer;
pnlDragValue: double;
mousepos: TPoint;
private // gradient stuff
Palette, BackupPal: TColorMap;
tmpBackupPal: TColorMap;
@ -353,7 +359,8 @@ begin
scrollBrightness.Position := trunc(cp.Brightness * 100);
scrollVibrancy.Position := trunc(cp.vibrancy * 100);
scrollZoom.Position := trunc(cp.zoom * 1000);
ScrollAngle.Position := Trunc(cp.FAngle * 18000.0 / PI) mod scrollAngle.Max;
// ScrollAngle.Position := Trunc(cp.FAngle * 18000.0 / PI) mod scrollAngle.Max;
scrollAngle.Position := Trunc((cp.FAngle + pi)* 18000.0 / PI) mod 36000;
if (abs(cp.Center[0]) < 1000) and (abs(cp.Center[1]) < 1000) then begin
scrollCenterX.Position := trunc(cp.Center[0] * 1000);
@ -926,7 +933,7 @@ end;
procedure TAdjustForm.scrollAngleChange(Sender: TObject);
begin
cp.FAngle := scrollAngle.Position * PI / 18000.0;
cp.FAngle := (scrollAngle.Position - 18000) * PI / 18000.0;
txtAngle.text := FloatToStr(cp.FAngle * 180 / PI);
DrawPreview;
end;
@ -950,9 +957,9 @@ begin
begin
key := #0;
try
v := Trunc(StrToFloat(txtAngle.Text) * 100) mod (scrollAngle.Max*2);
if v > scrollAngle.Max then v := v - scrollAngle.Max*2
else if v < scrollAngle.Min then v := v + scrollAngle.Max*2;
v := Trunc(StrToFloat(txtAngle.Text) * 100) mod scrollAngle.Max - 18000;
//if v > scrollAngle.Max then v := v - scrollAngle.Max*2
if v < scrollAngle.Min then v := v + scrollAngle.Max;
ScrollAngle.Position := v;
UpdateFlame;
EditBoxValue := txtAngle.Text;
@ -977,48 +984,6 @@ begin
end;
end;
procedure TAdjustForm.btnZoomClick(Sender: TObject);
begin
scrollZoom.Position := 0;
UpdateFlame;
end;
procedure TAdjustForm.btnXposClick(Sender: TObject);
begin
scrollCenterX.Position := 0;
UpdateFlame;
end;
procedure TAdjustForm.btnYposClick(Sender: TObject);
begin
scrollCenterY.Position := 0;
UpdateFlame;
end;
procedure TAdjustForm.btnAngleClick(Sender: TObject);
begin
scrollAngle.Position := 0;
UpdateFlame;
end;
procedure TAdjustForm.btnGammaClick(Sender: TObject);
begin
scrollGamma.Position := 400;
UpdateFlame;
end;
procedure TAdjustForm.btnBritghtnessClick(Sender: TObject);
begin
scrollBrightness.Position := 400;
UpdateFlame;
end;
procedure TAdjustForm.btnVibrancyClick(Sender: TObject);
begin
scrollVibrancy.Position := 100;
UpdateFlame;
end;
// --Z-- // gradient stuff implementation --------------------------------------
procedure TAdjustForm.Apply;
@ -1909,5 +1874,169 @@ begin
UpdateFlame;
end;
// -----------------------------------------------------------------------------
procedure TAdjustForm.DragPanelMouseDown(Sender: TObject;
Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
begin
if Button <> mbLeft then exit;
if (Sender = pnlMasterScale) then
pnlDragValue := cp.pixels_per_unit / 10
else if (Sender = pnlZoom) then
pnlDragValue := cp.zoom
else if (Sender = pnlXpos) then
pnlDragValue := cp.Center[0]
else if (Sender = pnlYpos) then
pnlDragValue := cp.Center[1]
else if (Sender = pnlAngle) then
pnlDragValue := cp.FAngle
else if (Sender = pnlGamma) then
pnlDragValue := cp.gamma
else if (Sender = pnlBrightness) then
pnlDragValue := cp.brightness
else if (Sender = pnlVibrancy) then
pnlDragValue := cp.vibrancy
else assert(false);
pnlDragMode := true;
pnlDragPos := 0;
pnlDragOld := x;
pnlMM := false;
SetCaptureControl(TControl(Sender));
Screen.Cursor := crHSplit;
GetCursorPos(mousepos); // hmmm
pnlDragged := false;
end;
procedure TAdjustForm.DragPanelMouseMove(Sender: TObject; Shift: TShiftState;
X, Y: Integer);
var
v: double;
begin
if pnlMM then // hack: to skip MouseMove event
begin
pnlMM:=false;
end
else
if pnlDragMode and (x <> pnlDragOld) then
begin
Inc(pnlDragPos, x - pnlDragOld);
if GetKeyState(VK_MENU) < 0 then v := 100000
else if GetKeyState(VK_CONTROL) < 0 then v := 10000
else if GetKeyState(VK_SHIFT) < 0 then v := 100
else v := 1000;
v := Round6(pnlDragValue + pnlDragPos / v);
SetCursorPos(MousePos.x, MousePos.y); // hmmm
pnlMM:=true;
if (Sender = pnlMasterScale) then
begin
v := v * 10;
if v <= 0.1 then v := 0.1;
cp.pixels_per_unit := v;
editPPU.Text := FloatToStr(v);
end
else if (Sender = pnlZoom) then
begin
scrollZoom.Position := trunc(v * 1000);
end
else if (Sender = pnlXpos) then
begin
scrollCenterX.Position := trunc(v * 1000);
end
else if (Sender = pnlYpos) then
begin
scrollCenterY.Position := trunc(v * 1000);
end
else if (Sender = pnlAngle) then
begin
scrollAngle.Position := Trunc((v + pi)* 18000.0 / PI) mod 36000;
end
else if (Sender = pnlGamma) then
begin
scrollGamma.Position := trunc(v * 100);
end
else if (Sender = pnlBrightness) then
begin
scrollBrightness.Position := trunc(v * 100);
end
else if (Sender = pnlVibrancy) then
begin
scrollVibrancy.Position := trunc(v * 100);
end;
//pEdit^.Text := FloatToStr(v);
//pEdit.Refresh;
pnlDragged := True;
DrawPreview;
end;
end;
procedure TAdjustForm.DragPanelMouseUp(Sender: TObject; Button: TMouseButton;
Shift: TShiftState; X, Y: Integer);
begin
if Button <> mbLeft then exit;
if pnlDragMode then
begin
SetCaptureControl(nil);
pnlDragMode := false;
Screen.Cursor := crDefault;
if pnlDragged then
begin
UpdateFlame;
pnlDragged := False;
end;
end;
end;
procedure TAdjustForm.DragPanelDblClick(Sender: TObject);
var
pValue: ^double;
begin
if (Sender = pnlMasterScale) then
begin
pValue := @cp.pixels_per_unit;
if pValue^ = 32 then exit;
pValue^ := 32;
editPPU.Text := FloatToStr(pValue^);
end
else if (Sender = pnlZoom) then
begin
scrollZoom.Position := 0;
end
else if (Sender = pnlXpos) then
begin
scrollCenterX.Position := 0;
end
else if (Sender = pnlYpos) then
begin
scrollCenterY.Position := 0;
end
else if (Sender = pnlAngle) then
begin
scrollAngle.Position := 18000;
end
else if (Sender = pnlGamma) then
begin
scrollGamma.Position := 400;
end
else if (Sender = pnlBrightness) then
begin
scrollBrightness.Position := 400;
end
else if (Sender = pnlVibrancy) then
begin
scrollVibrancy.Position := 100;
end
else assert(false);
UpdateFlame;
end;
end.

View File

@ -15,15 +15,7 @@ type
nrbatches: integer;
batchcounter: Pinteger;
BucketWidth: Int64;
BucketHeight: Int64;
{
bounds: array[0..3] of extended;
size: array[0..1] of extended;
RotationCenter: array[0..1] of extended;
}
FinalXform: ^TXform;
UseFinalXform: boolean;
BucketWidth, BucketHeight: integer;
camX0, camY0, camW, camH,
bws, bhs, cosa, sina, rcX, rcY: double;
@ -37,10 +29,8 @@ type
procedure Execute; override;
procedure AddPointsToBuckets(const points: TPointsArray);
procedure AddPointsToBuckets(const points: TPointsArray);
procedure AddPointsToBucketsAngle(const points: TPointsArray);
procedure AddPointsWithFX(const points: TPointsArray);
procedure AddPointsWithAngleFX(const points: TPointsArray);
end;
implementation
@ -75,36 +65,6 @@ begin
end;
end;
procedure TBucketFillerThread.AddPointsWithFX(const points: TPointsArray);
var
i: integer;
px, py: double;
Bucket: PBucket;
MapColor: PColorMapColor;
begin
try
for i := SUB_BATCH_SIZE - 1 downto 0 do begin
// if FStop then Exit;
FinalXform.NextPoint(points[i]);
px := points[i].x - camX0;
if (px < 0) or (px > camW) then continue;
py := points[i].y - camY0;
if (py < 0) or (py > camH) then continue;
Bucket := @TBucketArray(buckets^)[Round(bws * px) + Round(bhs * py) * BucketWidth];
MapColor := @ColorMap[Round(points[i].c * 255)];
Inc(Bucket.Red, MapColor.Red);
Inc(Bucket.Green, MapColor.Green);
Inc(Bucket.Blue, MapColor.Blue);
Inc(Bucket.Count);
end;
except
end
end;
///////////////////////////////////////////////////////////////////////////////
procedure TBucketFillerThread.AddPointsToBucketsAngle(const points: TPointsArray);
var
@ -131,38 +91,10 @@ begin
end;
end;
procedure TBucketFillerThread.AddPointsWithAngleFX(const points: TPointsArray);
var
i: integer;
px, py: double;
Bucket: PBucket;
MapColor: PColorMapColor;
begin
try
for i := SUB_BATCH_SIZE - 1 downto 0 do
begin
// if FStop then Exit;
FinalXform.NextPoint(points[i]);
px := points[i].x * cosa + points[i].y * sina + rcX;
if (px < 0) or (px > camW) then continue;
py := points[i].y * cosa - points[i].x * sina + rcY;
if (py < 0) or (py > camH) then continue;
Bucket := @TBucketArray(buckets^)[Round(bws * px) + Round(bhs * py) * BucketWidth];
MapColor := @ColorMap[Round(points[i].c * 255)];
Inc(Bucket.Red, MapColor.Red);
Inc(Bucket.Green, MapColor.Green);
Inc(Bucket.Blue, MapColor.Blue);
Inc(Bucket.Count);
end;
except
end
end;
///////////////////////////////////////////////////////////////////////////////
constructor TBucketFillerThread.Create(cp: TControlPoint);
var
i, n: integer;
begin
inherited Create(True);
Self.FreeOnTerminate := True;
@ -171,8 +103,7 @@ begin
SetLength(Points, SUB_BATCH_SIZE);
FinalXForm := @fcp.xform[fcp.NumXForms];
UseFinalXForm := fcp.finalXformEnabled and fcp.HasFinalXform;
fcp.Prepare;
end;
///////////////////////////////////////////////////////////////////////////////
@ -191,18 +122,10 @@ var
begin
inherited;
if FCP.FAngle = 0 then begin
if UseFinalXForm then
AddPointsProc := AddPointsWithFX
else
AddPointsProc := AddPointsToBuckets;
end
else begin
if UseFinalXForm then
AddPointsProc := AddPointsWithAngleFX
else
AddPointsProc := AddPointsToBucketsAngle;
end;
if FCP.FAngle = 0 then
AddPointsProc := AddPointsToBuckets
else
AddPointsProc := AddPointsToBucketsAngle;
bc := 0;
while (not Terminated) and (bc < Nrbatches) do begin

View File

@ -24,8 +24,6 @@ uses
Classes, Windows, Cmap, XForm, XFormMan;
const
EPS = 1E-10;
NXFORMS = 100;
SUB_BATCH_SIZE = 10000;
@ -84,17 +82,15 @@ type
TPointsArray = array of TCPpoint;
TPointsXYArray = array of TXYpoint;
T2Cpoint = record
x, y, c1, c2: double;
end;
P2Cpoint = ^T2Cpoint;
T2CPointsArray = array of T2Cpoint;
TControlPoint = class
public
xform: array[0..NXFORMS] of TXForm;
// finalxform: TXForm;
finalXform: ^TXForm;
finalXformEnabled: boolean;
useFinalXform: boolean;
variation: TVariation;
cmap: TColorMap;
cmapindex: integer;
@ -129,7 +125,6 @@ type
FAngle: Double;
FTwoColorDimensions: Boolean;
private
procedure PreparePropTable;
function getppux: double;
function getppuy: double;
@ -154,7 +149,8 @@ type
procedure IterateXYC(NrPoints: integer; var Points: TPointsArray);
procedure IterateXYCC(NrPoints: integer; var Points: T2CPointsArray);
procedure Testiterate(NrPoints: integer; var Points: TPointsArray);
procedure Prepare;
// procedure Testiterate(NrPoints: integer; var Points: TPointsArray);
function Clone: TControlPoint;
procedure Copy(cp1: TControlPoint);
@ -215,7 +211,6 @@ begin
for i := 0 to NXFORMS do begin
xform[i] := TXForm.Create;
end;
// finalxform := TXForm.Create;
pulse[0][0] := 0;
pulse[0][1] := 60;
@ -255,6 +250,8 @@ begin
white_level := 200;
FTwoColorDimensions := False;
finalXformEnabled := false;
end;
destructor TControlPoint.Destroy;
@ -263,14 +260,13 @@ var
begin
for i := 0 to NXFORMS - 1 do
xform[i].Free;
// finalxform.Free;
inherited;
end;
procedure TControlPoint.PreparePropTable;
procedure TControlPoint.Prepare;
var
i: Integer;
i, n: Integer;
propsum: double;
LoopValue: double;
j: integer;
@ -279,7 +275,12 @@ begin
SetLength(PropTable, PROP_TABLE_SIZE);
totValue := 0;
for i := 0 to NXFORMS - 1 do begin
n := NumXforms;
finalXform := @xform[n];
finalXform.Prepare;
useFinalXform := FinalXformEnabled and HasFinalXform;
for i := 0 to n - 1 do begin
xform[i].Prepare;
totValue := totValue + xform[i].density;
end;
@ -290,10 +291,11 @@ begin
repeat
inc(j);
propsum := propsum + xform[j].density;
until (propsum > LoopValue) or (j = NXFORMS - 1);
until (propsum > LoopValue) or (j = n - 1);
PropTable[i] := @xform[j];
LoopValue := LoopValue + TotValue / PROP_TABLE_SIZE;
end;
end;
(*
@ -534,25 +536,33 @@ procedure TControlPoint.IterateXY(NrPoints: integer; var Points: TPointsXYArray)
var
i: Integer;
px, py: double;
CurrentPoint: PXYPoint;
pPoint: PXYPoint;
begin
px := 2 * random - 1;
py := 2 * random - 1;
PreparePropTable;
for i := 0 to NXFORMS - 1 do
xform[i].prepare;
// PreparePropTable;
// for i := 0 to NXFORMS do xform[i].prepare;
try
for i := 0 to FUSE do
PropTable[Random(PROP_TABLE_SIZE)].NextPointXY(px,py);
pPoint := @Points[0];
if UseFinalXform then
for i := 0 to NrPoints - 1 do begin
PropTable[Random(PROP_TABLE_SIZE)].NextPointXY(px,py);
CurrentPoint := @Points[i];
CurrentPoint.X := px;
CurrentPoint.Y := py;
pPoint^.X := px;
pPoint^.Y := py;
finalXform^.NextPointXY(pPoint^.X, pPoint^.y);
Inc(pPoint);
end
else
for i := 0 to NrPoints - 1 do begin
PropTable[Random(PROP_TABLE_SIZE)].NextPointXY(px,py);
pPoint.X := px;
pPoint.Y := py;
Inc(pPoint);
end
except
on EMathError do begin
@ -562,31 +572,53 @@ begin
end;
procedure TControlPoint.IterateXYC(NrPoints: integer; var Points: TPointsArray);
{ Variations for Draves conpatibility }
var
i: Integer;
px, py, pc: double;
CurrentPoint: PCPPoint;
p: TCPPoint;
pPoint: PCPPoint;
begin
px := 2 * random - 1;
py := 2 * random - 1;
pc := random;
{$if false}
p.x := 2 * random - 1;
p.y := 2 * random - 1;
p.c := random;
{$else}
asm
fld1
call System.@RandExt
fadd st, st
fsub st, st(1)
fstp qword ptr [p.x]
call System.@RandExt
fadd st, st
fsubrp st(1), st
fstp qword ptr [p.y]
call System.@RandExt
fstp qword ptr [p.c]
end;
{$ifend}
PreparePropTable;
for i := 0 to NXFORMS - 1 do
xform[i].prepare;
// PreparePropTable;
// for i := 0 to NXFORMS do xform[i].prepare;
try
for i := 0 to FUSE do
PropTable[Random(PROP_TABLE_SIZE)].NextPoint(px,py,pc);
PropTable[Random(PROP_TABLE_SIZE)].NextPoint(p);
pPoint := @Points[0];
if UseFinalXform then
for i := 0 to NrPoints - 1 do begin
PropTable[Random(PROP_TABLE_SIZE)].NextPoint(px,py,pc);
CurrentPoint := @Points[i];
CurrentPoint.X := px;
CurrentPoint.Y := py;
CurrentPoint.C := pc;
PropTable[Random(PROP_TABLE_SIZE)].NextPoint(p);
finalXform^.NextPointTo(p, pPoint^);
Inc(pPoint);
end
else
for i := 0 to NrPoints - 1 do begin
PropTable[Random(PROP_TABLE_SIZE)].NextPoint(p);
pPoint^.x := p.x;
pPoint^.y := p.y;
pPoint^.c := p.c;
Inc(pPoint);
end
except
on EMathError do begin
@ -596,6 +628,7 @@ begin
end;
///////////////////////////////////////////////////////////////////////////////
{
procedure TControlPoint.Testiterate(NrPoints: integer; var Points: TPointsArray);
var
i: Integer;
@ -640,35 +673,46 @@ begin
end
end;
end;
}
procedure TControlPoint.IterateXYCC(NrPoints: integer; var Points: T2CPointsArray);
var
i: Integer;
px, py, pc1, pc2: double;
//px, py, pc1, pc2: double;
p: T2CPoint;
CurrentPoint: P2Cpoint;
begin
px := 2 * random - 1;
py := 2 * random - 1;
pc1 := random;
pc2 := random;
p.x := 2 * random - 1;
p.y := 2 * random - 1;
p.c1 := random;
p.c2 := random;
PreparePropTable;
for i := 0 to NXFORMS - 1 do
xform[i].prepare;
// PreparePropTable;
// for i := 0 to NXFORMS do xform[i].prepare;
try
for i := 0 to FUSE do
PropTable[Random(PROP_TABLE_SIZE)].NextPoint2C(px, py, pc1, pc2);
PropTable[Random(PROP_TABLE_SIZE)].NextPoint2C(p);//px, py, pc1, pc2);
CurrentPoint := @Points[0];
if UseFinalXform then
for i := 0 to NrPoints - 1 do begin
PropTable[Random(PROP_TABLE_SIZE)].NextPoint2C(px, py, pc1, pc2);
CurrentPoint := @Points[i];
CurrentPoint.X := px;
CurrentPoint.Y := py;
CurrentPoint.C1 := pc1;
CurrentPoint.C2 := pc2;
PropTable[Random(PROP_TABLE_SIZE)].NextPoint2C(p);//px, py, pc1, pc2);
CurrentPoint.X := p.x;
CurrentPoint.Y := p.y;
CurrentPoint.C1 := p.c1;
CurrentPoint.C2 := p.c2;
finalXform^.NextPoint2C(CurrentPoint^);
Inc(CurrentPoint);
end
else
for i := 0 to NrPoints - 1 do begin
PropTable[Random(PROP_TABLE_SIZE)].NextPoint2C(p);
CurrentPoint.X := p.x;
CurrentPoint.Y := p.y;
CurrentPoint.C1 := p.c1;
CurrentPoint.C2 := p.c2;
Inc(CurrentPoint);
end
except
on EMathError do begin
@ -680,7 +724,7 @@ end;
function TControlPoint.BlowsUp(NrPoints: integer): boolean;
var
i: Integer;
i, n: Integer;
px, py: double;
minx, maxx, miny, maxy: double;
Points: TPointsXYArray;
@ -688,25 +732,25 @@ var
begin
Result := false;
SetLength(Points, SUB_BATCH_SIZE);
n := min(SUB_BATCH_SIZE, NrPoints);
SetLength(Points, n);
px := 2 * random - 1;
py := 2 * random - 1;
PreparePropTable;
for i := 0 to NXFORMS - 1 do
xform[i].prepare;
Prepare;
try
for i := 0 to FUSE do
PropTable[Random(PROP_TABLE_SIZE)].NextPointXY(px,py);
for i := 0 to NrPoints - 1 do begin
CurrentPoint := @Points[0];
for i := 0 to n-1 do begin
PropTable[Random(PROP_TABLE_SIZE)].NextPointXY(px,py);
CurrentPoint := @Points[i];
CurrentPoint.X := px;
CurrentPoint.Y := py;
Inc(CurrentPoint);
// random CPs don't use finalXform...
end;
except
on EMathError do begin
@ -720,7 +764,7 @@ begin
maxx := -1E10;
miny := 1E10;
maxy := -1E10;
for i := 0 to SUB_BATCH_SIZE - 1 do begin
for i := 0 to n-1 do begin
minx := min(minx, Points[i].x);
maxx := max(maxx, Points[i].x);
miny := min(miny, Points[i].y);
@ -1085,7 +1129,7 @@ end;
procedure TControlPoint.CalcBoundbox;
var
Points: TPointsArray;
Points: TPointsXYArray;
i, j: integer;
deltax, minx, maxx: double;
cntminx, cntmaxx: integer;
@ -1108,7 +1152,18 @@ begin
1: iterateXYC(SUB_BATCH_SIZE, points);
end;
}
IterateXYC(SUB_BATCH_SIZE, points);
Prepare;
IterateXY(SUB_BATCH_SIZE, points);
{ if finalXformEnabled and HasFinalXform then begin
try
finalXform := @xform[NumXforms];
for i := 0 to SUB_BATCH_SIZE - 1 do
finalXform.NextPoint(points[i]);
except
end
end;}
LimitOutSidePoints := Round(0.05 * SUB_BATCH_SIZE);
@ -1678,12 +1733,9 @@ 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
(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);
(symmetry <> 1) or (vars[0] <> 1);
if Result = false then
begin
Result := Result or (vars[0] <> 1);
for i := 1 to NRVAR-1 do Result := Result or (vars[i] <> 0);
end
end;
end;

View File

@ -96,7 +96,7 @@ object EditForm: TEditForm
Left = 0
Top = 0
Hint = 'New blank flame'
Caption = 'Reset All'
Caption = 'New blank flame'
ImageIndex = 0
ParentShowHint = False
ShowHint = True
@ -252,16 +252,16 @@ object EditForm: TEditForm
ImageIndex = 14
Style = tbsSeparator
end
object tbEnableFinalXform: TToolButton
object tbVarPreview: TToolButton
Left = 332
Top = 0
Hint = 'Enable final transform'
Caption = 'Show Final Xform'
ImageIndex = 15
Hint = 'Show/hide variation preview'
Caption = 'Variation Preview'
ImageIndex = 14
ParentShowHint = False
ShowHint = True
Style = tbsCheck
OnClick = tbEnableFinalXformClick
OnClick = tbVarPreviewClick
end
object ToolButton3: TToolButton
Left = 357
@ -271,16 +271,16 @@ object EditForm: TEditForm
ImageIndex = 16
Style = tbsSeparator
end
object tbVarPreview: TToolButton
object tbEnableFinalXform: TToolButton
Left = 365
Top = 0
Hint = 'Show/hide variation preview'
Caption = 'Variation Preview'
ImageIndex = 14
Hint = 'Enable final transform'
Caption = 'Show Final Xform'
ImageIndex = 15
ParentShowHint = False
ShowHint = True
Style = tbsCheck
OnClick = tbVarPreviewClick
OnClick = tbEnableFinalXformClick
end
end
end
@ -1153,16 +1153,6 @@ object EditForm: TEditForm
end
object tabXForm: TTabSheet
Caption = 'Transform'
object lblWeight: TLabel
Left = 10
Top = 126
Width = 38
Height = 13
Hint = '"weight" is the probability of this transform to be applied'
Caption = 'Weight:'
ParentShowHint = False
ShowHint = True
end
object btnResetCoefs: TSpeedButton
Left = 8
Top = 76
@ -1294,6 +1284,24 @@ object EditForm: TEditForm
ShowHint = True
OnClick = btnSwapXformsClick
end
object pnlWeight: TPanel
Left = 8
Top = 122
Width = 88
Height = 21
Cursor = crHandPoint
Hint = '"Weight" is the probability of this transform to be applied'
Alignment = taLeftJustify
BevelOuter = bvLowered
Caption = ' Weight:'
ParentShowHint = False
ShowHint = True
TabOrder = 14
OnDblClick = DragPanelDblClick
OnMouseDown = DragPanelMouseDown
OnMouseMove = DragPanelMouseMove
OnMouseUp = DragPanelMouseUp
end
object txtA: TEdit
Left = 36
Top = 4
@ -1503,12 +1511,23 @@ object EditForm: TEditForm
Height = 100
Caption = 'Transform color'
TabOrder = 0
object Label29: TLabel
Left = 10
Top = 72
Width = 52
Height = 13
Caption = 'Symmetry:'
object pnlSymmetry: TPanel
Left = 8
Top = 70
Width = 73
Height = 21
Cursor = crHandPoint
Hint = 'Symmetry'
Alignment = taLeftJustify
BevelOuter = bvLowered
Caption = ' Symmetry:'
ParentShowHint = False
ShowHint = True
TabOrder = 3
OnDblClick = DragPanelDblClick
OnMouseDown = DragPanelMouseDown
OnMouseMove = DragPanelMouseMove
OnMouseUp = DragPanelMouseUp
end
object scrlXFormColor: TScrollBar
Left = 8
@ -1525,10 +1544,15 @@ object EditForm: TEditForm
object pnlXFormColor: TPanel
Left = 8
Top = 16
Width = 65
Width = 73
Height = 21
Cursor = crHandPoint
BevelOuter = bvLowered
TabOrder = 1
OnDblClick = DragPanelDblClick
OnMouseDown = DragPanelMouseDown
OnMouseMove = DragPanelMouseMove
OnMouseUp = DragPanelMouseUp
end
object txtXFormColor: TEdit
Left = 80
@ -1539,21 +1563,15 @@ object EditForm: TEditForm
OnExit = txtXFormColorExit
OnKeyPress = txtXFormColorKeyPress
end
object txtSymmetry: TComboBox
object txtSymmetry: TEdit
Left = 80
Top = 70
Width = 57
Height = 21
ItemHeight = 13
ItemIndex = 0
TabOrder = 3
TabOrder = 4
Text = '0'
OnExit = txtSymmetrySet
OnKeyPress = txtSymmetryKeyPress
OnSelect = txtSymmetrySet
Items.Strings = (
'0'
'1')
OnKeyPress = txtSymmetrKeyPress
end
end
object GroupBox2: TGroupBox
@ -1648,65 +1666,6 @@ object EditForm: TEditForm
Images = EditorTB
Left = 352
Top = 40
object mnuAutoZoom: TMenuItem
Caption = 'Auto Zoom'
Hint = 'Zoom to fit all triangles'
OnClick = mnuAutoZoomClick
end
object N1: TMenuItem
Caption = '-'
end
object mnuDelete: TMenuItem
Caption = 'Delete'
Hint = 'Delete selected triangle'
ImageIndex = 3
OnClick = mnuDeleteClick
end
object mnuDuplicate: TMenuItem
Caption = 'Duplicate'
Hint = 'Duplicate selected triangle'
ImageIndex = 2
OnClick = mnuDupClick
end
object mnuAdd: TMenuItem
Caption = 'Add'
Hint = 'Add new triangle'
ImageIndex = 1
OnClick = mnuAddClick
end
object N4: TMenuItem
Caption = '-'
end
object mnuFlipVertical: TMenuItem
Caption = 'Flip Vertical'
Hint = 'Flip triangle vertical'
ImageIndex = 11
OnClick = mnuFlipVerticalClick
end
object mnuFlipHorizontal: TMenuItem
Caption = 'Flip Horizontal'
Hint = 'Flip triangle horizontal'
ImageIndex = 10
OnClick = mnuFlipHorizontalClick
end
object N5: TMenuItem
Caption = '-'
end
object mnuVerticalFlipAll: TMenuItem
Caption = 'Flip All Vertical '
Hint = 'Flip all triangles vertical'
ImageIndex = 13
OnClick = mnuVerticalFlipAllClick
end
object mnuHorizintalFlipAll: TMenuItem
Caption = 'Flip All Horizontal'
Hint = 'Flip all triangles horizontal'
ImageIndex = 12
OnClick = mnuHorizintalFlipAllClick
end
object MenuItem1: TMenuItem
Caption = '-'
end
object mnuUndo: TMenuItem
Caption = 'Undo'
Enabled = False
@ -1723,6 +1682,45 @@ object EditForm: TEditForm
ShortCut = 16473
OnClick = mnuRedoClick
end
object N1: TMenuItem
Caption = '-'
end
object mnuAutoZoom: TMenuItem
Caption = 'Auto Zoom'
Hint = 'Zoom to fit all triangles'
ImageIndex = 20
OnClick = mnuAutoZoomClick
end
object mnuShowVarPreview: TMenuItem
Caption = 'Show Variation Preview'
Hint = 'Show/hide variation preview'
ImageIndex = 14
OnClick = tbVarPreviewClick
end
object N4: TMenuItem
Caption = '-'
end
object mnuAdd: TMenuItem
Caption = 'Add'
Hint = 'Add new triangle'
ImageIndex = 1
OnClick = mnuAddClick
end
object N5: TMenuItem
Caption = '-'
end
object mnuVerticalFlipAll: TMenuItem
Caption = 'Flip All Vertical '
Hint = 'Flip all triangles vertical'
ImageIndex = 13
OnClick = mnuVerticalFlipAllClick
end
object mnuHorizintalFlipAll: TMenuItem
Caption = 'Flip All Horizontal'
Hint = 'Flip all triangles horizontal'
ImageIndex = 12
OnClick = mnuHorizintalFlipAllClick
end
end
object QualityPopup: TPopupMenu
Images = MainForm.Buttons
@ -1754,11 +1752,11 @@ object EditForm: TEditForm
end
end
object EditorTB: TImageList
Left = 353
Top = 80
Left = 313
Top = 40
Bitmap = {
494C010110001300040010001000FFFFFFFFFF10FFFFFFFFFFFFFFFF424D3600
0000000000003600000028000000400000005000000001002000000000000050
494C010115001800040010001000FFFFFFFFFF10FFFFFFFFFFFFFFFF424D3600
0000000000003600000028000000400000006000000001002000000000000060
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
@ -1808,6 +1806,7 @@ object EditForm: TEditForm
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000054545400000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
@ -1815,6 +1814,7 @@ object EditForm: TEditForm
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000005454540000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
@ -1822,6 +1822,7 @@ object EditForm: TEditForm
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000545454000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
@ -1829,6 +1830,7 @@ object EditForm: TEditForm
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000054545400000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
@ -1888,6 +1890,130 @@ object EditForm: TEditForm
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000FFFFFF000000
00000000000000000000000000000000000000000000FFFFFF00000000000000
000000000000FFFFFF0000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000002424
2400242424002424240000000000000000000000000000000000242424002424
2400242424000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000FFFFFF000000
00000000000000000000000000000000000000000000FFFFFF00000000000000
000000000000FFFFFF0000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000002424
2400000000002424240000000000000000000000000000000000242424000000
0000242424000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000FFFFFF000000
0000000000000000000000000000000000000000000000000000FFFFFF000000
0000FFFFFF000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000002424
2400000000002424240000000000000000000000000000000000242424000000
0000242424000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000FFFFFF00FFFF
FF00FFFFFF00000000000000000000000000000000000000000000000000FFFF
FF00000000000000000000000000000000000000000000000000000000000000
0000000000000000000024242400000000000000000000000000000000002424
2400000000002424240000000000000000000000000000000000242424000000
0000242424000000000000000000000000000000000024242400000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000FFFFFF000000
0000000000000000000000000000000000000000000000000000FFFFFF000000
0000FFFFFF000000000000000000000000000000000000000000000000000000
0000000000002424240024242400000000000000000000000000000000002424
2400000000002424240000000000000000000000000000000000242424000000
0000242424000000000000000000000000000000000024242400242424000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000FFFFFF000000
00000000000000000000000000000000000000000000FFFFFF00000000000000
000000000000FFFFFF0000000000000000000000000000000000000000000000
0000242424002424240024242400000000000000000000000000000000002424
2400000000002424240000000000000000000000000000000000242424000000
0000242424000000000000000000000000000000000024242400242424002424
2400000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000FFFFFF00FFFF
FF00FFFFFF00FFFFFF00000000000000000000000000FFFFFF00000000000000
000000000000FFFFFF0000000000000000000000000000000000000000002424
2400242424000000000024242400000000000000000000000000000000002424
2400000000002424240000000000000000000000000000000000242424000000
0000242424000000000000000000000000000000000024242400000000002424
2400242424000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000242424002424
2400000000000000000024242400242424002424240024242400242424002424
2400000000002424240000000000000000000000000000000000242424000000
0000242424002424240024242400242424002424240024242400000000000000
0000242424002424240000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000005454
5400000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000024242400242424000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000002424240000000000000000000000000000000000242424000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000002424240024242400000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000545454000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000242424002424
2400000000000000000024242400242424002424240024242400242424002424
2400242424002424240000000000000000000000000000000000242424002424
2400242424002424240024242400242424002424240024242400000000000000
0000242424002424240000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000054545400000000000000
0000000000000000000000000000000000000000000000000000000000000000
00000000000000000000FFFFFF00C0C0C000C0C0C000FFFFFF00000000000000
0000000000000000000000000000000000000000000000000000000000002424
2400242424000000000024242400000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000024242400000000002424
2400242424000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000005454540000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000FFFFFF00FFFFFF00FFFFFF000000000000000000FFFFFF00FFFFFF00FFFF
FF00000000000000000000000000000000000000000000000000000000000000
0000242424002424240024242400000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000024242400242424002424
2400000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000FFFFFF00FFFFFF00FFFFFF000000000000000000FFFFFF00FFFFFF00FFFF
FF00000000000000000000000000000000000000000000000000000000000000
0000000000002424240024242400000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000024242400242424000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
00000000000000000000FFFFFF00C0C0C000C0C0C000FFFFFF00000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000024242400000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000024242400000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000008000800000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
@ -1901,8 +2027,96 @@ object EditForm: TEditForm
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000049004B00000000000000000049004B00000000000000
0000000000000000000000000000000000000000000000000000FFFFFF000000
00000000000000000000000000000000000000000000FFFFFF00000000000000
000000000000FFFFFF0000000000000000000000000000000000000000000000
0000000000000000000000000000000000008000800000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000004900
4B00000000000000000000000000000000000000000000000000000000000000
000049004B000000000000000000000000000000000000000000FFFFFF000000
00000000000000000000000000000000000000000000FFFFFF00000000000000
000000000000FFFFFF0000000000000000000000000000000000000000000000
0000000000000000000000000000000000008000800000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
00000000000000000000000000000000000049004B0000000000000000000000
0000000000000000000049004B00000000000000000049004B00000000000000
000000000000000000000000000049004B000000000000000000FFFFFF000000
0000000000000000000000000000000000000000000000000000FFFFFF000000
0000FFFFFF000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000008000800000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
000049004B000000000000000000000000000000000000000000000000004900
4B00000000000000000000000000000000000000000000000000FFFFFF00FFFF
FF00FFFFFF00000000000000000000000000000000000000000000000000FFFF
FF00000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000008000800000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
000000000000000000000000000000000000000000000000000049004B000000
0000000000000000000000000000000000000000000000000000000000000000
00000000000049004B0000000000000000000000000000000000FFFFFF000000
0000000000000000000000000000000000000000000000000000FFFFFF000000
0000FFFFFF000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000008000800000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
00000000000000000000000000000000000049004B0000000000000000000000
00000000000000000000EBEBEB00A0A0A000A0A0A000EBEBEB00000000000000
000000000000000000000000000049004B000000000000000000FFFFFF000000
00000000000000000000000000000000000000000000FFFFFF00000000000000
000000000000FFFFFF0000000000000000000000000000000000000000000000
0000000000000000000000000000000000008000800000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000EBEBEB00EBEBEB00EBEBEB000000000000000000EBEBEB00EBEBEB00EBEB
EB00000000000000000000000000000000000000000000000000FFFFFF00FFFF
FF00FFFFFF00FFFFFF00000000000000000000000000FFFFFF00000000000000
000000000000FFFFFF0000000000000000000000000000000000000000000000
0000000000000000000000000000000000008000800000000000000000000000
0000000000000000000000000000000000008000800080008000800080008000
8000000000000000000080008000800080008000800080008000800080008000
8000800080008000800080008000800080000000000000000000000000000000
0000EBEBEB00EBEBEB00EBEBEB000000000000000000EBEBEB00EBEBEB00EBEB
EB00000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000008000800000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
00000000000000000000000000000000000049004B0000000000000000000000
00000000000000000000EBEBEB00A0A0A000A0A0A000EBEBEB00000000000000
000000000000000000000000000049004B000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
000000000000000000000000000000000000000000000000000049004B000000
0000000000000000000000000000000000000000000000000000000000000000
00000000000049004B0000000000000000000000000000000000000000000000
0000000000000000000000000000008000000080000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
000049004B000000000000000000000000000000000000000000000000004900
4B00000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000008000000080000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000008000800000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
00000000000000000000000000000000000049004B0000000000000000000000
0000000000000000000049004B00000000000000000049004B00000000000000
000000000000000000000000000049004B000000000000000000000000000000
0000000000000080000000800000008000000080000000800000008000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000008000800000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
@ -1910,103 +2124,15 @@ object EditForm: TEditForm
0000000000000000000000000000000000000000000000000000000000004900
4B00000000000000000000000000000000000000000000000000000000000000
000049004B000000000000000000000000000000000000000000000000000000
0000000000000080000000800000008000000080000000800000008000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000008000800000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
00000000000000000000000000000000000049004B0000000000000000000000
0000000000000000000049004B00000000000000000049004B00000000000000
000000000000000000000000000049004B000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000008000800000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
000049004B000000000000000000000000000000000000000000000000004900
4B00000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000008000800000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
000000000000000000000000000000000000000000000000000049004B000000
0000000000000000000000000000000000000000000000000000000000000000
00000000000049004B0000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000008000800000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
00000000000000000000000000000000000049004B0000000000000000000000
00000000000000000000EBEBEB00A0A0A000A0A0A000EBEBEB00000000000000
000000000000000000000000000049004B000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000008000800000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000EBEBEB00EBEBEB00EBEBEB000000000000000000EBEBEB00EBEBEB00EBEB
EB00000000000000000000000000000000000000000000000000FFFFFF000000
00000000000000000000000000000000000000000000FFFFFF00000000000000
000000000000FFFFFF0000000000000000000000000000000000000000000000
0000000000000000000000000000000000008000800000000000000000000000
0000000000000000000000000000000000008000800080008000800080008000
8000000000000000000080008000800080008000800080008000800080008000
8000800080008000800080008000800080000000000000000000000000000000
0000EBEBEB00EBEBEB00EBEBEB000000000000000000EBEBEB00EBEBEB00EBEB
EB00000000000000000000000000000000000000000000000000FFFFFF000000
00000000000000000000000000000000000000000000FFFFFF00000000000000
000000000000FFFFFF0000000000000000000000000000000000000000000000
0000000000000000000000000000000000008000800000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
00000000000000000000000000000000000049004B0000000000000000000000
00000000000000000000EBEBEB00A0A0A000A0A0A000EBEBEB00000000000000
000000000000000000000000000049004B000000000000000000FFFFFF000000
0000000000000000000000000000000000000000000000000000FFFFFF000000
0000FFFFFF000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
000000000000000000000000000000000000000000000000000049004B000000
0000000000000000000000000000000000000000000000000000000000000000
00000000000049004B0000000000000000000000000000000000FFFFFF00FFFF
FF00FFFFFF00000000000000000000000000000000000000000000000000FFFF
FF00000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
000049004B000000000000000000000000000000000000000000000000004900
4B00000000000000000000000000000000000000000000000000FFFFFF000000
0000000000000000000000000000000000000000000000000000FFFFFF000000
0000FFFFFF000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000008000800000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
00000000000000000000000000000000000049004B0000000000000000000000
0000000000000000000049004B00000000000000000049004B00000000000000
000000000000000000000000000049004B000000000000000000FFFFFF000000
00000000000000000000000000000000000000000000FFFFFF00000000000000
000000000000FFFFFF0000000000000000000000000000000000000000000000
0000000000000000000000000000000000008000800000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000004900
4B00000000000000000000000000000000000000000000000000000000000000
000049004B000000000000000000000000000000000000000000FFFFFF00FFFF
FF00FFFFFF00FFFFFF00000000000000000000000000FFFFFF00000000000000
000000000000FFFFFF0000000000000000000000000000000000000000000000
0000000000000000000000000000000000008000800000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000049004B00000000000000000049004B00000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000008000000080000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000008000800000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
@ -2014,7 +2140,7 @@ object EditForm: TEditForm
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000008000000080000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
@ -2400,16 +2526,20 @@ object EditForm: TEditForm
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
000000000000000000000000000000000000424D3E000000000000003E000000
2800000040000000500000000100010000000000800200000000000000000000
000000000000000000000000FFFFFF0000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
00000000000000000000000000000000FF7FFFFFFFFFFFFFFF7FFFFFFDBFE1B7
FF7FFFFFEFF7EDA7E00FF3E77DBEED97E007E1E7F7EFE1B7FF63C0E7DC3BFFFF
FF73F3E7700E8F11FF73F3E7E0078F11FB730000E0078F11F363F3E7700E8383
E007F3E7DC3B83C7E00FF1C7F7EF8383F37FF80F7DBE8111FB7FFC1FEFF78111
FF7FFFFFFDBF8111FF7FFFFFFFFFFFFFFFFFFFFFFFFFFFFFF0070001FEFF8003
2800000040000000600000000100010000000000000300000000000000000000
000000000000000000000000FFFFFF00FFFF000000000000AAAB000000000000
FFFD000000000000BFFF000000000000FFFD000000000000B80F000000000000
FB9D000000000000BB3F000000000000FA7D000000000000B8FF000000000000
F9FD000000000000BBFF000000000000FFFD000000000000BFFF000000000000
D555000000000000FFFF0000000000008F11FFFFFFFFFFFF8F11FFE3C7FFFEFF
8F11FFE3C7FFFFFF8383FFE3C7FFFEFF83C7FDE3C7BFFFFF8383F9E3C79FFEFF
8111F1E3C78FFFFF8111E1E3C787AA028111C003C003FEE7FFFF8003C001FECF
FC3FC003C003FE9FF00FE1FFFF87FE3FE007F1FFFF8FFE7FE007F9FFFF9FFEFF
F00FFDFFFFBFFFFFFC3FFFFFFFFFFEFFFF7FFFFFFFFF8F11FF7FFFFFFDBF8F11
FF7FFFFFEFF78F11E00FF3E77DBE8383E007E1E7F7EF83C7FF63C0E7DC3B8383
FF73F3E7700E8111FF73F3E7E0078111FB730000E0078111F363F3E7700EFFFF
E007F3E7DC3BFE7FE00FF1C7F7EFFE7FF37FF80F7DBEF81FFB7FFC1FEFF7F81F
FF7FFFFFFDBFFE7FFF7FFFFFFFFFFE7FFFFFFFFFFFFFFFFFF0070001FEFF8003
F9F79FFD7FFDCFE7FCF7C8053EF9E7CFF277E4F51FF1F39FEF37F2754EE5F93F
EF97F93567CDFC7FDFC7FC95729DFEFFDFE7FE45793D5555DFF7FF25729DFEFF
DFFFFF9567CDFC7FEFC3FFCD4EE5F93FEFF3FFE51FF1F39FF3CBFFF13EF9E7CF
@ -2424,4 +2554,62 @@ object EditForm: TEditForm
C03FF3FFFFCFDFDFFFFFF3FFFFEFFFFF00000000000000000000000000000000
000000000000}
end
object TrianglePopup: TPopupMenu
AutoPopup = False
Images = EditorTB
Left = 353
Top = 73
object mnuReset: TMenuItem
Caption = 'Reset'
Hint = 'Reset triangle position'
ImageIndex = 19
OnClick = mnuResetClick
end
object N6: TMenuItem
Caption = '-'
end
object mnuDuplicate: TMenuItem
Caption = 'Duplicate'
Hint = 'Duplicate selected triangle'
ImageIndex = 2
OnClick = mnuDupClick
end
object mnuDelete: TMenuItem
Caption = 'Delete'
Hint = 'Delete selected triangle'
ImageIndex = 3
OnClick = mnuDeleteClick
end
object mnuAdd1: TMenuItem
Caption = 'Add'
Hint = 'Add new triangle'
ImageIndex = 1
OnClick = mnuAddClick
end
object N2: TMenuItem
Caption = '-'
end
object Rotatetriangle90CCW1: TMenuItem
Caption = 'Rotate triangle 90'#176' CCW'
ImageIndex = 17
OnClick = btTrgRotateLeft90Click
end
object Rotatetriangle90CCW2: TMenuItem
Caption = 'Rotate triangle 90'#176' CW'
ImageIndex = 18
OnClick = btTrgRotateRight90Click
end
object mnuFlipHorizontal: TMenuItem
Caption = 'Flip Horizontal'
Hint = 'Flip triangle horizontal'
ImageIndex = 10
OnClick = mnuFlipHorizontalClick
end
object mnuFlipVertical: TMenuItem
Caption = 'Flip Vertical'
Hint = 'Flip triangle vertical'
ImageIndex = 11
OnClick = mnuFlipVerticalClick
end
end
end

View File

@ -1,5 +1,6 @@
{
Apophysis Copyright (C) 2001-2004 Mark Townsend
Apophysis Copyright (C) 2005-2006 Ronald Hordijk, Piotr Boris, Peter Sdobnov
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@ -24,7 +25,7 @@ uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
ExtCtrls, StdCtrls, ComCtrls, Math, Menus, ToolWin, Registry,
ControlPoint, Render, cmap, Grids, ValEdit, Buttons, ImgList, CustomDrawControl,
Types, xform;
Types, XForm;
const
// PixelCountMax = 32768;
@ -35,7 +36,6 @@ const
crEditRotate = 22;
crEditScale = 23;
type PXForm = ^TXForm;
type
TEditForm = class(TForm)
GrphPnl: TPanel;
@ -45,9 +45,6 @@ type
PrevPnl: TPanel;
PreviewImage: TImage;
EditPopup: TPopupMenu;
MenuItem1: TMenuItem;
mnuDelete: TMenuItem;
mnuDuplicate: TMenuItem;
mnuAdd: TMenuItem;
mnuAutoZoom: TMenuItem;
N1: TMenuItem;
@ -66,7 +63,6 @@ type
PageControl: TPageControl;
TriangleTab: TTabSheet;
tabXForm: TTabSheet;
lblWeight: TLabel;
txtA: TEdit;
txtB: TEdit;
txtC: TEdit;
@ -144,7 +140,6 @@ type
ToolButton2: TToolButton;
tbVarPreview: TToolButton;
trkVarPreviewDepth: TTrackBar;
Label29: TLabel;
chkPreserve: TCheckBox;
btnXpost: TSpeedButton;
btnYpost: TSpeedButton;
@ -157,7 +152,6 @@ type
txtPost21: TEdit;
btnResetPostXForm: TSpeedButton;
btnSwapXforms: TSpeedButton;
txtSymmetry: TComboBox;
GroupBox3: TGroupBox;
editPivotY: TEdit;
editPivotX: TEdit;
@ -167,6 +161,19 @@ type
tbEnableFinalXform: TToolButton;
chkUseXFormColor: TCheckBox;
ToolButton3: TToolButton;
TrianglePopup: TPopupMenu;
mnuDuplicate: TMenuItem;
mnuDelete: TMenuItem;
mnuAdd1: TMenuItem;
N2: TMenuItem;
mnuShowVarPreview: TMenuItem;
mnuReset: TMenuItem;
N6: TMenuItem;
Rotatetriangle90CCW1: TMenuItem;
Rotatetriangle90CCW2: TMenuItem;
txtSymmetry: TEdit;
pnlWeight: TPanel;
pnlSymmetry: TPanel;
procedure ValidateVariable;
procedure vleVariablesValidate(Sender: TObject; ACol, ARow: Integer; const KeyName, KeyValue: string);
procedure vleVariablesKeyPress(Sender: TObject; var Key: Char);
@ -226,7 +233,7 @@ type
procedure txtXFormColorExit(Sender: TObject);
procedure txtXFormColorKeyPress(Sender: TObject; var Key: Char);
procedure txtSymmetrySet(Sender: TObject);
procedure txtSymmetryKeyPress(Sender: TObject; var Key: Char);
procedure txtSymmetrKeyPress(Sender: TObject; var Key: Char);
procedure btTrgRotateLeftClick(Sender: TObject);
procedure btTrgRotateRightClick(Sender: TObject);
@ -296,6 +303,13 @@ type
procedure VEVarsDrawCell(Sender: TObject; ACol, ARow: Integer;
Rect: TRect; State: TGridDrawState);
procedure tbEnableFinalXformClick(Sender: TObject);
procedure DragPanelMouseDown(Sender: TObject; Button: TMouseButton;
Shift: TShiftState; X, Y: Integer);
procedure DragPanelMouseMove(Sender: TObject; Shift: TShiftState; X,
Y: Integer);
procedure DragPanelMouseUp(Sender: TObject; Button: TMouseButton;
Shift: TShiftState; X, Y: Integer);
procedure DragPanelDblClick(Sender: TObject);
private
TriangleView: TCustomDrawControl;
@ -314,17 +328,12 @@ type
mouseOverPos: TSPoint;
varDragMode: boolean;
varDragIndex :integer;
varDragIndex: integer;
varDragValue: double;
varDragPos, varDragOld: integer;
varMM: boolean; //hack?
{
spinnerMode: boolean;
spinnerOld, spinnerPos: integer;
spinnerValue: double;
SpinnerAssoc: TEdit;
}
showVarPreview: boolean;
// --Z-- variables moved from outside
GraphZoom: double;
@ -340,8 +349,9 @@ type
PivotMode: (pivotLocal, pivotWorld);
VarsCache: array[0..64] of double; // hack: to prevent slow valuelist redraw
colorDrag, colorChanged: boolean;
colorDragX, colorOldX: integer;
pnlDragMode: boolean;
pnlDragPos, pnlDragOld: integer;
pnlDragValue: double;
(*
{ Options }
@ -405,10 +415,6 @@ implementation
uses
Main, Global, Adjust, Mutate, XformMan;
const
SUB_BATCH_SIZE = 1000;
SC_MyMenuItem1 = WM_USER + 1;
var
oldTriangle: TTriangle;
gCenterX: double;
@ -587,7 +593,6 @@ 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...
@ -602,7 +607,7 @@ begin
if SelectedTriangle > LastTriangle{???} then//NumXForms(cp) then
begin
SelectedTriangle := NumXForms(cp)-1;
SelectedTriangle := cp.NumXForms-1;
mouseOverTriangle := -1;
end;
@ -625,6 +630,7 @@ begin
HasChanged := false;
viewDragMode := false;
varDragMode := false;
pnlDragMode := false;
CornerCaught := false;
TriangleCaught := false;
@ -658,35 +664,6 @@ begin
PreviewImage.refresh;
end;
(*
procedure TEditForm.ReadjustWeights(var cp: TControlPoint);
{ Thanks to Rudy...code from Chaos }
// --Z-- and thanks to me for removing this! ;-)
var
total, othertotals, excess: double;
t, i: integer;
begin
t := NumXForms(cp);
{ /* First determine the excess. */ }
total := 0.0;
othertotals := 0.0;
for i := 0 to T - 1 do
if cp.xform[i].density <> 0.0 then
begin
total := total + cp.xform[i].density;
if (i <> SelectedTriangle) then
othertotals := othertotals + cp.xform[i].density;
end;
{ /* Now we need to fix'em */ }
//z excess := total - 1.0;
excess := 1.0 - (total - 1.0)/othertotals; // --Z--
for i := 0 to T - 1 do
if (i <> SelectedTriangle) and (cp.xform[i].density <> 0) then
//z cp.xform[i].density := cp.xform[i].density - cp.xform[i].density / othertotals * excess;
cp.xform[i].density := cp.xform[i].density * excess; // --Z--
end;
*)
procedure TEditForm.ShowSelectedInfo;
var
i: integer;
@ -783,8 +760,6 @@ begin
editPivotY.Text := Format('%.6g', [WorldPivot.y]);
end;
if cp.finalXformEnabled then tbEnableFinalXform.Down := true;
PageControl.Refresh;
end;
@ -881,11 +856,11 @@ end;
procedure TEditForm.DeleteTriangle(t: integer);
var
i, j: integer;
i: integer;
begin
if (t = Transforms ) then
if (t = Transforms) then
begin
assert(cp.HasFinalXForm);
assert(EnableFinalXform);
MainForm.UpdateUndo;
EnableFinalXform := false;
cp.finalXformEnabled := false;
@ -903,6 +878,7 @@ begin
if t = (Transforms - 1) then
begin
MainTriangles[t] := MainTriangles[Transforms];
cp.xform[t].Assign(cp.xform[Transforms]);
Dec(SelectedTriangle);
end
else begin
@ -1145,7 +1121,7 @@ end;
TextOut(b.x+2, b.y+1, 'O');
end;
if tbVarPreview.Down then
if showVarPreview then
begin
assert(trkVarPreviewRange.position > 0);
assert(trkVarPreviewDensity.position > 0);
@ -1910,7 +1886,13 @@ begin
if viewDragged=false then // haven't dragged - popup menu then
begin
GetCursorPos(mousepos); // hmmm
EditPopup.Popup(mousepos.x, mousepos.y);
if mouseOverTriangle < 0 then
EditPopup.Popup(mousepos.x, mousepos.y)
else begin
SelectedTriangle := mouseOverTriangle;
TriangleView.Refresh;
TrianglePopup.Popup(mousepos.x, mousepos.y)
end;
end
else viewDragged := false;
Screen.Cursor := crDefault;
@ -1957,12 +1939,18 @@ begin
end
else
begin
HelpersEnabled := False;
HelpersEnabled := true;
end;
if Registry.ValueExists('VariationPreview') then
tbVarPreview.Down := Registry.ReadBool('VariationPreview')
else tbVarPreview.Down := false;
begin
showVarPreview := Registry.ReadBool('VariationPreview');
tbVarPreview.Down := showVarPreview;
end
else begin
showVarPreview := false;
tbVarPreview.Down := false;
end;
if Registry.ValueExists('VariationPreviewRange') then
trkVarPreviewRange.Position := Registry.ReadInteger('VariationPreviewRange');
if Registry.ValueExists('VariationPreviewDensity') then
@ -2193,8 +2181,8 @@ begin
end;
end;
NewVal := Round6(StrToFloat(TEdit(Sender).Text));
if NewVal < 0 then NewVal := 0;
if NewVal > 0.99 then NewVal := 0.99;
if NewVal < 0.000001 then NewVal := 0.000001;
if NewVal > 100 then NewVal := 100;
{ If it's not the same as the old value and it was valid }
TEdit(Sender).Text := Format('%.6g', [NewVal]);
if (OldVal <> NewVal) and Allow then
@ -2225,8 +2213,8 @@ begin
end;
end;
NewVal := Round6(StrToFloat(TEdit(Sender).Text));
if NewVal < 0 then NewVal := 0;
if NewVal > 0.99 then NewVal := 0.99;
if NewVal < 0.000001 then NewVal := 0.000001;
if NewVal > 100 then NewVal := 100;
{ If it's not the same as the old value and it was valid }
TEdit(Sender).Text := Format('%.6g', [NewVal]);
if (OldVal <> NewVal) and Allow then
@ -2262,7 +2250,8 @@ begin
Registry.WriteInteger('ReferenceTriangleColor', ReferenceTriangleColor);
}
Registry.WriteBool('ResetLocation', mnuResetLoc.checked);
Registry.WriteBool('VariationPreview', tbVarPreview.Down);
Registry.WriteBool('VariationPreview', showVarPreview);
Registry.WriteBool('HelpersEnabled', HelpersEnabled);
Registry.WriteInteger('VariationPreviewRange', trkVarPreviewRange.Position);
Registry.WriteInteger('VariationPreviewDensity', trkVarPreviewDensity.Position);
Registry.WriteInteger('VariationPreviewDepth', trkVarPreviewDepth.Position);
@ -2534,11 +2523,14 @@ begin
end;
procedure TEditForm.scrlXFormColorChange(Sender: TObject);
var
v: double;
begin
cp.xform[SelectedTriangle].color := (scrlXFormColor.Position) / scrlXFormColor.Max;
txtXFormColor.Text := Format('%1.3f', [cp.xform[SelectedTriangle].color]);
v := (scrlXFormColor.Position) / scrlXFormColor.Max;
cp.xform[SelectedTriangle].color := v;
pnlXFormColor.color := ColorValToColor(MainCp.cmap, v);
txtXFormColor.Text := Format('%1.3f', [v]);
txtXFormColor.Refresh;
pnlXFormColor.color := ColorValToColor(MainCp.cmap, cp.xform[SelectedTriangle].color);
DrawPreview;
end;
@ -2555,64 +2547,6 @@ begin
TriangleView.Invalidate;
end;
(*
procedure TEditForm.pnlBackColorClick(Sender: TObject);
begin
AdjustForm.ColorDialog.Color := EditorBkgColor; //pnlBackColor.Color;
if AdjustForm.ColorDialog.Execute then
begin
pnlBackColor.Color := AdjustForm.ColorDialog.Color;
BackgroundColor := Integer(pnlBackColor.color);
GrphPnl.Color := BackgroundColor;
TriangleView.Invalidate;
end;
end;
procedure TEditForm.pnlReferenceClick(Sender: TObject);
begin
AdjustForm.ColorDialog.Color := pnlReference.Color;
if AdjustForm.ColorDialog.Execute then
begin
pnlReference.Color := AdjustForm.ColorDialog.Color;
ReferenceTriangleColor := Integer(pnlReference.color);
TriangleView.Invalidate;
end;
end;
procedure TEditForm.pnlGridColor1Click(Sender: TObject);
begin
AdjustForm.ColorDialog.Color := pnlGridColor1.Color;
if AdjustForm.ColorDialog.Execute then
begin
pnlGridColor1.Color := AdjustForm.ColorDialog.Color;
GridColor1 := Integer(pnlGridColor1.color);
TriangleView.Invalidate;
end;
end;
procedure TEditForm.pnlGridColor2Click(Sender: TObject);
begin
AdjustForm.ColorDialog.Color := pnlGridColor2.Color;
if AdjustForm.ColorDialog.Execute then
begin
pnlGridColor2.Color := AdjustForm.ColorDialog.Color;
GridColor2 := Integer(pnlGridColor2.color);
TriangleView.Invalidate;
end;
end;
procedure TEditForm.pnlHelpersColorClick(Sender: TObject);
begin
AdjustForm.ColorDialog.Color := pnlHelpersColor.Color;
if AdjustForm.ColorDialog.Execute then
begin
pnlHelpersColor.Color := AdjustForm.ColorDialog.Color;
HelpersColor := Integer(pnlHelpersColor.color);
TriangleView.Invalidate;
end;
end;
*)
procedure TEditForm.txtXFormColorExit(Sender: TObject);
var
v: double;
@ -2689,7 +2623,7 @@ begin
end;
end;
procedure TEditForm.txtSymmetryKeyPress(Sender: TObject; var Key: Char);
procedure TEditForm.txtSymmetrKeyPress(Sender: TObject; var Key: Char);
var
Allow: boolean;
NewVal, OldVal: double;
@ -2837,6 +2771,7 @@ begin
varDragMode:=true;
varDragPos:=0;
varMM := false;
SetCaptureControl(TValueListEditor(Sender));
if Sender = VEVars then
varDragValue := cp.xform[SelectedTriangle].vars[varDragIndex]
@ -2883,11 +2818,11 @@ begin
if Sender = VEVars then
begin
cp.xform[SelectedTriangle].vars[varDragIndex] := v;
TValueListEditor(Sender).Values[VarNames(varDragIndex)] := Format('%.6g', [v]);
TValueListEditor(Sender).Values[VarNames(varDragIndex)] := FloatToStr(v); //Format('%.6g', [v]);
end
else begin
cp.xform[SelectedTriangle].SetVariable(vleVariables.Keys[varDragIndex+1], v);
vleVariables.Values[vleVariables.Keys[varDragIndex+1]] := Format('%.6g', [v]);
vleVariables.Values[vleVariables.Keys[varDragIndex+1]] := FloatToStr(v); //Format('%.6g', [v]);
end;
HasChanged := True;
@ -3453,12 +3388,22 @@ var
i: integer;
begin
MainForm.UpdateUndo;
for i := 2 to Transforms-1 do cp.xform[i].density := 0;
for i := 0 to Transforms-1 do cp.xform[i].Clear;//density := 0;
cp.xform[0].vars[0] := 1;
cp.xform[0].density := 0.5;
cp.xform[1].vars[0] := 1;
cp.xform[1].density := 0.5;
cp.xform[1].color := 1;
cp.xform[2].symmetry := 1;
Transforms := 2;
SelectedTriangle := 1;
MainTriangles[0] := MainTriangles[-1];
with cp.xform[0] do begin
MainTriangles[1] := MainTriangles[-1];
MainTriangles[2] := MainTriangles[-1];
assert(cp.HasFinalXForm = false);
{ with cp.xform[0] do begin
density := 0.5;
color := 0;
symmetry := 0;
@ -3470,7 +3415,6 @@ begin
p[2, 0] := 0;
p[2, 1] := 0;
end;
MainTriangles[1] := MainTriangles[-1];
with cp.xform[1] do begin
density := 0.5;
color := 1;
@ -3488,7 +3432,7 @@ begin
cp.xform[0].vars[i] := 0;
cp.xform[1].vars[i] := 0;
end;
}
cbTransforms.clear;
cbTransforms.Items.Add('1');
cbTransforms.Items.Add('2');
@ -3543,6 +3487,8 @@ end;
procedure TEditForm.tbVarPreviewClick(Sender: TObject);
begin
showVarPreview := not showVarPreview;
tbVarPreview.Down := showVarPreview;
TriangleView.Invalidate;
end;
@ -3809,25 +3755,20 @@ begin
ShowSelectedInfo;
UpdateFlame(true);
end;
// .............................................................................
procedure TEditForm.VEVarsDrawCell(Sender: TObject; ACol, ARow: Integer;
Rect: TRect; State: TGridDrawState);
var
c: TColor;
begin
// if ARow = 0 then exit;
if (ARow > NRLOCVAR) then
if (ARow > NRLOCVAR) and not (gdSelected in State) then
begin
// if ARow and 1 = 1 then c := c shr 1;
VEVars.canvas.brush.Color := $ffe0e0;
VEVars.canvas.fillRect(Rect);
VEVars.canvas.TextOut(Rect.Left+2, Rect.Top, VEVars.Cells[ACol,ARow]);
VEVars.canvas.TextOut(Rect.Left+2, Rect.Top+2, VEVars.Cells[ACol,ARow]);
end;
end;
procedure TEditForm.tbEnableFinalXformClick(Sender: TObject);
var
i: integer;
begin
MainForm.UpdateUndo;
EnableFinalXform := tbEnableFinalXform.Down;
@ -3835,15 +3776,11 @@ begin
begin
if (EnableFinalXform = true) then
begin
//cp.xform[Transforms].Clear;
//cp.xform[Transforms].Symmetry := 1;
cbTransforms.Items.Add('Final');
SelectedTriangle := Transforms;
if (mouseOverTriangle > LastTriangle) then mouseOverTriangle := -1;
end
else begin
//cp.xform[Transforms].Clear;
//cp.xform[Transforms].Symmetry := 1;
if cbTransforms.Items.Count = Transforms+1 then
cbTransforms.Items.Delete(Transforms);
if SelectedTriangle >= Transforms then SelectedTriangle := Transforms-1;
@ -3854,5 +3791,141 @@ begin
TriangleView.Invalidate;
end;
procedure TEditForm.DragPanelMouseDown(Sender: TObject;
Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
begin
if Button <> mbLeft then exit;
//assert(pnlDragMode = false);
if (Sender = pnlWeight) then
if SelectedTriangle < Transforms then
pnlDragValue := cp.xform[SelectedTriangle].density
else exit
else if (Sender = pnlSymmetry) then
pnlDragValue := cp.xform[SelectedTriangle].symmetry
else if (Sender = pnlXformColor) then
pnlDragValue := cp.xform[SelectedTriangle].color
else assert(false);
pnlDragMode := true;
pnlDragPos := 0;
pnlDragOld := x;
varMM := false;
SetCaptureControl(TControl(Sender));
Screen.Cursor := crHSplit;
GetCursorPos(mousepos); // hmmm
HasChanged := false;
end;
procedure TEditForm.DragPanelMouseMove(Sender: TObject; Shift: TShiftState;
X, Y: Integer);
var
v: double;
pEdit: ^TEdit;
begin
if varMM then // hack: to skip MouseMove event
begin
varMM:=false;
end
else
if pnlDragMode and (x <> pnlDragOld) then
begin
Inc(pnlDragPos, x - pnlDragOld);
if GetKeyState(VK_MENU) < 0 then v := 100000
else if GetKeyState(VK_CONTROL) < 0 then v := 10000
else if GetKeyState(VK_SHIFT) < 0 then v := 100
else v := 1000;
v := Round6(pnlDragValue + pnlDragPos / v);
SetCursorPos(MousePos.x, MousePos.y); // hmmm
varMM:=true;
if (Sender = pnlWeight) then
begin
if v <= 0.000001 then v := 0.000001;
cp.xform[SelectedTriangle].density := v;
pEdit := @txtP;
end
else if (Sender = pnlSymmetry) then
begin
if v < -1 then v := -1
else if v > 1 then v := 1;
cp.xform[SelectedTriangle].symmetry := v;
pEdit := @txtSymmetry;
end
else if (Sender = pnlXformColor) then
begin
if v < 0 then v := 0
else if v > 1 then v := 1;
cp.xform[SelectedTriangle].color := v;
pnlXFormColor.Color := ColorValToColor(cp.cmap, v);
scrlXformColor.Position := round(v*1000);
pEdit := @txtXformColor;
end;
pEdit^.Text := FloatToStr(v); // Format('%.6g', [v])
//pEdit.Refresh;
HasChanged := True;
DrawPreview;
end;
end;
procedure TEditForm.DragPanelMouseUp(Sender: TObject; Button: TMouseButton;
Shift: TShiftState; X, Y: Integer);
begin
if Button <> mbLeft then exit;
if pnlDragMode then
begin
SetCaptureControl(nil);
pnlDragMode := false;
Screen.Cursor := crDefault;
if HasChanged then
begin
MainForm.UpdateUndo;
UpdateFlame(true);
HasChanged := False;
end;
end;
end;
procedure TEditForm.DragPanelDblClick(Sender: TObject);
var
pValue: ^double;
pEdit: ^TEdit;
begin
if (Sender = pnlWeight) then
begin
if SelectedTriangle = LastTriangle then exit; // hmm
pValue := @cp.xform[SelectedTriangle].density;
if pValue^ = 0.5 then exit;
pValue^ := 0.5;
pEdit := @txtP;
end
else if (Sender = pnlSymmetry) then
begin
pValue := @cp.xform[SelectedTriangle].symmetry;
if pValue^ = 0 then exit;
pValue^ := 0;
pEdit := @txtSymmetry;
end
else if (Sender = pnlXformColor) then
begin
pValue := @cp.xform[SelectedTriangle].color;
if pValue^ = 0 then exit;
pValue^ := 0;
pEdit := @txtXformColor;
end
else assert(false);
MainForm.UpdateUndo;
pEdit^.Text := FloatToStr(pValue^);
UpdateFlame(true);
end;
end.

View File

@ -33,7 +33,7 @@ type
procedure FormKeyPress(Sender: TObject; var Key: Char);
procedure ImageDblClick(Sender: TObject);
private
Remainder, StartTime, Now: Extended;
Remainder, StartTime, t: double;
Renderer: TRenderThread;
procedure showTaskbar;
procedure hideTaskbar;
@ -68,15 +68,17 @@ begin
// cp.center[1] := MainForm.center[1];
cp.sample_density := defSampleDensity;
StartTime := Now;
t := now;
Remainder := 1;
if Assigned(Renderer) then Renderer.Terminate;
if Assigned(Renderer) then Renderer.WaitFor;
assert(not assigned(renderer));
if not Assigned(Renderer) then
begin
Renderer := TRenderThread.Create;
Renderer.TargetHandle := Handle;
Renderer.OnProgress := OnProgress;
Renderer.Compatibility := Compatibility;
Renderer.Compatibility := Compatibility;
Renderer.SetCP(cp);
Renderer.Resume;
end;
@ -90,7 +92,7 @@ begin
begin
bm := TBitmap.Create;
bm.assign(Renderer.GetImage);
Image.Picture.Graphic := bm;
Image.Picture.Graphic := bm;
// Canvas.StretchDraw(Rect(0, 0, ClientWidth, ClientHeight), bm);
Renderer.Free;
@ -100,11 +102,18 @@ begin
end;
procedure TFullscreenForm.HandleThreadTermination(var Message: TMessage);
//var
// bm: TBitmap;
begin
if Assigned(Renderer) then
begin
// bm := TBitmap.Create;
// bm.assign(Renderer.GetImage);
// Image.Picture.Graphic := bm;
Renderer.Free;
Renderer := nil;
// bm.Free;
end;
end;

View File

@ -17,7 +17,7 @@ type
FTransparentImage: TBitmap;
Fcp: Tcontrolpoint;
FBucketWidth: Int64;
FBucketWidth: integer;
FBuckets: TBucketArray;
FOnProgress: TOnProgress;
@ -39,7 +39,7 @@ type
procedure SetCP(CP: TControlPoint);
procedure Init;
procedure SetBucketData(const Buckets: TBucketArray; const BucketWidth: int64);
procedure SetBucketData(const Buckets: TBucketArray; const BucketWidth: integer);
function GetFilterSize: Integer;
@ -174,7 +174,7 @@ begin
end;
///////////////////////////////////////////////////////////////////////////////
procedure TImageMaker.SetBucketData(const Buckets: TBucketArray; const BucketWidth: int64);
procedure TImageMaker.SetBucketData(const Buckets: TBucketArray; const BucketWidth: integer);
begin
FBuckets := Buckets;
FBucketWidth := BucketWidth;

View File

@ -586,7 +586,7 @@ begin
{ Editor } // --Z-- moved from EditForm
if Registry.OpenKey('Software\' + APP_NAME + '\Forms\Editor', False) then
begin
if Registry.ValueExists('UseTransformColors') then
{ if Registry.ValueExists('UseTransformColors') then
begin
UseTransformColors := Registry.ReadBool('UseTransformColors');
end
@ -602,6 +602,7 @@ begin
begin
UseFlameBackground := False;
end;
}
if Registry.ValueExists('BackgroundColor') then
EditorBkgColor := Registry.ReadInteger('BackgroundColor')
else

View File

@ -40,9 +40,6 @@ type
Buckets: TBucketArray;
ColorMap: TColorMapArray;
FinalXform: ^TXform;
UseFinalXform: boolean;
camX0, camX1, camY0, camY1, // camera bounds
camW, camH, // camera sizes
bws, bhs, cosa, sina, rcX, rcY: double;
@ -59,8 +56,6 @@ type
procedure AddPointsToBuckets(const points: TPointsArray);
procedure AddPointsToBucketsAngle(const points: TPointsArray);
procedure AddPointsWithFX(const points: TPointsArray);
procedure AddPointsWithAngleFX(const points: TPointsArray);
procedure SetPixels;
public
@ -215,14 +210,15 @@ end;
///////////////////////////////////////////////////////////////////////////////
procedure TRenderer64.InitValues;
var
i, n: integer;
begin
InitBuffers;
CreateCamera;
CreateColorMap;
FinalXForm := @fcp.xform[fcp.NumXForms];
UseFinalXForm := fcp.finalXformEnabled and fcp.HasFinalXform;
fcp.Prepare;
end;
///////////////////////////////////////////////////////////////////////////////
@ -251,86 +247,6 @@ begin
end;
end;
procedure TRenderer64.AddPointsWithFX(const points: TPointsArray);
const
const255: single = 255;
var
i: integer;
px, py: double;
Bucket: PBucket;
MapColor: PColorMapColor;
begin
try
for i := SUB_BATCH_SIZE - 1 downto 0 do begin
// if FStop then Exit;
FinalXform.NextPoint(points[i]);
{$if true}
px := points[i].x - camX0;
if (px < 0) or (px > camW) then continue;
py := points[i].y - camY0;
if (py < 0) or (py > camH) then continue;
Bucket := @buckets[Round(bws * px) + Round(bhs * py) * BucketWidth];
MapColor := @ColorMap[Round(points[i].c * 255)];
Inc(Bucket.Red, MapColor.Red);
Inc(Bucket.Green, MapColor.Green);
Inc(Bucket.Blue, MapColor.Blue);
Inc(Bucket.Count);
{$else}
asm
mov eax, [points]
lea edx, [eax + edi*8] // assert: "i" in edi
// fld qword ptr [edx + edi*8] // assert: "i" in edi
fld qword ptr [edx]
fsub qword ptr [bx]
fldz
fcomp st(1), st
fnstsw ax
sahf
jb @skip1
fld qword ptr [wx]
fcomp
fnstsw ax
sahf
jnbe @skip1
fld qword ptr [edx + 8]
fsub qword ptr [by]
fldz
fcomp
fnstsw ax
sahf
jb @skip2
fld qword ptr [wy]
fcomp
fnstsw ax
sahf
jnbe @skip2
fmul qword ptr [bhs]
fimul [BucketWidth]
fld qword ptr [edx + 16]
fmul dword ptr [const255]
sub esp, 4
fistp dword ptr [esp]
pop eax
@skip2:
fstp st
@skip1:
fstp st
@continue:
end;
{$ifend}
end
except
end
end;
///////////////////////////////////////////////////////////////////////////////
procedure TRenderer64.AddPointsToBucketsAngle(const points: TPointsArray);
var
@ -357,36 +273,6 @@ begin
end;
end;
procedure TRenderer64.AddPointsWithAngleFX(const points: TPointsArray);
var
i: integer;
px, py: double;
Bucket: PBucket;
MapColor: PColorMapColor;
begin
try
for i := SUB_BATCH_SIZE - 1 downto 0 do
begin
// if FStop then Exit;
FinalXform.NextPoint(points[i]);
px := points[i].x * cosa + points[i].y * sina + rcX;
if (px < 0) or (px > camW) then continue;
py := points[i].y * cosa - points[i].x * sina + rcY;
if (py < 0) or (py > camH) then continue;
Bucket := @buckets[Round(bws * px) + Round(bhs * py) * BucketWidth];
MapColor := @ColorMap[Round(points[i].c * 255)];
Inc(Bucket.Red, MapColor.Red);
Inc(Bucket.Green, MapColor.Green);
Inc(Bucket.Blue, MapColor.Blue);
Inc(Bucket.Count);
end;
except
end
end;
///////////////////////////////////////////////////////////////////////////////
procedure TRenderer64.SetPixels;
var
@ -401,18 +287,10 @@ begin
// AssignFile(F, 'c:\temp\flame.txt');
// Rewrite(F);
if FCP.FAngle = 0 then begin
if UseFinalXForm then
AddPointsProc := AddPointsWithFX
else
AddPointsProc := AddPointsToBuckets;
end
else begin
if UseFinalXForm then
AddPointsProc := AddPointsWithAngleFX
else
AddPointsProc := AddPointsToBucketsAngle;
end;
if FCP.FAngle = 0 then
AddPointsProc := AddPointsToBuckets
else
AddPointsProc := AddPointsToBucketsAngle;
SetLength(Points, SUB_BATCH_SIZE);

View File

@ -42,9 +42,6 @@ type
Buckets: TBucketArray;
ColorMap: TColorMapArray;
FinalXform: ^TXform;
UseFinalXform: boolean;
camX0, camX1, camY0, camY1, // camera bounds
camW, camH, // camera sizes
Xsize, Ysize: double;
@ -239,6 +236,8 @@ begin
CreateCamera;
CreateColorMap;
fcp.Prepare;
end;

View File

@ -41,9 +41,6 @@ type
Buckets: TBucketArray;
ColorMap: TColorMapArray;
FinalXform: ^TXform;
UseFinalXform: boolean;
camX0, camX1, camY0, camY1, // camera bounds
camW, camH, // camera sizes
bws, bhs, cosa, sina, rcX, rcY: double;
@ -64,8 +61,6 @@ type
procedure AddPointsToBuckets(const points: TPointsArray);
procedure AddPointsToBucketsAngle(const points: TPointsArray);
procedure AddPointsWithFX(const points: TPointsArray);
procedure AddPointsWithAngleFX(const points: TPointsArray);
procedure SetPixels;
protected
@ -213,6 +208,8 @@ end;
///////////////////////////////////////////////////////////////////////////////
procedure TRendererMM64.InitValues;
var
i: integer;
begin
image_height := fcp.Height;
image_Width := fcp.Width;
@ -223,8 +220,7 @@ begin
CreateColorMap;
FinalXForm := @fcp.xform[fcp.NumXForms];
UseFinalXForm := fcp.finalXformEnabled and fcp.HasFinalXform;
fcp.Prepare;
end;
///////////////////////////////////////////////////////////////////////////////
@ -255,36 +251,6 @@ begin
end;
end;
procedure TRendererMM64.AddPointsWithFX(const points: TPointsArray);
var
i: integer;
px, py: double;
Bucket: PBucket;
MapColor: PColorMapColor;
begin
try
for i := SUB_BATCH_SIZE - 1 downto 0 do begin
// if FStop then Exit;
FinalXform.NextPoint(points[i]);
px := points[i].x - camX0;
if (px < 0) or (px > camW) then continue;
py := points[i].y - camY0;
if (py < 0) or (py > camH) then continue;
Bucket := @buckets[Round(bws * px) + Round(bhs * py) * BucketWidth];
MapColor := @ColorMap[Round(points[i].c * 255)];
Inc(Bucket.Red, MapColor.Red);
Inc(Bucket.Green, MapColor.Green);
Inc(Bucket.Blue, MapColor.Blue);
Inc(Bucket.Count);
end;
except
end
end;
///////////////////////////////////////////////////////////////////////////////
procedure TRendererMM64.AddPointsToBucketsAngle(const points: TPointsArray);
var
@ -311,36 +277,6 @@ begin
end;
end;
procedure TRendererMM64.AddPointsWithAngleFX(const points: TPointsArray);
var
i: integer;
px, py: double;
Bucket: PBucket;
MapColor: PColorMapColor;
begin
try
for i := SUB_BATCH_SIZE - 1 downto 0 do
begin
// if FStop then Exit;
FinalXform.NextPoint(points[i]);
px := points[i].x * cosa + points[i].y * sina + rcX;
if (px < 0) or (px > camW) then continue;
py := points[i].y * cosa - points[i].x * sina + rcY;
if (py < 0) or (py > camH) then continue;
Bucket := @buckets[Round(bws * px) + Round(bhs * py) * BucketWidth];
MapColor := @ColorMap[Round(points[i].c * 255)];
Inc(Bucket.Red, MapColor.Red);
Inc(Bucket.Green, MapColor.Green);
Inc(Bucket.Blue, MapColor.Blue);
Inc(Bucket.Count);
end;
except
end
end;
///////////////////////////////////////////////////////////////////////////////
procedure TRendererMM64.SetPixels;
var

View File

@ -39,9 +39,6 @@ type
Buckets: TBucketArray;
ColorMap: TColorMapArray;
FinalXform: ^TXform;
UseFinalXform: boolean;
camX0, camX1, camY0, camY1, // camera bounds
camW, camH, // camera sizes
bws, bhs, cosa, sina, rcX, rcY: double;
@ -69,8 +66,6 @@ type
procedure AddPointsToBuckets(const points: TPointsArray);
procedure AddPointsToBucketsAngle(const points: TPointsArray);
procedure AddPointsWithFX(const points: TPointsArray);
procedure AddPointsWithAngleFX(const points: TPointsArray);
procedure SetPixels;
procedure SetPixelsMT;
@ -225,6 +220,8 @@ end;
///////////////////////////////////////////////////////////////////////////////
procedure TRendererMM64_MT.InitValues;
var
i, n: integer;
begin
image_height := fcp.Height;
image_Width := fcp.Width;
@ -235,8 +232,7 @@ begin
CreateColorMap;
FinalXForm := @fcp.xform[fcp.NumXForms];
UseFinalXForm := fcp.finalXformEnabled and fcp.HasFinalXform;
fcp.Prepare;
end;
///////////////////////////////////////////////////////////////////////////////
@ -267,36 +263,6 @@ begin
end;
end;
procedure TRendererMM64_MT.AddPointsWithFX(const points: TPointsArray);
var
i: integer;
px, py: double;
Bucket: PBucket;
MapColor: PColorMapColor;
begin
try
for i := SUB_BATCH_SIZE - 1 downto 0 do begin
// if FStop then Exit;
FinalXform.NextPoint(points[i]);
px := points[i].x - camX0;
if (px < 0) or (px > camW) then continue;
py := points[i].y - camY0;
if (py < 0) or (py > camH) then continue;
Bucket := @buckets[Round(bws * px) + Round(bhs * py) * BucketWidth];
MapColor := @ColorMap[Round(points[i].c * 255)];
Inc(Bucket.Red, MapColor.Red);
Inc(Bucket.Green, MapColor.Green);
Inc(Bucket.Blue, MapColor.Blue);
Inc(Bucket.Count);
end;
except
end
end;
///////////////////////////////////////////////////////////////////////////////
procedure TRendererMM64_MT.AddPointsToBucketsAngle(const points: TPointsArray);
var
@ -323,36 +289,6 @@ begin
end;
end;
procedure TRendererMM64_MT.AddPointsWithAngleFX(const points: TPointsArray);
var
i: integer;
px, py: double;
Bucket: PBucket;
MapColor: PColorMapColor;
begin
try
for i := SUB_BATCH_SIZE - 1 downto 0 do
begin
// if FStop then Exit;
FinalXform.NextPoint(points[i]);
px := points[i].x * cosa + points[i].y * sina + rcX;
if (px < 0) or (px > camW) then continue;
py := points[i].y * cosa - points[i].x * sina + rcY;
if (py < 0) or (py > camH) then continue;
Bucket := @buckets[Round(bws * px) + Round(bhs * py) * BucketWidth];
MapColor := @ColorMap[Round(points[i].c * 255)];
Inc(Bucket.Red, MapColor.Red);
Inc(Bucket.Green, MapColor.Green);
Inc(Bucket.Blue, MapColor.Blue);
Inc(Bucket.Count);
end;
except
end
end;
///////////////////////////////////////////////////////////////////////////////
procedure TRendererMM64_MT.SetPixels;
var
@ -362,18 +298,10 @@ var
points: TPointsArray;
AddPointsProc: procedure (const points: TPointsArray) of object;
begin
if FCP.FAngle = 0 then begin
if UseFinalXForm then
AddPointsProc := AddPointsWithFX
else
AddPointsProc := AddPointsToBuckets;
end
else begin
if UseFinalXForm then
AddPointsProc := AddPointsWithAngleFX
else
AddPointsProc := AddPointsToBucketsAngle;
end;
if FCP.FAngle = 0 then
AddPointsProc := AddPointsToBuckets
else
AddPointsProc := AddPointsToBucketsAngle;
SetLength(Points, SUB_BATCH_SIZE);

View File

@ -19,6 +19,10 @@ type
end;
PXYpoint = ^TXYpoint;
T2Cpoint = record
x, y, c1, c2: double;
end;
TMatrix = array[0..2, 0..2] of double;
{$define _ASM_}
@ -36,13 +40,14 @@ type
FSinA: double;
FCosA: double;
FLength: double;
// CalculateAngle, CalculateLength, CalculateSinCos: boolean;
colorC1, colorC2: double;
// precalculated constants for some variations
waves_f1, waves_f2,
rings_dx,
fan_dx, fan_dx2,
cosine_var2: double; // precalc...
cosine_var2,
polar_vpi: double;
FRegVariations: array of TBaseVariation;
@ -111,9 +116,10 @@ type
procedure NextPoint(var px, py, pc: double); overload;
procedure NextPoint(var CPpoint: TCPpoint); overload;
procedure NextPointTo(var CPpoint, ToPoint: TCPpoint);
// procedure NextPoint(var px, py, pz, pc: double); overload;
procedure NextPointXY(var px, py: double);
procedure NextPoint2C(var px, py, pc1, pc2: double);
procedure NextPoint2C(var p: T2CPoint);
procedure Rotate(const degrees: double);
procedure Translate(const x, y: double);
@ -243,6 +249,8 @@ begin
cosine_var2 := vars[20]/2;
polar_vpi := vars[5]/pi;
if (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) then
begin
p00 := p[0][0];
@ -308,9 +316,7 @@ asm
fmul st, st
faddp
fsqrt
fadd qword ptr [EPS] // test...
fadd qword ptr [EPS] // avoid divide by zero...(?)
fdiv st(1), st
fdiv st(2), st
fstp qword ptr [eax + FLength]
@ -333,9 +339,7 @@ asm
fmul st, st
faddp
fsqrt
fadd qword ptr [EPS] // test...
fadd qword ptr [EPS] // avoid divide by zero...(?)
fdiv st(1), st
fdiv st(2), st
fstp qword ptr [eax + FLength]
@ -546,16 +550,12 @@ begin
FPy := FPy + vars[5] * ny;
}
begin
FPx := FPx + vars[5] * FAngle / PI;
FPx := FPx + polar_vpi * FAngle; //vars[5] * FAngle / PI;
FPy := FPy + vars[5] * (sqrt(sqr(FTx) + sqr(FTy)) - 1.0);
{$else}
asm
mov edx, [eax + vars]
fld qword ptr [edx + 5*8]
fld qword ptr [eax + FAngle]
fldpi
fdivp st(1), st
fmul st, st(1)
fmul qword ptr [eax + polar_vpi]
fadd qword ptr [eax + FPx]
fstp qword ptr [eax + FPx]
fld qword ptr [eax + FTx]
@ -566,7 +566,8 @@ asm
fsqrt
fld1
fsubp st(1), st
fmulp
mov edx, [eax + vars]
fmul qword ptr [edx + 5*8]
fadd qword ptr [eax + FPy]
fstp qword ptr [eax + FPy]
fwait
@ -648,14 +649,8 @@ end;
procedure TXForm.Disc;
{$ifndef _ASM_}
var
// nx, ny: double;
r, sinr, cosr: double;
begin
// --Z-- ????? - calculating PI^2 to get square root from it, hmm?
// nx := FTx * PI;
// ny := FTy * PI;
// r := sqrt(nx * nx + ny * ny);
SinCos(PI * sqrt(sqr(FTx) + sqr(FTy)), sinr, cosr);
r := vars[8] * FAngle / PI;
FPx := FPx + sinr * r;
@ -841,17 +836,12 @@ end;
procedure TXForm.Julia;
{$ifndef _ASM_}
var
a, r: double;
sinr, cosr: double;
r, sina, cosa: double;
begin
if random(2) <> 0 then
a := FAngle/2 + PI
else
a := FAngle/2;
SinCos(a, sinr, cosr);
SinCos(FAngle/2 + pi*random(2), sina, cosa);
r := vars[13] * sqrt(sqrt(sqr(FTx) + sqr(FTy)));
FPx := FPx + r * cosr;
FPy := FPy + r * sinr;
FPx := FPx + r * cosa;
FPy := FPy + r * sina;
{$else}
asm
fld qword ptr [ebx + FAngle] // assert: self is in ebx
@ -862,11 +852,12 @@ asm
xor eax, eax // hmm...
add eax, $02 // hmmm....
call System.@RandInt // hmmmm.....
test al, al
jnz @skip
push eax
fild dword ptr [esp]
add esp, 4
fldpi
fmulp
faddp
@skip:
fsincos
fld qword ptr [ebx + FTx]
fmul st, st
@ -965,25 +956,25 @@ begin
FPy := FPy + vars[15] * (FTy + c11 * sin(FTx * waves_f2));
{$else}
asm
mov edx, [ebx + vars]
mov edx, [eax + vars]
fld qword ptr [edx + 15*8]
fld qword ptr [ebx + FTy]
fld qword ptr [ebx + FTx]
fld qword ptr [eax + FTy]
fld qword ptr [eax + FTx]
fld st(1)
fmul qword ptr [ebx + waves_f1]
fmul qword ptr [eax + waves_f1]
fsin
fmul qword ptr [ebx + c10]
fmul qword ptr [eax + c10]
fadd st, st(1)
fmul st, st(3)
fadd qword ptr [ebx + FPx]
fstp qword ptr [ebx + FPx]
fmul qword ptr [ebx + waves_f2]
fadd qword ptr [eax + FPx]
fstp qword ptr [eax + FPx]
fmul qword ptr [eax + waves_f2]
fsin
fmul qword ptr [ebx + c11]
fmul qword ptr [eax + c11]
faddp
fmulp
fadd qword ptr [ebx + FPy]
fstp qword ptr [ebx + FPy]
fadd qword ptr [eax + FPy]
fstp qword ptr [eax + FPy]
fwait
{$endif}
end;
@ -1009,11 +1000,11 @@ begin
FPy := FPy + r * FTx;
{$else}
asm
mov edx, [ebx + vars]
mov edx, [eax + vars]
fld qword ptr [edx + 16*8]
fadd st, st
fld qword ptr [ebx + FTx]
fld qword ptr [ebx + FTy]
fld qword ptr [eax + FTx]
fld qword ptr [eax + FTy]
fld st(1)
fmul st, st
fld st(1)
@ -1024,11 +1015,11 @@ asm
faddp
fdivp st(3), st
fmul st, st(2)
fadd qword ptr [ebx + FPx]
fstp qword ptr [ebx + FPx]
fadd qword ptr [eax + FPx]
fstp qword ptr [eax + FPx]
fmulp
fadd qword ptr [ebx + FPy]
fstp qword ptr [ebx + FPy]
fadd qword ptr [eax + FPy]
fstp qword ptr [eax + FPy]
fwait
{$endif}
end;
@ -1371,11 +1362,11 @@ begin
FPy := FPy + r * FTy;
{$else}
asm
mov edx, [ebx + vars]
mov edx, [eax + vars]
fld qword ptr [edx + 23*8]
fadd st, st
fld qword ptr [ebx + FTy]
fld qword ptr [ebx + FTx]
fld qword ptr [eax + FTy]
fld qword ptr [eax + FTx]
fld st(1)
fmul st, st
fld st(1)
@ -1386,11 +1377,11 @@ asm
faddp
fdivp st(3), st
fmul st, st(2)
fadd qword ptr [ebx + FPx]
fstp qword ptr [ebx + FPx]
fadd qword ptr [eax + FPx]
fstp qword ptr [eax + FPx]
fmulp
fadd qword ptr [ebx + FPy]
fstp qword ptr [ebx + FPy]
fadd qword ptr [eax + FPy]
fstp qword ptr [eax + FPy]
fwait
{$endif}
end;
@ -1407,8 +1398,8 @@ begin
FPy := FPy + r * FTy;
{$else}
asm
fld qword ptr [ebx + FTy]
fld qword ptr [ebx + FTx]
fld qword ptr [eax + FTy]
fld qword ptr [eax + FTx]
fld st(1)
fmul st, st
fld st(1)
@ -1420,14 +1411,14 @@ asm
fdivp st(1), st
fld1
fadd
mov edx, [ebx + vars]
mov edx, [eax + vars]
fdivr qword ptr [edx + 24*8]
fmul st(2), st
fmulp
fadd qword ptr [ebx + FPx]
fstp qword ptr [ebx + FPx]
fadd qword ptr [ebx + FPy]
fstp qword ptr [ebx + FPy]
fadd qword ptr [eax + FPx]
fstp qword ptr [eax + FPx]
fadd qword ptr [eax + FPy]
fstp qword ptr [eax + FPy]
fwait
{$endif}
end;
@ -1440,17 +1431,17 @@ begin
FPy := FPy + vars[25] * FTy;
{$else}
asm
mov edx, [ebx + vars]
mov edx, [eax + vars]
fld qword ptr [edx + 25*8]
fld qword ptr [ebx + FTx]
fld qword ptr [eax + FTx]
fsin
fld qword ptr [ebx + FTy]
fld qword ptr [eax + FTy]
fmul st, st(2)
fadd qword ptr [ebx + FPy]
fstp qword ptr [ebx + FPy]
fadd qword ptr [eax + FPy]
fstp qword ptr [eax + FPy]
fmulp
fadd qword ptr [ebx + FPx]
fstp qword ptr [ebx + FPx]
fadd qword ptr [eax + FPx]
fstp qword ptr [eax + FPx]
fwait
{$endif}
end;
@ -1465,27 +1456,27 @@ begin
FPy := FPy + vars[26] * (FTy + amplitude * sin(FTx * pi));
{$else}
asm
mov edx, [ebx + vars]
mov edx, [eax + vars]
fld qword ptr [edx + 26*8]
fld dword ptr [amplitude]
fld qword ptr [ebx + FTy]
fld qword ptr [eax + FTy]
fldpi
fld qword ptr [ebx + FTx]
fld qword ptr [eax + FTx]
fld st(2)
fmul st, st(2)
fsin
fmul st, st(4)
fadd st, st(1)
fmul st, st(5)
fadd qword ptr [ebx + FPx]
fstp qword ptr [ebx + FPx]
fadd qword ptr [eax + FPx]
fstp qword ptr [eax + FPx]
fmulp
fsin
fmulp st(2), st
faddp
fmulp
fadd qword ptr [ebx + FPy]
fstp qword ptr [ebx + FPy]
fadd qword ptr [eax + FPy]
fstp qword ptr [eax + FPy]
fwait
{$endif}
end;
@ -1580,6 +1571,24 @@ begin
// CPpoint.y := p[0,1] * FPx + p[1,1] * FPy + p[2,1];
end;
procedure TXForm.NextPointTo(var CPpoint, ToPoint: TCPpoint);
var
i: Integer;
begin
ToPoint.c := CPpoint.c * colorC1 + colorC2;
FTx := c00 * CPpoint.x + c10 * CPpoint.y + c20;
FTy := c01 * CPpoint.x + c11 * CPpoint.y + c21;
Fpx := 0;
Fpy := 0;
for i:= 0 to FNrFunctions-1 do
FCalcFunctionList[i];
ToPoint.x := FPx;
ToPoint.y := FPy;
end;
{
///////////////////////////////////////////////////////////////////////////////
@ -1659,18 +1668,18 @@ end;
}
///////////////////////////////////////////////////////////////////////////////
procedure TXForm.NextPoint2C(var px, py, pc1, pc2: double);
procedure TXForm.NextPoint2C(var p: T2CPoint);
var
i: Integer;
begin
// first compute the color coord
// pc1 := (pc1 + color) * 0.5 * (1 - symmetry) + symmetry * pc1;
// pc2 := (pc2 + color) * 0.5 * (1 - symmetry) + symmetry * pc2;
pc1 := pc1 * colorC1 + colorC2;
pc2 := pc2 * colorC1 + colorC2;
p.c1 := p.c1 * colorC1 + colorC2;
p.c2 := p.c2 * colorC1 + colorC2;
FTx := c00 * px + c10 * py + c20;
FTy := c01 * px + c11 * py + c21;
FTx := c00 * p.x + c10 * p.y + c20;
FTy := c01 * p.x + c11 * p.y + c21;
Fpx := 0;
Fpy := 0;
@ -1678,8 +1687,8 @@ begin
for i:= 0 to FNrFunctions-1 do
FCalcFunctionList[i];
px := FPx;
py := FPy;
p.x := FPx;
p.y := FPy;
// px := p[0,0] * FPx + p[1,0] * FPy + p[2,0];
// py := p[0,1] * FPx + p[1,1] * FPy + p[2,1];
end;

View File

@ -1,6 +1,6 @@
object frmPostProcess: TfrmPostProcess
Left = 38
Top = 43
Left = 61
Top = 77
Width = 640
Height = 534
Caption = 'Post Render'
@ -36,40 +36,75 @@ object frmPostProcess: TfrmPostProcess
Height = 13
Caption = 'Background Color'
end
object Label2: TLabel
Left = 12
Top = 34
Width = 24
Height = 13
Caption = 'Filter'
object pnlFilter: TPanel
Left = 8
Top = 32
Width = 97
Height = 21
Cursor = crHandPoint
BevelOuter = bvLowered
Caption = 'Filter Radius'
TabOrder = 13
OnDblClick = DragPanelDblClick
OnMouseDown = DragPanelMouseDown
OnMouseMove = DragPanelMouseMove
OnMouseUp = DragPanelMouseUp
end
object Label3: TLabel
Left = 172
Top = 12
Width = 35
Height = 13
Caption = 'Gamma'
object pnlVibrancy: TPanel
Left = 344
Top = 32
Width = 81
Height = 21
Cursor = crHandPoint
BevelOuter = bvLowered
Caption = 'Vibrancy'
TabOrder = 12
OnDblClick = DragPanelDblClick
OnMouseDown = DragPanelMouseDown
OnMouseMove = DragPanelMouseMove
OnMouseUp = DragPanelMouseUp
end
object Label4: TLabel
Left = 332
Top = 34
Width = 45
Height = 13
Caption = 'Vibrancy:'
end
object Label5: TLabel
Left = 332
Top = 12
Width = 42
Height = 13
Caption = 'Contrast'
end
object Label6: TLabel
Left = 172
Top = 34
Width = 50
Height = 13
object pnlBrightness: TPanel
Left = 184
Top = 32
Width = 81
Height = 21
Cursor = crHandPoint
BevelOuter = bvLowered
Caption = 'Brightness'
TabOrder = 10
OnDblClick = DragPanelDblClick
OnMouseDown = DragPanelMouseDown
OnMouseMove = DragPanelMouseMove
OnMouseUp = DragPanelMouseUp
end
object pnlContrast: TPanel
Left = 344
Top = 8
Width = 81
Height = 21
Cursor = crHandPoint
BevelOuter = bvLowered
Caption = 'Contrast'
TabOrder = 11
OnDblClick = DragPanelDblClick
OnMouseDown = DragPanelMouseDown
OnMouseMove = DragPanelMouseMove
OnMouseUp = DragPanelMouseUp
end
object pnlGamma: TPanel
Left = 184
Top = 8
Width = 81
Height = 21
Cursor = crHandPoint
BevelOuter = bvLowered
Caption = 'Gamma'
TabOrder = 9
OnDblClick = DragPanelDblClick
OnMouseDown = DragPanelMouseDown
OnMouseMove = DragPanelMouseMove
OnMouseUp = DragPanelMouseUp
end
object btnSave: TButton
Left = 552
@ -112,7 +147,7 @@ object frmPostProcess: TfrmPostProcess
end
object txtFilterRadius: TEdit
Left = 104
Top = 30
Top = 32
Width = 57
Height = 21
TabOrder = 2
@ -124,9 +159,9 @@ object frmPostProcess: TfrmPostProcess
Height = 21
TabOrder = 3
end
object txtVib: TEdit
object txtVibrancy: TEdit
Left = 424
Top = 30
Top = 32
Width = 57
Height = 21
TabOrder = 6
@ -140,7 +175,7 @@ object frmPostProcess: TfrmPostProcess
end
object txtBrightness: TEdit
Left = 264
Top = 30
Top = 32
Width = 57
Height = 21
TabOrder = 4

View File

@ -16,29 +16,47 @@ type
pnlBackColor: TPanel;
ColorDialog: TColorDialog;
ProgressBar1: TProgressBar;
Label2: TLabel;
btnApply: TButton;
txtFilterRadius: TEdit;
Label3: TLabel;
txtGamma: TEdit;
Label4: TLabel;
txtVib: TEdit;
Label5: TLabel;
txtVibrancy: TEdit;
txtContrast: TEdit;
Label6: TLabel;
txtBrightness: TEdit;
pnlGamma: TPanel;
pnlBrightness: TPanel;
pnlContrast: TPanel;
pnlVibrancy: TPanel;
pnlFilter: TPanel;
procedure btnSaveClick(Sender: TObject);
procedure btnApplyClick(Sender: TObject);
procedure FormDestroy(Sender: TObject);
procedure pnlBackColorClick(Sender: TObject);
procedure FormClose(Sender: TObject; var Action: TCloseAction);
procedure FormShow(Sender: TObject);
procedure DragPanelMouseDown(Sender: TObject; Button: TMouseButton;
Shift: TShiftState; X, Y: Integer);
procedure DragPanelMouseMove(Sender: TObject; Shift: TShiftState; X,
Y: Integer);
procedure DragPanelMouseUp(Sender: TObject; Button: TMouseButton;
Shift: TShiftState; X, Y: Integer);
procedure DragPanelDblClick(Sender: TObject);
private
{ Private declarations }
FRenderer: TBaseRenderer;
FCP: TControlPoint;
FImagename: string;
pnlDragMode, pnlDragged, pnlMM: boolean;
pnlDragPos, pnlDragOld: integer;
pnlDragValue: double;
mousepos: TPoint;
BkgColor: TColor;
Filter,
Gamma, Brightness,
Contrast, Vibrancy: double;
procedure UpdateFlame;
procedure SetDefaultValues;
@ -123,12 +141,18 @@ end;
///////////////////////////////////////////////////////////////////////////////
procedure TfrmPostProcess.SetDefaultValues;
begin
pnlBackColor.Color := RGB(Fcp.background[0], Fcp.background[1], Fcp.background[2]);
txtFilterRadius.Text := FloatTostr(FCP.spatial_filter_radius);
txtGamma.Text := FloatTostr(FCP.gamma);
txtVib.Text := FloatTostr(FCP.vibrancy);
txtContrast.Text := FloatTostr(FCP.contrast);
txtBrightness.Text := FloatTostr(FCP.brightness);
BkgColor := RGB(Fcp.background[0], Fcp.background[1], Fcp.background[2]);
pnlBackColor.Color := BkgColor;
Filter := FCP.spatial_filter_radius;
txtFilterRadius.Text := FloatTostr(Filter);
Gamma := FCP.gamma;
txtGamma.Text := FloatTostr(Gamma);
Vibrancy := FCP.vibrancy;
txtVibrancy.Text := FloatTostr(Vibrancy);
Contrast := FCP.contrast;
txtContrast.Text := FloatTostr(Contrast);
Brightness := FCP.brightness;
txtBrightness.Text := FloatTostr(brightness);
end;
///////////////////////////////////////////////////////////////////////////////
@ -201,13 +225,13 @@ begin
txtGamma.Text := FloatTostr(0.01);
end;
TryStrToFloat(txtVib.Text, FCP.vibrancy);
TryStrToFloat(txtVibrancy.Text, FCP.vibrancy);
if FCP.vibrancy > 10 then begin
FCP.vibrancy := 10;
txtVib.Text := '10';
txtVibrancy.Text := '10';
end else if FCP.vibrancy < 0.01 then begin
FCP.vibrancy := 0.01;
txtVib.Text := FloatTostr(0.01);
txtVibrancy.Text := FloatTostr(0.01);
end;
TryStrToFloat(txtContrast.Text, FCP.contrast);
@ -220,9 +244,9 @@ begin
end;
TryStrToFloat(txtBrightness.Text, FCP.brightness);
if FCP.brightness > 10 then begin
FCP.brightness := 10;
txtBrightness.Text := '10';
if FCP.brightness > 100 then begin
FCP.brightness := 100;
txtBrightness.Text := '100';
end else if FCP.brightness < 0.01 then begin
FCP.brightness := 0.01;
txtBrightness.Text := FloatTostr(0.01);
@ -243,5 +267,165 @@ begin
FImagename := imagename;
end;
///////////////////////////////////////////////////////////////////////////////
// -----------------------------------------------------------------------------
procedure TfrmPostProcess.DragPanelMouseDown(Sender: TObject;
Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
begin
if Button <> mbLeft then exit;
if (Sender = pnlFilter) then
pnlDragValue := fcp.spatial_filter_radius * 10
else if (Sender = pnlGamma) then
pnlDragValue := fcp.gamma
else if (Sender = pnlBrightness) then
pnlDragValue := fcp.brightness
else if (Sender = pnlContrast) then
pnlDragValue := fcp.contrast
else if (Sender = pnlVibrancy) then
pnlDragValue := fcp.vibrancy
else assert(false);
pnlDragMode := true;
pnlDragPos := 0;
pnlDragOld := x;
pnlMM := false;
SetCaptureControl(TControl(Sender));
Screen.Cursor := crHSplit;
GetCursorPos(mousepos); // hmmm
pnlDragged := false;
end;
procedure TfrmPostProcess.DragPanelMouseMove(Sender: TObject; Shift: TShiftState;
X, Y: Integer);
var
v: double;
pEdit: ^TEdit;
begin
if pnlMM then // hack: to skip MouseMove event
begin
pnlMM:=false;
end
else
if pnlDragMode and (x <> pnlDragOld) then
begin
Inc(pnlDragPos, x - pnlDragOld);
if GetKeyState(VK_MENU) < 0 then v := 100000
else if GetKeyState(VK_CONTROL) < 0 then v := 10000
else if GetKeyState(VK_SHIFT) < 0 then v := 100
else v := 1000;
v := Round6(pnlDragValue + pnlDragPos / v);
SetCursorPos(MousePos.x, MousePos.y); // hmmm
pnlMM:=true;
if (Sender = pnlFilter) then
begin
v := v / 10;
if v > 2 then v := 2
else if v < 0.01 then v := 0.01;
fcp.spatial_filter_radius := v;
pEdit := @txtFilterRadius;
end
else if (Sender = pnlGamma) then
begin
if v > 10 then v := 10
else if v < 0.01 then v := 0.01;
fcp.gamma := v;
pEdit := @txtGamma;
end
else if (Sender = pnlBrightness) then
begin
if v > 100 then v := 100
else if v < 0.01 then v := 0.01;
fcp.brightness := v;
pEdit := @txtBrightness;
end
else if (Sender = pnlContrast) then
begin
if v > 10 then v := 10
else if v < 0.01 then v := 0.01;
fcp.contrast := v;
pEdit := @txtContrast;
end
else if (Sender = pnlVibrancy) then
begin
if v > 10 then v := 10
else if v < 0.01 then v := 0.01;
fcp.vibrancy := v;
pEdit := @txtVibrancy;
end;
pEdit^.Text := FloatToStr(v);
//pEdit.Refresh;
pnlDragged := True;
// TODO: image preview (?)
//DrawPreview;
end;
end;
procedure TfrmPostProcess.DragPanelMouseUp(Sender: TObject; Button: TMouseButton;
Shift: TShiftState; X, Y: Integer);
begin
if Button <> mbLeft then exit;
if pnlDragMode then
begin
SetCaptureControl(nil);
pnlDragMode := false;
Screen.Cursor := crDefault;
if pnlDragged then
begin
UpdateFlame;
pnlDragged := False;
end;
end;
end;
procedure TfrmPostProcess.DragPanelDblClick(Sender: TObject);
var
pValue: ^double;
pDefaultValue: ^double;
pEdit: ^TEdit;
begin
if (Sender = pnlFilter) then
begin
pValue := @fcp.spatial_filter_radius;
pDefaultValue := @Filter;
pEdit := @txtFilterRadius;
end
else if (Sender = pnlGamma) then
begin
pValue := @fcp.gamma;
pDefaultValue := @Gamma;
pEdit := @txtGamma;
end
else if (Sender = pnlBrightness) then
begin
pValue := @fcp.brightness;
pDefaultValue := @Brightness;
pEdit := @txtBrightness;
end
else if (Sender = pnlContrast) then
begin
pValue := @fcp.contrast;
pDefaultValue := @Contrast;
pEdit := @txtContrast
end
else if (Sender = pnlVibrancy) then
begin
pValue := @fcp.vibrancy;
pDefaultValue := @Vibrancy;
pEdit := @txtVibrancy;
end
else assert(false);
if pValue^ = pDefaultValue^ then exit;
pValue^ := pDefaultValue^;
pEdit^.Text := FloatToStr(pValue^);
UpdateFlame;
end;
end.