Autor Beitrag
GericasS
ontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic starofftopic star
Beiträge: 540

Windows Vista Home Premium
D2010, VisualStudio2008
BeitragVerfasst: Mi 24.10.07 10:36 
Morgen DF,

hab heute mal etwas mit zufälligen Farben versucht.

ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
procedure TForm1.Timer1Timer(Sender: TObject);
begin
  Randomize ;
  Edit1.Text := IntToStr(random(1000)) ;
  Edit1.Color := random(255) ;
end;
end.


Jetzt hab ich nur das Problem das sich das edit nur in rot Tönen färbt.
Wie ich aus meiner Design Erfahrung dachte, arbeitet Delphi auch mit
RGB also 255,255,255 wenn ich damit nicht falsch liege ?
Nur wie bekomme ich die andren beiden Werte für G(grün) B(Blau) noch in
den Random Befehl ?

ich hatte es schon auf folgende Art und Weise versucht.

ausblenden Delphi-Quelltext
1:
Edit1.Color := random(255,255,255) ;					


aber das funktioniert auch nicht :(

Grüße

GericasS :D:D

_________________
Alexander N.
Neue Bewaffnung Amilo xi2428 T9300
Gausi
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 8554
Erhaltene Danke: 481

Windows 7, Windows 10
D7 PE, Delphi XE3 Prof, Delphi 10.3 CE
BeitragVerfasst: Mi 24.10.07 10:37 
ausblenden Delphi-Quelltext
1:
Edit1.Color := random($ffffff)					

_________________
We are, we were and will not be.
GericasS Threadstarter
ontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic starofftopic star
Beiträge: 540

Windows Vista Home Premium
D2010, VisualStudio2008
BeitragVerfasst: Mi 24.10.07 10:42 
user profile iconGausi hat folgendes geschrieben:
ausblenden Delphi-Quelltext
1:
Edit1.Color := random($ffffff)					


Hey,

danke dir funktioniert super !

Jetzt aber die Frage warum der Wert für weiß ?

_________________
Alexander N.
Neue Bewaffnung Amilo xi2428 T9300
Narses
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Administrator
Beiträge: 10185
Erhaltene Danke: 1261

W11x64
TP3 .. D7pro .. D10.2CE
BeitragVerfasst: Mi 24.10.07 10:46 
Moin!

ausblenden Delphi-Quelltext
1:
Edit1.Color := Random($1000000);					

Korrekt wäre das, Random liefert ja 0..N-1. ;)

cu
Narses

_________________
There are 10 types of people - those who understand binary and those who don´t.
Gausi
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 8554
Erhaltene Danke: 481

Windows 7, Windows 10
D7 PE, Delphi XE3 Prof, Delphi 10.3 CE
BeitragVerfasst: Mi 24.10.07 10:47 
Weil $ffffff einfach die größte 24-Bit-Zahl ist, die es gibt, und ein TColor-Wert ist nichts anderes als eine Zahl zwischen 0 und 256^3 (oder halt $ffffff). Den Alpha-Kanal lassen wir einfach mal weg :mrgreen:.

@Narses: Hast natürlich recht. :oops:

_________________
We are, we were and will not be.
GericasS Threadstarter
ontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic starofftopic star
Beiträge: 540

Windows Vista Home Premium
D2010, VisualStudio2008
BeitragVerfasst: Mi 24.10.07 10:49 
@ Narses und Gausi :

Danke euch beiden für die Erklärung und den Code, ja den AKanal lassen wir mal weg :mrgreen:

_________________
Alexander N.
Neue Bewaffnung Amilo xi2428 T9300
Narses
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Administrator
Beiträge: 10185
Erhaltene Danke: 1261

W11x64
TP3 .. D7pro .. D10.2CE
BeitragVerfasst: Mi 24.10.07 11:02 
Moin!

@Alpha-Kanal: :gruebel: War das speziell bei TColor-Werten nicht so, dass das oberste Byte eben nicht das Alpha darstellt, sonden spezielle Farben aus der Systempalette? :nixweiss:

cu
Narses

_________________
There are 10 types of people - those who understand binary and those who don´t.
GericasS Threadstarter
ontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic starofftopic star
Beiträge: 540

Windows Vista Home Premium
D2010, VisualStudio2008
BeitragVerfasst: Mi 24.10.07 11:07 
Also,

so weit ich weiß ist der Alphakanal ein weiterer Kanal, der Werte wie die Transparenz bzw. Sichtbarkeit speichert. Bin mir aber nicht so sicher kannst ja mal bei Wiki nachlesen !

_________________
Alexander N.
Neue Bewaffnung Amilo xi2428 T9300
Narses
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Administrator
Beiträge: 10185
Erhaltene Danke: 1261

W11x64
TP3 .. D7pro .. D10.2CE
BeitragVerfasst: Mi 24.10.07 11:15 
Moin!

Ja, im Allgemeinen haste auch Recht, also für pf32Bitist das auch so. ;) Aber z.B. bei Farben für Komponenten sind so die Farben aus der Systempalette drüber gemapped. Wie gesagt, weiß ich nicht mehr soo genau (hab ich mal wo gelesen :nixweiss:), müßte man mal im VCL-Source stöbern bzw. API-Doku wälzen. :?

cu
Narses

_________________
There are 10 types of people - those who understand binary and those who don´t.
GericasS Threadstarter
ontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic starofftopic star
Beiträge: 540

Windows Vista Home Premium
D2010, VisualStudio2008
BeitragVerfasst: Mi 24.10.07 11:19 
Hey,

also das vertieft sich jetzt leider zu sehr in Delphi etc. ich habe Ahnung von der Verwenung in Photoshop etc. aber nicht in der Programmierung. Denke mal Gausi weiß das besser :)

_________________
Alexander N.
Neue Bewaffnung Amilo xi2428 T9300
Lossy eX
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 1048
Erhaltene Danke: 4



BeitragVerfasst: Mi 24.10.07 11:24 
Narsens: Ja. Eigentlich hast du recht. So etwas wie clBtnFace ist als FF000000 + 15 deklariert. Also das ist eine ganz spezielle Konstante. Und TColor ist als -$7FFFFFFF-1..$7FFFFFFF. Also genau genommen wäre ein sauberes Abbilden des Alphas mit TColor nicht möglich. Da es eigentlich ein Cardinal sein müsste. Wobei es aber beides 32 Bit Werte sind.

Aber generell , bis auf 1-2 Ausnahmen, wird der Alpha auch komplett von der GDI ignoriert weswegen der sowieso nur bei anderen Sachen zum Tragen kommt. Und für Bitmaps würde ich auch grundsätzlich TRGBQuad oder TRGBTriple benutzen.

_________________
Nur die Menschheit ist arrogant genug, um zu glauben sie sei die einzige intelligente Lebensform im All. Wo nicht mal das nachhaltig bewiesen wurde.