Autor Beitrag
ALF
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 1085
Erhaltene Danke: 53

WinXP, Win7, Win10
Delphi 7 Enterprise, XE
BeitragVerfasst: Mi 03.11.10 16:26 
Dabei hab ich das schon mal gemacht :oops: Allerdings von einem vorgegenen RGB zu weiss
Hier mal mein Code. Die Vorlage hab ich von user profile iconjaenicke.
zur Erklärung, es sollen nur die letzten 70 Pixel von 200 in der Breite ein Farbverlauf erhalten.
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
if FillSize > 130 then
begin
    RValueInc := GetRValue(FEndColor - FStartColor) / W-130;// W = 200 Pixel
    GValueInc := GetGValue(FEndColor - FStartColor) / W-130;
    BValueInc := GetBValue(FEndColor - FStartColor) / W-130;
    for I:= 130 to FillSize do
    begin  //ab hier passiert alles mögliche nur nicht der gewünschte Farbverlauf
        Pen.Color := FStartColor + RGB(Round((i-130) * RValueInc), Round((i-130) * GValueInc),Round((i-130) * BValueInc));

       //Pen.Color:=  RGB(Round((RValueInc+(255-RValueInc))/ (W-130)*(I-130)), Round((GValueInc+(255-GValueInc))/ (W-130)*(I-130)),Round((BValueInc+(255-BValueInc))/ (W-130)*(I-130)));
        
        moveto(I, 0);
        LineTo(I, W);
    end;
end;
Wo hab ich da schon wiedermal einen Denkfehler? Ich erhalte zwar ein Farbverlauf aber nicht in den Farben von StartColor zu EndColor. Dabei ist es nur Mathe, aber in welcher Reihenfolge? :gruebel:

Gruss Alf

_________________
Wenn jeder alles kann oder wüsste und keiner hätt' ne Frage mehr, omg, währe dieses Forum leer!
Oliver Marx
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 80
Erhaltene Danke: 18

Win 7 Prof.
Delphi XE Prof.
BeitragVerfasst: Mi 03.11.10 17:55 
Hi,

ich glaube, du hast da nur ein paar Klammern vergessen.

ausblenden Delphi-Quelltext
1:
2:
3:
    RValueInc := GetRValue(FEndColor - FStartColor) / (W-130);// W = 200 Pixel
    GValueInc := GetGValue(FEndColor - FStartColor) / (W-130);
    BValueInc := GetBValue(FEndColor - FStartColor) / (W-130);


Viele Grüße

Oliver
ALF Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 1085
Erhaltene Danke: 53

WinXP, Win7, Win10
Delphi 7 Enterprise, XE
BeitragVerfasst: Mi 03.11.10 18:47 
Ne, gerade rausgefunden das kann so nicht funcen. Ich muss wahrscheinlich für beide, StartColor und EndColor, ne differenz zu 255 machen oder zur Pixelzahl oder so :gruebel: Weil, wenn StartColor > als EndColor oder auch umgekehrt, irgendwann ja der RGBWert >255 bzw <0 wird zur Pixelzahl mh.... :?!?: Blöde Logik
DAs wird ja richtig kompliziert :eyecrazy:
Edit: Leider noch nicht ganz? Aber fast, der Anfangswert stimmt nicht ganz?

ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
if fillSize > 130 then
begin
    RsValue:= GetRValue(FStartColor);
    GsValue:= GetGValue(FStartColor);
    BsValue:= GetBValue(FStartColor);
    
    ReValue:= GetRValue(FEndColor);
    GeValue:= GetGValue(FEndColor);
    BsValue:= GetBValue(FEndColor);
    
    for I:=130 to FillSize do
    begin
        Pen.Color:=  RGB(Round(RsValue +(ReValue-RsValue)/ (W-130)*(I-130)),
                         Round(GsValue +(GeValue-GsValue)/ (W-130)*(I-130)),
                         Round(BsValue +(BeValue-BsValue)/ (W-130)*(I-130)));

        moveto(I, 0);
        LineTo(I, W);
    end;
end;


Gruss ALf

_________________
Wenn jeder alles kann oder wüsste und keiner hätt' ne Frage mehr, omg, währe dieses Forum leer!
platzwart
ontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic starofftopic star
Beiträge: 1054
Erhaltene Danke: 78

Win 7, Ubuntu 9.10
Delphi 2007 Pro, C++, Qt
BeitragVerfasst: Mi 03.11.10 19:35 
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
    RsValue:= GetRValue(FStartColor);
    GsValue:= GetGValue(FStartColor);
    BsValue:= GetBValue(FStartColor);
    
    ReValue:= GetRValue(FEndColor);
    GeValue:= GetGValue(FEndColor);
    BsValue:= GetBValue(FEndColor);

_________________
Wissenschaft schafft Wissenschaft, denn Wissenschaft ist Wissenschaft, die mit Wissen und Schaffen Wissen schafft. (myself)
ALF Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 1085
Erhaltene Danke: 53

WinXP, Win7, Win10
Delphi 7 Enterprise, XE
BeitragVerfasst: Mi 03.11.10 19:44 
Ach ich liebe meine Blindheit

THX nun klappts auch mit der Farbe.

Gruss Alf

_________________
Wenn jeder alles kann oder wüsste und keiner hätt' ne Frage mehr, omg, währe dieses Forum leer!