-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwynik.pas
executable file
·830 lines (723 loc) · 20.7 KB
/
wynik.pas
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
unit wynik;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, ExtCtrls, StdCtrls, MT19937, ComCtrls, GBlur2, HSLUtils, ExtDlgs, info;
const
MAXATTR = 10000;
STEP = 2000;
type
PRGBArray = ^TRGBArray;
TRGBArray = array[Word] of TRGBTriple;
PRealValue = ^TRealValue;
TRealValue = record
value: Double;
next: PRealValue;
end;
TRealList = class(TPersistent)
private
start, last: PRealValue;
cnt: Integer;
public
constructor Create;
destructor Destroy; override;
procedure Add(const val: Double);
function Remove: Double;
function GetList: PRealValue;
published
property Count: Integer read cnt;
end;
TAttractorThread = class(TThread)
private
w,h,maxiter,num,funkcja,fseed, composite: Integer;
stretch: Boolean;
q, colorshift: Double;
timer: TDateTime;
procedure Rysuj(const x,y: TRealList; xmin, xmax, ymin, ymax: Double; const hxy: TRealList);
function GenerujAtraktor(const gen: Boolean): Boolean;
function NowyAtraktor: Integer;
protected
procedure Execute; override;
public
constructor Create(const seed, f, fx: Integer; const quality, shift: Double; const stretch: Boolean);
function IsRunning: Boolean;
procedure Stop;
end;
TImageForm = class(TForm)
Image: TImage;
SaveDialog: TSavePictureDialog;
procedure FormCreate(Sender: TObject);
procedure FormClose(Sender: TObject; var Action: TCloseAction);
public
th: TAttractorThread;
currseed: Integer;
procedure ZrobAtraktor(const w,h,seed, f, fx: Integer; const quality, shift: Double; const stretch: Boolean);
end;
var
ImageForm: TImageForm;
implementation
{$R *.dfm}
// Dodawanie do ListBoxa - ¿eby kod byl krótszy
procedure AddToLog(log: TListBox; const str: String);
begin
log.items.Add(str);
log.ItemIndex:= log.Count - 1;
log.Repaint;
end;
//////////////////////////////////////////////////////////// FUNKCJE KOLOROWANIA
{ Rysuje prostok¹t z o danym stopniu przezroczystosci }
procedure Prostokat(bitmap: TBitmap; const x,y,w,h,r,g,b: Integer; const a: Double);
var
i,j: Integer;
row: PRGBArray;
begin
for j:= y to y+h-1 do
begin
row:= bitmap.ScanLine[j];
for i:= x to x+w-1 do
begin
row[i].r:= trunc(row[i].r + (r - row[i].r) * a);
row[i].g:= trunc(row[i].g + (g - row[i].g) * a);
row[i].b:= trunc(row[i].b + (b - row[i].b) * a);
end;
end;
end;
{ Koloruje obrazek na podstawie innego }
function Colorize(const a,b: TBitmap): TBitmap;
var
i,j: Integer;
ha,sa,la,hb,sb,lb: Double;
rescol, acol, bcol: TColor;
resrow, arow, brow: PRGBArray;
begin
Result:= TBitmap.Create;
Result.Width:= a.Width;
Result.Height:= a.Height;
Result.PixelFormat:= pf24bit;
for j:= 0 to a.Height - 1 do
begin
resrow:= Result.ScanLine[j];
arow:= a.ScanLine[j];
brow:= b.ScanLine[j];
for i:= 0 to a.Width - 1 do
begin
acol:= rgb(arow[i].r, arow[i].g, arow[i].b);
bcol:= rgb(brow[i].r, brow[i].g, brow[i].b);
RGBtoHSL(acol, ha,sa,la);
RGBtoHSL(bcol, hb,sb,lb);
rescol:= HSLtoRGB(ha, sa, lb);
resrow[i].r:= GetRValue(rescol);
resrow[i].g:= GetGValue(rescol);
resrow[i].b:= GetBValue(rescol);
end;
end;
end;
{ Dodaje kolory dwóch obrazków do siebie }
procedure LinearDodgeSelf(const src: TBitmap; var dest: TBitmap);
var
i,j, r,g,b: Integer;
arow, brow: PRGBArray;
begin
for j:= 0 to src.Height - 1 do
begin
arow:= src.ScanLine[j];
brow:= dest.ScanLine[j];
for i:= 0 to src.Width - 1 do
begin
r:= arow[i].r + brow[i].r;
g:= arow[i].g + brow[i].g;
b:= arow[i].b + brow[i].b;
if r > 255 then r:= 255;
if g > 255 then g:= 255;
if b > 255 then b:= 255;
brow[i].r:= r;
brow[i].g:= g;
brow[i].b:= b;
end;
end;
end;
{ Przyciemnia obrazek w podanym stopniu }
procedure FadeSelf(var dest: TBitmap; const amount: Double);
var
i,j: Integer;
brow: PRGBArray;
begin
for j:= 0 to dest.Height - 1 do
begin
brow:= dest.ScanLine[j];
for i:= 0 to dest.Width - 1 do
begin
brow[i].r:= trunc(brow[i].r - brow[i].r * amount);
brow[i].g:= trunc(brow[i].g - brow[i].g * amount);
brow[i].b:= trunc(brow[i].b - brow[i].b * amount);
end;
end;
end;
//////////////////////////////////////////////////////////////////// LISTA LICZB
constructor TRealList.Create;
begin
start:= nil;
last:= nil;
cnt:= 0;
end;
destructor TRealList.Destroy;
begin
last:= nil;
while start <> nil do Remove;
start:= nil;
end;
procedure TRealList.Add(const val: Double);
var el: PRealValue;
begin
New(el);
el^.value:= val;
el^.next:= nil;
if start = nil then start:= el
else last^.next:= el;
last:= el;
end;
function TRealList.GetList;
begin
Result:= start;
end;
function TRealList.Remove;
var wywal: PRealValue;
begin
Result:= start^.value;
wywal:= start;
start:= start^.next;
Dispose(wywal);
end;
///////////////// G³ówny form
procedure TImageForm.FormCreate(Sender: TObject);
begin
currseed:= -1;
with Image.Picture.Bitmap do
begin
PixelFormat:= pf24bit;
Width:= Image.Width;
Height:= Image.Height;
end;
Image.Picture.Bitmap.Canvas.Brush.Color:= clBlack;
Image.Picture.Bitmap.Canvas.FillRect(ImageForm.Image.ClientRect);
end;
procedure TImageForm.FormClose(Sender: TObject; var Action: TCloseAction);
var
q: Integer;
begin
if th.IsRunning then
begin
q:= MessageBox(Handle, 'Czy na pewno chcesz przerwaæ generowanie atraktora?', 'Generator dziwnych atraktorów', MB_YESNO + MB_DEFBUTTON2 + MB_ICONQUESTION);
case q of
IDYES:
begin
th.Stop;
AddToLog(InfoForm.Log, 'Przerwano.');
InfoForm.Progress.Position:= 0;
end;
IDNO: Action:= caNone;
end;
end;
InfoForm.Close;
end;
procedure TImageForm.ZrobAtraktor(const w,h,seed, f, fx: Integer; const quality, shift: Double; const stretch: Boolean);
begin
if not InfoForm.running then
begin
ClientWidth:= w;
ClientHeight:= h;
Image.Picture.Bitmap.Width:= w;
Image.Picture.Bitmap.Height:= h;
Show;
// Ustawia formularz z logiem w odpowiednim miejscu
if (Top + Height + InfoForm.Height) <= (Screen.Height - 32) then
begin
InfoForm.Top:= Top + Height;
InfoForm.Left:= Left;
end;
th:= TAttractorThread.Create(seed, f, fx, quality, shift, stretch);
th.FreeOnTerminate:= true;
end;
end;
//////////////////////////////////////////////// W£AŒCIWE GENEROWANIE ATRAKTORÓW
constructor TAttractorThread.Create(const seed, f, fx: Integer; const quality, shift: Double; const stretch: Boolean);
begin
Randomize;
self.w:= ImageForm.Image.Width;
self.h:= ImageForm.Image.Height;
self.fseed:= seed;
self.maxiter:= trunc(2000000 * quality * (self.w*self.h)/262144);
self.funkcja:= f;
self.q:= quality;
self.stretch:= stretch;
self.composite:= fx;
self.timer:= Now;
self.colorshift:= shift;
InfoForm.Show;
InfoForm.Caption:= 'Generowanie atraktora...';
InfoForm.Log.Items.Clear;
InfoForm.Progress.Min:= 0;
InfoForm.Progress.Max:= self.maxiter;
InfoForm.Progress.Step:= 1;
inherited Create(false);
end;
procedure TAttractorThread.Execute;
begin
try
ImageForm.currseed:= NowyAtraktor;
except
on e: EOverflow do
begin
MessageBox(ImageForm.Handle, 'W trakcie generowania wyst¹pi³ b³¹d. Prawdopodobnie podany numer atraktora jest nieprawid³owy dla danej funkcji.'+#13#10+'Podaj inny numer lub pozostaw pole pustym.', 'Generator dziwnych atraktorów', MB_OK + MB_ICONERROR + MB_DEFBUTTON1);
InfoForm.running:= false;
ImageForm.Close;
end;
end;
end;
procedure TAttractorThread.Stop;
begin
InfoForm.running:= false;
Terminate;
end;
function TAttractorThread.IsRunning: Boolean;
begin
Result:= InfoForm.running;
end;
function TAttractorThread.NowyAtraktor: Integer;
var
seed: Integer;
done: Boolean;
caption: String;
begin
done:= false;
Result:= -1;
while not done and not Terminated do
begin
InfoForm.running:= true;
inc(num);
// Jest limit atraktorów, ¿eby nie lecia³ w kó³ko
if num > MAXATTR then
begin
AddToLog(InfoForm.Log, 'Osi¹gniêto limit atraktorów, przerywanie');
InfoForm.running:= false;
Result:= -1;
Exit;
end;
// Losowanie numeru
if fseed = -1 then
seed:= Random($0fffffff)
else
seed:= fseed;
sgenrand_MT19937(seed);
// Tytu³ formularza
case funkcja of
0: caption:= 'Kwadratowa (';
1: caption:= 'Trygonometryczna (';
2: caption:= 'Henon (';
3: caption:= 'Peter de Jong Mod (';
4: caption:= 'Peter de Jong (';
5: caption:= 'Tinkerbell (';
6: caption:= 'Ikeda (';
end;
caption:= caption + inttostr(seed) + ')';
ImageForm.Caption:= caption;
InfoForm.Progress.Position:= 0;
AddToLog(InfoForm.Log, Format('Generowanie atraktora (numer: %d)...', [seed]));
done:= GenerujAtraktor((fseed = -1));
if not done then fseed:= -1;
Result:= seed;
end;
Stop;
end;
function TAttractorThread.GenerujAtraktor(const gen: Boolean): Boolean;
var
ax, ay: array [0..5] of Double;
xmin, xmax, ymin, ymax: Double;
d0,dd,dx,dy,lapunow: Double;
xe,ye,nowexe,noweye: Double;
i, etap: Integer;
loop, fail: Boolean;
j: Integer;
hxy, x1, y1, xx, yy, xy, xi, yi, xexe, xeye, yeye, absdx, absdy, absddd0, t: Double;
begin
Result:= true;
// Czyszczenie obrazka
with ImageForm.Image.Picture.Bitmap.Canvas do
begin
Brush.Color:= clBlack;
FillRect(ImageForm.Image.ClientRect);
end;
// Losowanie parametrów
for i:=0 to 5 do
begin
ax[i]:= 4 * (randFloat_MT19937 - 0.5);
ay[i]:= 4 * (randFloat_MT19937 - 0.5);
end;
// Od teraz dzialamy bez list!!!111
x1 := randFloat_MT19937 - 0.5;
y1 := randFloat_MT19937 - 0.5;
lapunow:= 0;
xmin:= 1e32;
xmax:= -1e32;
ymin:= 1e32;
ymax:= -1e32;
xe:= x1 + (randFloat_MT19937 - 0.5) / 1000;
ye:= y1 + (randFloat_MT19937 - 0.5) / 1000;
dx:= x1 - xe;
dy:= y1 - ye;
d0:= sqrt(dx*dx + dy*dy);
i:= 1;
for etap:= 1 to 2 do
begin
// G³ówna pêtla
loop:= true;
repeat
fail:= false;
j:= 0;
// Generowanie etapami (¿eby nie odœwie¿ac tak czêsto)
while (j < STEP) and (i < maxiter) and not Terminated do
begin
x1:= lx^.value;
y1:= ly^.value;
xx:= x1*x1;
yy:= y1*y1;
xy:= x1*y1;
// Dodawanie wartosci szeregu
xi:= 0;
yi:= 0;
case funkcja of
0: // Kwadratowa
begin
xi:= ax[0] + ax[1]*x1 + ax[2]*xx + ax[3]*xy + ax[4]*y1 + ax[5]*yy;
yi:= ay[0] + ay[1]*x1 + ay[2]*xx + ay[3]*xy + ay[4]*y1 + ay[5]*yy;
end;
1: // Trygonometryczna
begin
xi:= ax[0] * sin(ax[1]*y1) + ax[2] * cos(ax[3]*x1);
yi:= ay[0] * sin(ay[1]*x1) + ay[2] * cos(ay[3]*y1);
end;
2: // Henon
begin
xi:= y1 + 1 - 1.4*xx;
yi:= 0.3 * x1;
end;
3: // de Jong - zmodyfikowany
begin
xi:= ax[0] * sin(ax[1]*y1) - cos(ax[2]*x1);
yi:= ay[0] * sin(ax[1]*x1) - cos(ax[2]*y1);
end;
4: // de Jong
begin
xi:= sin(ax[0]*y1) - cos(ax[1]*x1);
yi:= sin(ay[0]*x1) - cos(ay[1]*y1);
end;
5: // Tinkerbell
begin
xi:= xx - yy + ax[0]*x1 + ax[1]*y1;
yi:= 2*xy + ay[0]*x1 + ay[1]*y1;
end;
6: // Ikeda
begin
t:= 0.4 - 6 / (1 + xx + yy);
xi:= 1 + ax[0] * (x1*cos(t) - y1*sin(t));
yi:= ax[0] * (x1*sin(t) + y1*cos(t));
end;
end;
x.Add(xi);
y.Add(yi);
// Wyliczanie nowych wartosci granicznych
if xi < xmin then xmin:= xi;
if yi < ymin then ymin:= yi;
if xi > xmax then xmax:= xi;
if yi > ymax then ymax:= yi;
// Wyliczanie wartosci w celu kolorowania wg "szybkosci" punktow
if (composite > 0) and (i > 100) then
begin
dx:= (xi-x1) / (xmax-xmin);
dy:= (yi-y1) / (ymax-ymin);
hxy.Add(dx*dx+dy*dy);
end;
// Sprawdzanie numeru tylko je¿eli jest losowy
if gen then
begin
// Czy szereg d¹¿y do nieskoñczonoœci
if (xmin < -1e10) or (ymin < -1e10) or (xmax > 1e10) or (ymax > 1e10) then
begin
fail:= true;
Break;
end;
xexe:= xe*xe;
xeye:= xe*ye;
yeye:= ye*ye;
case funkcja of
0: // Kwadratowa
begin
nowexe:= ax[0] + ax[1]*xe + ax[2]*xexe + ax[3]*xeye + ax[4]*ye + ax[5]*yeye;
noweye:= ay[0] + ay[1]*xe + ay[2]*xexe + ay[3]*xeye + ay[4]*ye + ay[5]*yeye;
end;
1: // Trygonometryczna
begin
nowexe:= ax[0] * sin(ax[1]*ye) + ax[2] * cos(ax[3]*xe);
noweye:= ay[0] * sin(ay[1]*xe) + ay[2] * cos(ay[3]*ye);
end;
2: // Henon
begin
nowexe:= ye + 1 - 1.4*xexe;
noweye:= 0.3 * xe;
end;
3: // de Jong - zamodyfikowany
begin
nowexe:= ax[0] * sin(ax[1]*ye) - cos(ax[2]*xe);
noweye:= ay[0] * sin(ax[1]*xe) - cos(ax[2]*ye);
end;
4: // de Jong
begin
nowexe:= sin(ax[0]*ye) - cos(ax[1]*xe);
noweye:= sin(ay[0]*xe) - cos(ay[1]*ye);
end;
5: // Tinkerbell
begin
nowexe:= xexe - yeye + ax[0]*xe + ax[1]*ye;
noweye:= 2*xeye + ay[0]*xe + ay[1]*ye;
end;
6: // Ikeda
begin
t:= 0.4 - 6 / (1 + xexe + yeye);
nowexe:= 1 + ax[0] * (xe*cos(t) - ye*sin(t));
noweye:= ax[0] * (xe*sin(t) + ye*cos(t));
end;
end;
// Czy szereg d¹¿y do punktu
dx:= lx^.next^.value - x1;
dy:= ly^.next^.value - y1;
if (abs(dx) < 1e-10) and (abs(dy) < 1e-10) then
begin
fail:= true;
Break;
end;
// Liczenie wyk³adnika Lapunowa
if i>1000 then
begin
dx:= lx^.next^.value - nowexe;
dy:= ly^.next^.value - noweye;
dd:= sqrt(dx*dx + dy*dy);
lapunow:= lapunow + ln(abs(dd / d0));
xe:= lx^.next^.value + d0 * dx / dd;
ye:= ly^.next^.value + d0 * dy / dd;
end;
end;
lx:= lx^.next;
ly:= ly^.next;
inc(i);
inc(j);
end;
if (i < maxiter) and not fail then
begin
InfoForm.Progress.StepBy(STEP);
end
else
begin
// Generowanie zakoñczone, sprawdzanie wykladnika Lapunowa
if gen then
if not fail then
begin
if abs(lapunow) < 10 then
begin
AddToLog(InfoForm.Log, 'Znaleziono szereg neutralnie stabilny, przerywanie');
fail:= true;
end
else if lapunow < 0 then
begin
AddToLog(InfoForm.Log, 'Znaleziono szereg okresowy, przerywanie');
fail:= true;
end
else
AddToLog(InfoForm.Log, 'Znaleziono szereg chaotyczny');
end;
loop:= false;
end;
until (not loop) or Terminated;
// Przejscie do rysowania
if ((not fail) or (not gen)) and not Terminated then
begin
AddToLog(InfoForm.Log, 'Rysowanie atraktora...');
Rysuj(x,y,xmin,xmax,ymin,ymax,hxy);
end;
lx:= nil;
ly:= nil;
x.Free;
y.Free;
hxy.Free;
Result:= not fail;
end;
procedure TAttractorThread.Rysuj(const x,y: TRealList; xmin, xmax, ymin, ymax: Double; const hxy: TRealList);
var
i, ix, iy, r,g,b: Integer;
hue, bhue, fx, fy, xrange, yrange: Double;
blur, colored, blurred, bluratr, cnv, glow, back: TBitmap;
loop: Boolean;
j, c, off, bx, by: Integer;
col: TColor;
row: PRGBArray;
begin
InfoForm.Progress.Position:= 0;
// Przygotowanie obrazków
blur:= TBitmap.Create;
with blur do
begin
Width:= w;
Height:= h;
PixelFormat:= pf24bit;
Canvas.Brush.Color:= clBlack;
Canvas.FillRect(ImageForm.Image.ClientRect);
end;
cnv:= TBitmap.Create;
with cnv do
begin
Width:= w;
Height:= h;
PixelFormat:= pf24bit;
Canvas.Brush.Color:= clBlack;
Canvas.FillRect(ImageForm.Image.ClientRect);
end;
// Zakres rysowania
xrange:= (xmax-xmin) / 0.8;
yrange:= (ymax-ymin) / 0.8;
// Dostosowanie zakresu je¿eli nie rozci¹gamy atraktora
if not stretch then
begin
if yrange > xrange then
begin
xmin:= xmin - (yrange-xrange)/2;
xmax:= xmax - (yrange-xrange)/2;
xrange:= yrange;
end
else if xrange > yrange then
begin
ymin:= ymin - (xrange-yrange)/2;
ymax:= ymax - (xrange-yrange)/2;
yrange:= xrange;
end;
end;
// Wyliczanie koloru pocz¹tkowego
hue:= randFloat_MT19937 + colorshift;
while hue > 1 do hue:= hue - 1;
i:= 0;
loop:= true;
repeat
c:= round(1.5 / q);
j:=0;
while (j < STEP) and (i < maxiter) and not Terminated do
begin
// Wyliczanie wspólrzêdnych punktu na ekranie
fx:= (x.Remove - xmin) / xrange + 0.1;
fy:= (y.Remove - ymin) / yrange + 0.1;
ix:= trunc(fx*w);
iy:= trunc(fy*h);
if i > 100 then
begin
// Rysowanie punktu
row:= cnv.ScanLine[iy];
r:= row[ix].r + c;
g:= row[ix].g + c;
b:= row[ix].b + c;
if r > 255 then r:= 255;
if g > 255 then g:= 255;
if b > 255 then b:= 255;
row[ix].r:= r;
row[ix].g:= g;
row[ix].b:= b;
// Rysowanie prostok¹ta w odpowiednim kolorze na osobnym obrazku
if (composite > 0) then
if i < STEP*25 then
begin
bhue:= hue + hxy.Remove / 3;
while bhue > 1 do bhue:= bhue - 1;
col:= HSLtoRGB(bhue, 1, 0.6);
off:= 5;
bx:= trunc(ix-off);
by:= trunc(iy-off);
Prostokat(blur, bx, by, 2*off, 2*off, GetRValue(col), GetGValue(col), GetBValue(col), 0.075);
end;
end;
inc(i);
inc(j);
end;
if i < maxiter then
begin
if (i mod (STEP*10)) = 0 then
ImageForm.Image.Picture.Graphic:= cnv;
InfoForm.Progress.StepBy(STEP);
end
else
begin
ImageForm.Image.Picture.Graphic:= cnv;
if (composite > 0) then
begin
// Kolorowanie
AddToLog(InfoForm.Log, 'Kolorowanie');
InfoForm.Progress.Position:= 0;
InfoForm.Progress.Step:= 1;
InfoForm.Progress.Max:= 4;
// 1/4
blurred:= TBitmap.Create;
blurred.Assign(blur);
GBlur(blurred, 5);
colored:= Colorize(blurred, cnv);
blurred.Free;
ImageForm.Image.Picture.Graphic:= colored;
InfoForm.Progress.StepIt;
// 2/4
if composite > 1 then
begin
bluratr:= TBitmap.Create;
bluratr.Assign(cnv);
GBlur(bluratr, 2.5);
LinearDodgeSelf(bluratr, colored);
bluratr.Free;
ImageForm.Image.Picture.Graphic:= colored;
end;
InfoForm.Progress.StepIt;
// 3/4
if composite > 2 then
begin
glow:= TBitmap.Create;
glow.Assign(colored);
GBlur(glow, 10);
FadeSelf(glow, 0.7);
LinearDodgeSelf(glow, colored);
glow.Free;
ImageForm.Image.Picture.Graphic:= colored;
end;
InfoForm.Progress.StepIt;
// 4/4
back:= TBitmap.Create;
back.Assign(colored);
GBlur(back, sqrt(w*h)*0.125);
FadeSelf(back, 0.5);
LinearDodgeSelf(back, colored);
ImageForm.Image.Picture.Graphic:= colored;
back.Free;
colored.Free;
InfoForm.Progress.StepIt;
AddToLog(InfoForm.Log, 'Gotowe! Czas: '+FormatDateTime('hh:nn:ss', Now - timer));
InfoForm.Caption:= 'Gotowe';
InfoForm.Progress.Position:= 0;
end
else
begin
AddToLog(InfoForm.Log, 'Gotowe! Czas: '+FormatDateTime('hh:nn:ss', Now - timer));
InfoForm.Caption:= 'Gotowe';
InfoForm.Progress.Position:= 0;
end;
loop:= false;
end;
until (not loop) or Terminated;
row:= nil;
blur.Free;
cnv.Free;
{x.Free;
y.Free;
hxy.Free;}
end;
end.