Показать сообщение отдельно
  #1  
Старый 28.09.2015, 09:54
paraffin paraffin вне форума
Прохожий
 
Регистрация: 07.09.2015
Сообщения: 9
Версия Delphi: Delphi 7
Репутация: 10
По умолчанию вызов процедуры по таймеру

Нужно по таймеру вызывать процедуру Show(отрисовывает линию в paintbox1), а процедура FindPut должна срабатывать в процедуре Show, расчёт пути производится по переменной t, следовательно каждый раз когда срабатывает таймер переменная t должна увеличиваться на единицу t:=t+1, помогите пожалуйста заставить работать программу в данный момент компилятор ругается на 110 строку в MyClasses ошибка: Missing operator or semicolon.
Код:
unit Unit1;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, ExtCtrls, StdCtrls, MyClasses;

type
  TForm1 = class(TForm)
    PaintBox1: TPaintBox;
    Button1: TButton;
    Timer1: TTimer;
    procedure FormCreate(Sender: TObject);
    procedure PaintBox1Paint(Sender: TObject);
    procedure Button1Click(Sender: TObject);
    procedure Timer1Timer(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
end;

var
  Form1: TForm1;
  MyLine1: TMyLine;
implementation

{$R *.dfm}


procedure TForm1.FormCreate(Sender: TObject);
  begin
    Width:=960;   //ширина формы
    Height:=600;  //высота формы
  end;

procedure TForm1.PaintBox1Paint(Sender: TObject);
  begin
    MyLine1:=MyClasses.TMyLine.Create(PaintBox1.Canvas, 270, ((PaintBox1.Left+PaintBox1.Width) div 2), ((PaintBox1.Left+PaintBox1.Height) div 2), ClBlack, (PaintBox1.Width div 2-10), 5);
    PaintBox1.Canvas.Rectangle(8,8,208,208); //Рисует квадрат
    MyLine1.Show();  //отрисовывает линию
end;

procedure TForm1.Button1Click(Sender: TObject);
  begin
  if Timer1.Enabled then
    Timer1.Enabled := False //Выключает таймер
  else
    Timer1.Enabled := true;//Включает таймер
  end;

procedure TForm1.Timer1Timer(Sender: TObject);
  begin
    PaintBox1.Invalidate;
  end;

end.

Код:
unit MyClasses;

interface

uses
  SysUtils, Classes, Graphics;

type
  TZakon=class
  private
    { Private declarations }
    v:real; //скорость
    a:real; //ускорение
    s:real; //путь
  public
    { Public declarations }
    procedure FindSpeed(t:integer); //Находит скорость
    procedure FindAcc(t:integer);   //Находит ускорение
    procedure FindPut(t:integer);   //Находит путь
  end;

  //Класс Точка
type
  TMyPoint=class
  private
    { Private declarations }
    px:integer; // Координата Х точки
    py:integer; //Координата У точки
    cvet:TColor; //Цвет точки
  public
    { Public declarations }
    constructor Create(Newpx:integer; Newpy:integer; Newcvet:TColor);
end;

//Класс геометрическая фигура
type
  TGeometryFigure=class(TMyPoint)
  private
    { Private declarations }
    w:real; //Ширина фигуры
    h:real; //Высота фигуры
    ang:real; //Угол поворота фигуры
    x:integer; //Координата Х (докуда рисовать фигуру)
    y:integer; //Координата У (докуда рисовать фигуру)
  public
    { Public declarations }

    constructor Create(Newang:real; Newpx:integer; Newpy:integer; Newcvet:TColor; Neww:real; Newh:real);
  end;

type
  TMyLine=class(TGeometryFigure)
  private
    { Private declarations }
    FCanvas:TCanvas; //Холст для рисования
  public
    { Public declarations }
    procedure Show(); //отображает линию
    constructor Create(Destination:TCanvas; Newang:real; Newpx:integer; Newpy:integer; Newcvet:TColor; Neww:real; Newh:real);
  end;

var
  MyLine1:TGeometryFigure;
  FindPut:TZakon;
  s:real;
  t:integer;

implementation

{TZakon1}
procedure TZakon.FindAcc(t:integer); //Находит ускорение
  begin
    a:=sin(t);
  end;

procedure TZakon.FindPut(t:integer); //Находит путь
  begin
    s:=t-sin(t);
  end;

procedure TZakon.FindSpeed(t:integer); //Находит Скорость
  begin
    v:=-cos(t)+1;
  end;

{ TMyPoint }

constructor TMyPoint.Create(Newpx:integer; Newpy:integer; Newcvet:TColor);
  begin
    px:=Newpx;
    py:=Newpy;
    cvet:=Newcvet;
  end;

{ TGeometryFigure }

constructor TGeometryFigure.Create(Newang:real; Newpx:integer; Newpy:integer; Newcvet:TColor; Neww:real; Newh:real);
  begin
    inherited Create(Newpx, Newpy, Newcvet);
    w:=Neww;
    h:=Newh;
    ang:=Newang;
  end;

constructor TMyLine.Create(Destination: TCanvas; Newang:real; Newpx:integer; Newpy:integer; Newcvet:TColor; Neww:real; Newh:real);
  begin
    FCanvas:=Destination;
  end;

procedure TMyLine.Show();
begin
if not Assigned(FCanvas) then Exit;
FindPut(1);   //выполнение процедуры Найти путь
t:=t+1;
ang:=(s*180)/(Pi*w); //Расчёт угла на который переместится точка
x:=Round(px+w*cos(ang*pi/180)); //координата Х где теперь окажется точка 
y:=Round(py+w*sin(ang*pi/180)); //координата У где теперь окажется точка
FCanvas.MoveTo(px,py); //перемещение карандаша в центр окружности
FCanvas.LineTo(x,y);   //Отрисовка линии от центра окружности до точки с координатами Х,У
end;

end.
Ответить с цитированием