Autor Beitrag
F34r0fTh3D4rk
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 5284
Erhaltene Danke: 27

Win Vista (32), Win 7 (64)
Eclipse, SciTE, Lazarus
BeitragVerfasst: Mo 19.06.06 14:56 
ich wusste nicht, wie ich den titel besser formulieren hätte können, nunja, ich habe einen rekursiven gradient algo angefangen, der auch soweit super funzt:
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
procedure gradient(image: Timage; col1, col2: TColor; Startp, Endp: integer; ainc: integer);
var
  newp: integer;
  newcol: TColor;
begin
  newp := (startp + (endp - startp) div 2);
  newcol := RGB((getrvalue(col1) + getrvalue(col2)) div 2, (getgvalue(col1) + getgvalue(col2)) div 2, (getbvalue(col1) + getbvalue(col2)) div 2);
  with image.Canvas do
  begin
    pen.color := newcol;
    MoveTo(newp, 0);
    LineTo(newp, image.Height - 1);
  end;
  if ainc <= 7 then
  begin
    gradient(image, col1, newcol, startp, newp, ainc + 1);
    gradient(image, newcol, col2, newp, endp, ainc + 1);
  end;
end;

procedure TMainForm.Button4Click(Sender: TObject);
begin
  gradient(image1, clred, claqua, 0, image1.width - 10);
end;


problem macht mir die markierte zeile, denn ab dem wert 7 scheint der übergang fließend zu sein, jedoch weiß ich nicht wie ich die 7 berechne, ich dachte da pro rekursionsebene immer 2 prozeduren instanziert werden, dass es dann 2^x wäre, aber dem ist leider nicht so, wie kommt man auf diesen wert ?

(und nein ich möchte den algo net anders haben ^^)

//EDIT: gelöst ;)

mfg
GTA-Place
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
EE-Regisseur
Beiträge: 5248
Erhaltene Danke: 2

WIN XP, IE 7, FF 2.0
Delphi 7, Lazarus
BeitragVerfasst: Mo 19.06.06 18:33 
Einfach if ainc <= 7 then durch if ((EndP - StartP) div 2) > 0 then ersetzen.

_________________
"Wer Ego-Shooter Killerspiele nennt, muss konsequenterweise jeden Horrorstreifen als Killerfilm bezeichnen." (Zeit.de)
F34r0fTh3D4rk Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 5284
Erhaltene Danke: 27

Win Vista (32), Win 7 (64)
Eclipse, SciTE, Lazarus
BeitragVerfasst: Mo 19.06.06 19:29 
jo danke, ich stand aufm schlauch :lol: