三度网教程:是一个免费提供流行视频软件教程、在线学习分享的学习平台!

画动态多边型

时间:2023-12-20作者:未知来源:三度网教程人气:


type
  TPtArray = array[0..0] of TPoint;
  PPtArray = ^TPtArray;

procedure DrawDynamicPolyArray(NumPoints : integer;
                               Canvas : TCanvas);
var
  p : PPtArray;
  i : integer;
begin
{$IFOPT R+}
  {$DEFINE CKRANGE}
  {$R-}
{$ENDIF}
  GetMem(p, sizeof(TPoint) * NumPoints);
  Randomize;
  for i := 0 to (NumPoints -1) do begin
    p^[i].x := Random(Form1.Width);
    p^[i].y := Random(Form1.Height);
  end;
  Polygon(Canvas.Handle, p, NumPoints);
  FreeMem(p, sizeof(TPoint) * NumPoints);
{$IFDEF CKRANGE}
  {$UNDEF CKRANGE}
  {$R+}
{$ENDIF}
end;

procedure TForm1.Button1Click(Sender: TObject);
begin
  Form1.Canvas.Brush.Color := clWhite;
  Form1.Canvas.FillRect(Rect(0, 0, Form1.Width, Form1.Height));
  Form1.Canvas.Brush.Color := clRed;
  DrawDynamicPolyArray(SpinEdit1.Value,
                       Form1.Canvas);
end;

procedure TForm1.FormCreate(Sender: TObject);
begin
  SpinEdit1.MinValue := 2;
  SpinEdit1.MaxValue := 1000;
  SpinEdit1.Value := 100;
end;

end.

关键词:  画动态多边型





Copyright © 2012-2018 三度网教程(http://www.3du8.cn) .All Rights Reserved 网站地图 友情链接

免责声明:本站资源均来自互联网收集 如有侵犯到您利益的地方请及时联系管理删除,敬请见谅!

QQ:1006262270   邮箱:kfyvi376850063@126.com   手机版