was ist neu ¦  programmier tips ¦  indy artikel ¦  intraweb artikel ¦  informationen ¦  links ¦  interviews
 sonstiges ¦  tutorials ¦  Add&Win Gewinnspiel

Tips (1541)

Dateien (137)
Datenbanken (90)
Drucken (35)
Grafik (114)
IDE (21)
Indy (5)
Internet / LAN (130)
IntraWeb (0)
Mathematik (76)
Multimedia (45)
Oberfläche (107)
Objekte/
ActiveX (51)

OpenTools API (3)
Sonstiges (126)
Strings (83)
System (266)
VCL (242)

Tips sortiert nach
Komponente


Tip suchen

Tip hinzufügen

Add&Win Gewinnspiel

Werbung

48 Visitors Online


 
...einen TColor verdunkeln oder aufhellen?
Autor: TheB_6030
Homepage: http://nav.to/PenguinProductions/
[ Tip ausdrucken ]  

Tip Bewertung (12):  
     


// Takes a TColor and returns either the lighter or darker color, depending on
// the supplied integer (percentage of original to add or subtract)
// I don't know if this is 100% correct - I did it away from my computer.

function TMainForm.ChangeColor(InputColor: TColor; Lighten: Boolean; n: Extended): TColor;
var
  
r,g,b: extended;
begin
  
// Grab RGB values
  
r := GetRValue(InputColor);
  g := GetGValue(InputColor);
  b := GetBValue(InputColor);
  // Do the operation
  
if Lighten = True then
  begin
    
r := r+((r/255)*100);
    g := g+((g/255)*100);
    b := b+((b/255)*100);
  end else
  begin
    
r := r-((r/255)*100);
    g := g-((g/255)*100);
    b := b-((b/255)*100);
  end;
  // Check whether result is in range
  
if r > 255 then r := 255;
  if r < 0 then r := 0;
  if g > 255 then g := 255;
  if g < 0 then g := 0;
  if b > 255 then b := 255;
  if b < 0 then b := 0;
  // Send it out
  
Result := RGB(byte(Round(r)),byte(Round(g)),byte(Round(b)));
end;

 

Bewerten Sie diesen Tipp:

dürftig
ausgezeichnet


Copyright © by SwissDelphiCenter.ch
All trademarks are the sole property of their respective owners