当前位置: 源码素材网 » Delphi教程 » 详情页

delphi随机选号 随机抽取号码 附动态效果

  •   时间:2018-12-16
  • 概述:随机生成字符

附有动态效果的delphi随机生成号码,随机选号,右侧的窗口具备动态效果,让选号程序更加生动,具体代码如下:

unit Unit1;
interface
uses
  Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
  ExtCtrls, TeEngine, Series, ArrowCha, TeeProcs, Chart, StdCtrls, Buttons;
type
  TForm1 = class(TForm)
    Chart1: TChart;
    ArrowSeries1: TArrowSeries;
    Timer1: TTimer;
    Panel1: TPanel;
    BitBtn3: TBitBtn;
    Memo1: TMemo;
    Label1: TLabel;
    procedure FormCreate(Sender: TObject);
    procedure Timer1Timer(Sender: TObject);
    procedure BitBtn3Click(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
    procedure AddRandomArrows;
  end;
var
  Form1: TForm1;
  data : array[1..15] of Extended;
implementation
{$R *.DFM}
procedure TForm1.FormCreate(Sender: TObject);
begin
  With ArrowSeries1 do
  Begin
    ArrowWidth:=32;
    ArrowHeight:=24;
    ColorEachPoint:=True;
    XValues.DateTime:=False;
    YValues.DateTime:=False;
    AddRandomArrows;
  end;
end;
procedure TForm1.AddRandomArrows;
var x0,y0,x1,y1:Double;
    t:Longint;
begin
  With ArrowSeries1 do
  Begin
    Clear;
    for t:=1 to 15 do
    begin
      x0:=Random( 1000 );
      y0:=Random( 1000 );
      x1:=Random( 300 ) - 150.0;
      if x1<50 then x1:=50;
      x1:=x1+x0;
      y1:=Random( 300 ) - 150.0;
      if y1<50 then y1:=50;
      y1:=y1+y0;
      AddArrow( x0,y0,x1,y1, '', clTeeColor );
    end;
  end;
end;
procedure TForm1.Timer1Timer(Sender: TObject);
var t:Longint;
begin
  Timer1.Enabled:=False;
  With ArrowSeries1 do
  Begin
    for t:=0 to Count-1 do
    Begin
      StartXValues[t]:=StartXValues[t]+Random(100)-50.0;
      StartYValues[t]:=StartYValues[t]+Random(100)-50.0;
      EndXValues[t]  :=EndXValues[t]+Random(100)-50.0;
      EndYValues[t]  :=EndYValues[t]+Random(100)-50.0;
      data[t+1] := StartXValues[t]+StartYValues[t]+EndXValues[t]+EndYValues[t];
    End;
    Repaint;
  End;
  Timer1.Enabled:=True;
end;
procedure TForm1.BitBtn3Click(Sender: TObject);
var
  t,d : integer;
  str : string;
begin
  if Timer1.Enabled then
  begin
     Timer1.Enabled := False;
     BitBtn3.Caption := '开始';
     for t:=1 to 15 do
     begin
        d := abs(round(data[t])mod 10);
        str := '第'+IntToStr(t)+'位:'+IntToStr(d);
        Memo1.Lines.Add(str);
     end;
  end
  else
  begin
     Timer1.Enabled := True;
     BitBtn3.Caption := '结束';
  end;
end;
end.

    相关声明:

      若“delphi随机选号 随机抽取号码 附动态效果”有损您的权益,请告之我们删除内容。
      部分文章来源于网络,版权归原作者所有。