Ignore:
Timestamp:
Nov 23, 2012, 1:11:03 PM (12 years ago)
Author:
chronos
Message:
  • Added: Test using Graphics32 package TGR32Image class.
  • Modified: Used packages are now located uncompressed in Packages subfolder.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • GraphicTest/UFastBitmap.pas

    r442 r450  
    3838    constructor Create;
    3939    destructor Destroy; override;
    40     procedure RandomImage;
     40    procedure RandomImage(Index, Count: Integer);
    4141    property Size: TPoint read FSize write SetSize;
    4242    property Pixels[X, Y: Integer]: TFastBitmapPixel read GetPixel write SetPixel;
     
    204204end;
    205205
    206 procedure TFastBitmap.RandomImage;
     206procedure TFastBitmap.RandomImage(Index, Count: Integer);
    207207var
    208208  I, X, Y: Integer;
    209209begin
     210  // Main three color blocks
    210211  for I := 0 to 2 do
    211     for Y := 0 to (Size.Y div 2) - 1 do
     212    for Y := 0 to (Size.Y div 3) - 1 do
    212213      for X := 0 to (Size.X div 3) - 1 do
    213214        Pixels[X + (I * (Size.X div 3)), Y] := (255 shl (I * 8)) and $ffffff;
    214215
    215   for Y := (Size.Y div 2) to Size.Y - 1 do
     216  // Random noise
     217  for Y := (Size.Y div 3) to (Size.Y * 2 div 3) - 1 do
    216218    for X := 0 to Size.X - 1 do
    217219      Pixels[X, Y] := (Random(256) or (Random(256) shl 16) or (Random(256) shl 8)) and $ffffff;
     220
     221  // Color gradient
     222  for Y := (Size.Y * 2 div 3) to (Size.Y - 1) do begin
     223    for X := 0 to Size.X - 1 do
     224      Pixels[X, Y] := (Trunc(Sin((X + Trunc(Index / Count * Size.X)) mod Size.X
     225        / Size.X * pi) * 255) * $010101) and $ffffff;
     226  end;
    218227end;
    219228
Note: See TracChangeset for help on using the changeset viewer.