урок на делфи 38 - Елка с гирляндами


задание на delphi. гирлянды на елке


unit Unit1;
interface
uses
Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants, System.Classes, Vcl.Graphics,
Vcl.Controls, Vcl.Forms, Vcl.Dialogs, Vcl.ExtCtrls, Vcl.StdCtrls,math;
type
TForm1 = class(TForm)
Image1: TImage;
Shape1: TShape;
Shape2: TShape;
Shape3: TShape;
Shape4: TShape;
Shape5: TShape;
Shape6: TShape;
Shape7: TShape;
Shape8: TShape;
Shape9: TShape;
Shape10: TShape;
Shape11: TShape;
Shape12: TShape;
Shape13: TShape;
Shape14: TShape;
Shape15: TShape;
Shape16: TShape;
Shape17: TShape;
Label1: TLabel;
Timer1: TTimer;
Timer2: TTimer;
procedure Timer1Timer(Sender: TObject);
procedure Timer2Timer(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{Программа подготовлена для ролика на ютубе https://youtu.be/xhxYcu0CJM4
И скачена с сайте http://dear-ruslan.ru
Автор Салихьянов Руслан. }
{$R *.dfm}
procedure TForm1.Timer1Timer(Sender: TObject);
begin
if Timer1.Tag=0 then
Label1.Left:=Label1.Left-1;
if Label1.Left=0 then
Timer1.Tag:=1;
if Timer1.Tag=1 then
Label1.Left:=Label1.Left+1;
if Label1.Left=225 then
Timer1.Tag:=0;
end;
procedure TForm1.Timer2Timer(Sender: TObject);
var i,q:integer;
begin
for i := 0 to 18 do
begin
if Components[i] is TShape then
begin
q:=RandomRange(0,2);
if q=0 then
TShape(Components[i]).Brush.Color:=clRed;
if q=1 then
TShape(Components[i]).Brush.Color:=clYellow;
end;
end;
end;
end.



Скачать