Arsip: contoh sederhana fungsi random

 
user image
more 13 years ago

asiyrob

Ass.. Ganti warna font secara acak dengan fungsi random..ternyata simpel dan font jadi cantik. Siapkan 1label,1timer (atur interval timer=200) procedure TForm1.Timer1Timer(Sender: TObject); var x : integer; begin label1.Font.Color:=random(x); end; NB: "bisa juga buat ngacak posisi object dalam sebuah form..bahkan buat kursor mouse gerak sendiri kayak Virus gitu" :twisted: moga bermanfaat.. :P
user image
more 13 years ago

DelphiExpert

Jangan lupa panggil procedure Randomize terlebih dahulu untuk initializes the random number generator with a random value... biar lebih random gitu loh... :mrgreen: Taken from Delphi Help file: Randomize initializes the built-in random number generator with a random value (obtained from the system clock). The random number generator should be initialized by making a call to Randomize, or by assigning a value to RandSeed. Do not combine the call to Randomize in a loop with calls to the Random function. Typically, Randomize is called only once, before all calls to Random.
user image
more 8 years ago

apank2110

tolong dibantu donk... saya mau bikin undian bergambar secara acak..... saya punya 20 panel.... gimana caranya agar panel2 tsb berganti warna secara acak.....? help me....
user image
more 8 years ago

halimanh


const
  color : array of TColor = (clBlack, clMaroon, clGreen, clOlive,
                                    clNavy, clPurple, clTeal, clGray,
                                    clSilver, clRed, clLime, clYellow,
                                    clBlue, clFuchsia, clAqua, clLtGray,
                                    clDkGray, clWhite, clMoneyGreen, clSkyBlue,
                                    clCream, clMedGray);
function getRandomColor: TColor;
begin
  Result := Color[RandomRange(1, 22)];
end;

procedure TForm1.Button1Click(Sender: TObject);
begin
  panel1.Color := getRandomColor();
  Panel2.Color := getRandomColor();
  Panel3.Color := getRandomColor();
end;
procedure TForm1.FormActivate(Sender: TObject);
begin
  Randomize;
end;
user image
more 8 years ago

halimanh

yg ini tanpa button, ditambah timer di form

uses Math;
{$R *.dfm}
const
  color : array[1..22] of TColor = (clBlack, clMaroon, clGreen, clOlive,
    clNavy, clPurple, clTeal, clGray,
    clSilver, clRed, clLime, clYellow,
    clBlue, clFuchsia, clAqua, clLtGray,
    clDkGray, clWhite, clMoneyGreen, clSkyBlue,
    clCream, clMedGray);
function getRandomColor: TColor;
begin
 Result := Color[RandomRange(1, 22)];
end;
procedure TForm1.FormCreate(Sender: TObject);
begin
  Randomize;
end;
procedure TForm1.Timer1Timer(Sender: TObject);
begin
  panel1.Color := getRandomColor;
  panel2.Color := getRandomColor;
  panel3.Color := getRandomColor;
end;
user image
more 8 years ago

madi

walah, itu thread jaman jebot, tentunya sudah solved lah cepek deh :D
more ...
  • Pages:
  • 1
Share to

Random Topic

Local Business Directory, Search Engine Submission & SEO Tools FreeWebSubmission.com SonicRun.com