unit UniCaptcha;

interface
uses
  classes
,
 
Graphics,
  uniImage
;

type
TUniCaptcha=class(TUniImage)
 
private
   
FChallenge:ShortString;
    procedure
Render;
 
public
    constructor create
(Owner:TComponent);override;
    procedure
SetChallenge(aChallenge :ShortString);
  published
    property
Challenge  :ShortString    read FChallenge   write FChallenge;
end;

procedure
Register;

implementation

constructor
TUniCaptcha.Create(Owner:TComponent);
begin
  inherited
;
end;

procedure
TUniCaptcha.SetChallenge(aChallenge:ShortString);
begin
 
FChallenge:= aChallenge;
 
Render;
end;

procedure
TUniCaptcha.render;
Var
  b
:TBitmap;
  i
:Integer;
begin
  b
:=TBitmap.Create;
 
with b do
 
begin
    b
.Width  :=self.Width;
    b
.height :=self.Height;
   
For i :=0 to 30dobegin
      randomize
;
      canvas
.Pen.Width     := random(5)+5;
     
Canvas.Pen.Color     := random(64738)+64738;
     
Canvas.Brush.Style   := bsFDiagonal;

     
Canvas.Ellipse(random(width),random(Height),random(width),random(height));
   
end;
   
Canvas.Font.Color:= clBlue;
   
Canvas.Font.Size  :=18;
   
Canvas.TextOut(10,trunc(self.height/2),FChallenge);
   
Canvas.Font.Color:= clRed;
   
Canvas.TextOut(8,trunc(self.height/2)-2,FChallenge);
 
end;

 
Picture.Assign(B);
  b
.Free;
end;

procedure
Register;
begin
   
RegisterComponents('UniCustom',[TUniCaptcha]);
end;

end.