Delphi Tutorial


 

Neon effects using basic colors

 

      

Download this example

procedure TForm1.FormCreate(Sender: TObject);

    { Draw 1 pixcel width line }
    procedure DrawLine(W,Y,H,L,RGBV:Integer; Step:Real);
    Var
        R, C : Integer;
    Begin
        For R:=0 To H Do
        Begin
            
{ Change fill color }
            If R<=L Then
            Begin
                C:=Round(R*Step);
                Case RGBV Of
                    1:Image1.Canvas.Pen.Color:=RGB(C,0,0);
                    2:Image1.Canvas.Pen.Color:=RGB(0,C,0);
                    3:Image1.Canvas.Pen.Color:=RGB(0,0,C);
                End;
            End
            Else If R<=2*L Then
            Begin
                C:=Round((R-L)*Step);
                Case RGBV Of
                    1:Image1.Canvas.Pen.Color:=RGB(255-C,0,0);
                    2:Image1.Canvas.Pen.Color:=RGB(0,255-C,0);
                    3:Image1.Canvas.Pen.Color:=RGB(0,0,255-C);
                End;
            End;
            { Fill area by drawing lines }
            Image1.Canvas.MoveTo(0,Y+R);
            Image1.Canvas.LineTo(W,Y+R);
        End;

    End;

Var
    Row, X, Y, H, H2, W, L : Integer;
    Step : Real;
begin
    { Get form size }
    H:=Image1.Height;
    W:=Image1.Width;

    { Fill image area by form color }
    Image1.Canvas.Brush.Color:=clBlack;
    Image1.Canvas.Pen.Color:=clBlack;
    Image1.Canvas.Rectangle(0,0,W,H);


    { Set fill size }
    H2:=100;
    L:=H2 Div 2;

    { Set fill step size }
    Step:=255/L;
    For Row:=1 To 3 Do
    Begin
        Y:=(Row-1)*150;
        DrawLine(W,Y,H2,L,Row,Step);
    End;
end;

DOWNLOAD this example

Click here to download this complete example for Delphi 6. (File size 4KB)

 

 

 

Go top

 


Previous Page First Page Next Page
 
Copyright © 2002 digitalcoding.com. All rights reserved.