Einzelnen Beitrag anzeigen

SvenLittkowski

Registriert seit: 18. Dez 2004
98 Beiträge
 
#8

AW: Komponente: noch grün hinter den Ohren

  Alt 10. Feb 2011, 15:49
Hier der inzwischen veränderte Code.

Code:
unit ColorMixer;

interface

  uses
    SysUtils, WinTypes, WinProcs, Messages, Classes, Graphics, Controls,
    Forms, Dialogs, StdCtrls;

  type
    TColorMixer=class(TComponent)
    private
      FColor1_Original:      TColor;
      FColor2_Added:         TColor;
      FMixStrengthPercentage: Byte;
      FColor3_Result:        TColor;
      SetColor3_Result:      TColor;
    protected
      function Colorize(Sender: TObject; ColorOriginal, ColorAdded: TColor; PercentageStrength: Byte): TColor;
    public
      constructor Create( AOwner: TComponent); override;
    published
      property Color1_Original:      TColor read   FColor1_Original      write SetColor1_Original       default clBlack;
      property Color2_Added:         TColor read   FColor2_Added         write SetColor2_Added          default clWhite;
      property MixStrengthPercentage: Byte  read   FMixStrengthPercentage write SetFMixStrengthPercentage default 50;
      property Color3_Result:        TColor read   FColor3_Result        default clGray ;
    end;

  procedure Register;

implementation

  constructor TColorMixer.Create(AOwner: TComponent);
  begin
   inherited Create(AOwner);    
  end;

  function TColorMixer.Colorize(Sender: TObject; ColorOriginal, ColorAdded: TColor; PercentageStrength: Byte): TColor;
  var
   Color1, Color2:                        LongInt;
   ValueR, ValueG, ValueB, Value1, Value2: Byte;
  begin
   PercentageStrength:=Round(2.55*PercentageStrength);
   Color1:=ColorToRGB(ColorOriginal);
   Color2:=ColorToRGB(ColorAdded);
   Value1:=Byte(Color1);
   Value2:=Byte(Color2);
   ValueR:=PercentageStrength*(Value1-Value2) shr 8+Value2;
   Value1:=Byte(Color1 shr 8);
   Value2:=Byte(Color2 shr 8);
   ValueG:=PercentageStrength*(Value1-Value2) shr 8+Value2;
   Value1:=Byte(Color1 shr 16);
   Value2:=Byte(Color2 shr 16);
   ValueB:=PercentageStrength*(Value1-Value2) shr 8+Value2;
   Result:=(ValueB shl 16)+(ValueG shl 8)+ValueR;
  end;

  procedure Register;
  begin
   RegisterComponents('Sven Littkowski`s Best',[TColorMixer]);
  end;

end.
Zitat von MyDelphi 7:
[Error] ColorMixer.pas(22): Field or method identifier expected
[Error] ColorMixer.pas(23): Field or method identifier expected
[Error] ColorMixer.pas(24): Field or method identifier expected
[Hint] ColorMixer.pas(16): Private symbol 'SetColor3_Result' declared but never used
[Fatal Error] dclusr.dpk(176): Could not compile used unit '..\Projects\Sven\Unit ColorMixer\ColorMixer.pas'

Geändert von SvenLittkowski (10. Feb 2011 um 15:51 Uhr)
  Mit Zitat antworten Zitat